Ask Your Question
0

service error

asked 2013-02-11 22:44:41 -0500

mrpiccolo gravatar image

updated 2014-01-28 17:15:12 -0500

ngrennan gravatar image

hi
this is my service client code

include "ros/ros.h"
include "scenario/scenario.h"
include <cstdlib>

int main(int argc, char **argv) {
ros::init(argc, argv, "remote");
ros::NodeHandle n;
ros::ServiceClient client = n.serviceClient<scenario::scenario>("stringa");
ros::Rate loop_rate(0.5);
while (ros::ok()){
scenario::scenario srv;
srv.request.pc="hello word";
if (client.call(srv)){
if((unsigned)srv.response.rasp[0]!=255)
ROS_INFO("%s", srv.response.rasp);
} else
{
ROS_ERROR("Failed to call service scenario");
return 1;
}
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}

but when i launch the program receive ERROR Failed to call service scenario, what is the problem?
P.S i create the service that is called scenario

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2013-02-11 23:23:16 -0500

Check whether service is getting started correctly using rosservice list command and try calling service from terminal, if it works fine then service is working fine but the way ur calling ur code is not correct.

edit flag offensive delete link more

Comments

i typed rosservice list /local/get_loggers /local/set_logger_level /rosout/get_loggers /rosout/set_logger_level /stringa and then rosservice type stringa ERROR: Unable to communicate with service [/stringa], address [rosrpc://nicolo-laptop:40626]

mrpiccolo gravatar image mrpiccolo  ( 2013-02-12 01:29:01 -0500 )edit

If this is the case then ur service declaration might have some problem. Name of the service is same as package name so try changing name of the service from scenario to something else..it might resolve the problem..

ayush_dewan gravatar image ayush_dewan  ( 2013-02-12 03:23:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-02-11 22:44:41 -0500

Seen: 1,480 times

Last updated: Feb 11 '13