0
$\begingroup$

Rosanswers logo

I currently have a set of N controllers "controller_i" which all use the same resources. Intially when I launch Gazebo and Rviz all the controllers are stopped. What I would like to do is turn off and on the controllers in my code.

I can do this by calling the appropriate controller_manager service, see bellow.

ros::ServiceClient                          controller_manager_service;
controller_manager_msgs::SwitchController   switch_msg;

  controller_manager_service = nh.serviceClient<controller_manager_msgs::SwitchController>("/controller_manager/switch_controller");

 switch_msg.request.start_controllers = {{"controller_1"}};
 switch_msg.request.stop_controllers  = {{"controller_2"}};
 switch_msg.request.strictness        = controller_manager_msgs::SwitchController::Request::STRICT;
 controller_manager_service.call(switch_msg);

Here decided to start controller_1 and stop controller_2. However I would like to know of a way to query the controller_manager to know which controllers are active.

In this way I can set switch_msg.request.stop_controllers to the currently running controller.


Originally posted by gpldecha on ROS Answers with karma: 285 on 2015-12-13

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Wouldn't controller_manager_msgs/srv/ListControllers get you the list of controllers (then check state field of each ControllerState)?


Originally posted by gvdhoorn with karma: 86574 on 2015-12-13

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.