ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hello sir,
You need to use request responce messages specific to ros_control package, in particular the controller_manager/switch_controller service . These are defined here: https://github.com/ros-controls/ros_control/tree/noetic-devel/controller_manager_msgs/srv
The code then would look something like:
#include "controller_manager_msgs/SwitchController.h"
#include <ros/ros.h>
bool switchController(...){
controller_manager_msgs::SwitchControllerRequest req;
controller_manager_msgs::SwitchControllerResponse res;
//Choose which controller to load/unload
req.start_controllers = ...;
req.stop_controllers = ...;
req.strictness = 1;
req.start_asap = true;
req.timeout = 2.;
ros::service::call("/myrobot/controller_manager/switch_controller", res, req);
return res.ok;
}
2 | No.2 Revision |
Hello sir,
You need to use request responce messages specific to ros_control package, in particular the controller_manager/switch_controller service . These are defined here: https://github.com/ros-controls/ros_control/tree/noetic-devel/controller_manager_msgs/srv
The code then would look something like:
#include "controller_manager_msgs/SwitchController.h"
#include <ros/ros.h>
bool switchController(...){
controller_manager_msgs::SwitchControllerRequest req;
controller_manager_msgs::SwitchControllerResponse res;
//Choose which controller to load/unload
req.start_controllers = ...;
req.stop_controllers = ...;
req.strictness = 1;
req.start_asap = true;
req.timeout = 2.;
ros::service::call("/myrobot/controller_manager/switch_controller", res, req);
&res, &req);
return res.ok;
}
3 | No.3 Revision |
Hello sir,
You need to use request responce messages specific to ros_control package, in particular the controller_manager/switch_controller service . These are defined here: https://github.com/ros-controls/ros_control/tree/noetic-devel/controller_manager_msgs/srv
The code then would look something like:
#include "controller_manager_msgs/SwitchController.h"
#include <ros/ros.h>
bool switchController(...){
controller_manager_msgs::SwitchControllerRequest req;
controller_manager_msgs::SwitchControllerResponse res;
//Choose which controller to load/unload
req.start_controllers = ...;
req.stop_controllers = ...;
req.strictness = 1;
req.start_asap = true;
req.timeout = 2.;
ros::service::call("/myrobot/controller_manager/switch_controller", &res, &req);
res, req);
return res.ok;
}