0
$\begingroup$

Rosanswers logo

hi
this is my service client code

include "ros/ros.h"
include "scenario/scenario.h"
include

int main(int argc, char **argv) {
ros::init(argc, argv, "remote");
ros::NodeHandle n;
ros::ServiceClient client = n.serviceClientscenario::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


Originally posted by mrpiccolo on ROS Answers with karma: 36 on 2013-02-11

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by ayush_dewan with karma: 1610 on 2013-02-12

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by mrpiccolo on 2013-02-12:
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]

Comment by ayush_dewan on 2013-02-12:
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..

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.