How could I switch ros controllers using ros controller_manager/switch_controller service in c++
Hi,
Right now, I can switch position controllers and torque controllers by running the following commands in a terminal.
rosservice call /myrobot/controller_manager/switch_controller "{start_controllers: ['joint1_torque_controller'],stop_controllers: [joint1_position_controller], strictness: 2}"
But, the question is how to implement that in my c++ code. I find something here. It is ros::service::call(const std::string & service_name, MReq & req, MRes & res ). The question become how to convert "{start_controllers: ['joint1_torque_controller'],stop_controllers: [joint1_position_controller], strictness: 2}" to be a MReq.
Thanks in advance