ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hi Jan.
I am also trying to do this. I can call the service in cpp code. The problem is I cannot add the parameters. Anyway, I can tell you how I did it.
ros::init(argc, argv, "tracker"); // Initialize ROS coms
ros::NodeHandle* n = (ros::NodeHandle*) new ros::NodeHandle("~"); //The node handle
ros::ServiceClient client = n->serviceClient<nodelet::NodeletLoad>("/nodelet_manager/load_nodelet"); //this is my service name
nodelet::NodeletLoad srv;
srv.request.name = "name1";
srv.request.type = "race_3d_object_tracking/race_3d_object_tracking_nodelet"; //this is my nodelet
//This is the part that does not work. But the rest does. Meaning I can call the service and it runs, but I cannot change the parameters
//srv.request.remap_source_args.push_back("name");
//srv.request.remap_target_args.push_back("new_name");
//srv.request.my_argv.push_back("point_cloud_in:=/camera/depth_registered/points");
if (client.call(srv))
{
ROS_INFO("Service response ok");
}
else
{
ROS_ERROR("Failed to call service");
}
2 | Just asking for help :) |
Hi Jan.
I am also trying to do this. I can call the service in cpp code. The problem is I cannot add the parameters. Anyway, I can tell you how I did it.
ros::init(argc, argv, "tracker"); // Initialize ROS coms
ros::NodeHandle* n = (ros::NodeHandle*) new ros::NodeHandle("~"); //The node handle
ros::ServiceClient client = n->serviceClient<nodelet::NodeletLoad>("/nodelet_manager/load_nodelet"); //this is my service name
nodelet::NodeletLoad srv;
srv.request.name = "name1";
srv.request.type = "race_3d_object_tracking/race_3d_object_tracking_nodelet"; //this is my nodelet
//This is the part that does not work. But the rest does. Meaning I can call the service and it runs, but I cannot change the parameters
//srv.request.remap_source_args.push_back("name");
//srv.request.remap_target_args.push_back("new_name");
//srv.request.my_argv.push_back("point_cloud_in:=/camera/depth_registered/points");
if (client.call(srv))
{
ROS_INFO("Service response ok");
}
else
{
ROS_ERROR("Failed to call service");
}
If you can find how to insert params please tell me.
Regards
Miguel