Error in writing a Client for RGB-Dslam
I am currently working on a project which requires me to use the RGB-D slam without a GUI. So i have to use the ros service calls for the various operations to be done by the node.
Now since the rgbdslam has to be used in sync with other nodes i can't always use the terminal to make rosservice commands.
So instead i am writing a client for the Rgbd-slam service. Here's the code which produces an error. Whenever i run the node below the service is not called and there is an error as in the ELSE loop.
ros::init(argc, argv, "rgbdslam_client");
ros::NodeHandle n;
ros::ServiceClient client = n.serviceClient<rgbdslam::rgbdslam_ros_ui>("rgbdslam_ros_ui");
rgbdslam::rgbdslam_ros_ui srv;
srv.request.command = "frame";
if (client.call(srv))
{
ROS_INFO("Capturing a frame");
}
else
{
ROS_ERROR("Failed to call service Rgbdslam frame capture ");
return 1;
}
return 0;
But when i use the Rosservice call command in the other terminal it works fine.
What could be a possible solution to the above problem..?
--edit--
@Felix Endres
Had to edit the line to this
ros::ServiceClient client = n.serviceClient<rgbdslam::rgbdslam_ros_ui>("/rgbdslam/ros_ui");
from
ros::ServiceClient client = n.serviceClient<rgbdslam::rgbdslam_ros_ui>("rgbdslam_ros_ui");
And it works fine.