You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When switching controllers from the cmdline via rosservice call /controller_manager/switch_controller ... it works out of the box. However doing the same from python code always failed silently (response was ok=True, but controller wasn't started as confirmed via rqt controller_manager plugin). Experimenting a little bit, I noticed that I need to load the controller in advance when switching programmatically. However calling the service from cmdline and from python should be the same, shouldn't it?
This works:
#!/usr/bin/env python3importrospyfromcontroller_manager_msgs.srvimportSwitchController, LoadControllerdefcall(ns, cls, **kwargs):
rospy.wait_for_service(ns)
service=rospy.ServiceProxy(ns, cls)
response=service(**kwargs)
print(response.ok)
ifnotresponse.ok:
print(response)
try:
# When calling the switch_controller service here, I need to ensure that the controller is loaded.# When calling the service via cmdline (rosservice call /controller_manager/switch_controller ...) it works without loading!?call("/controller_manager/load_controller", LoadController,
name="position_joint_trajectory_controller")
call("/controller_manager/switch_controller", SwitchController,
start_controllers=["position_joint_trajectory_controller"],
stop_controllers=["effort_joint_trajectory_controller"],
strictness=1, start_asap=False, timeout=0.0)
exceptrospy.ServiceExceptionase:
print("Service call failed: %s"%e)
The text was updated successfully, but these errors were encountered:
When switching controllers from the cmdline via
rosservice call /controller_manager/switch_controller ...
it works out of the box. However doing the same from python code always failed silently (response wasok=True
, but controller wasn't started as confirmed via rqt controller_manager plugin). Experimenting a little bit, I noticed that I need to load the controller in advance when switching programmatically. However calling the service from cmdline and from python should be the same, shouldn't it?This works:
The text was updated successfully, but these errors were encountered: