rosserial ServiceClient with request parameter
Hi everyone,
i want to access a Ros-Service e.g. over rosserial with parameter, what I am doing wrong?
#include <QCoreApplication>
#include "ros.h"
#include <ros/service_client.h>
#include <QDebug>
#include <string>
#include <stdio.h>
#include <windows.h>
#include <turtlesim/Spawn.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
ros::NodeHandle nh;
char *ros_master {nullptr};
qDebug() << "connect to ros...";
ros_master = "192.168.1.156:11411";
nh.initNode (ros_master);
ros::ServiceClient<turtlesim::Spawn::Request, turtlesim::Spawn::Response> turtle_client("spawn");
turtlesim::Spawn::Request request;
turtlesim::Spawn::Response response;
request.name="mikey";
request.x=3;
request.y=3;
request.theta=0;
nh.serviceClient(turtle_client);
turtle_client.call(request,response);
qDebug() << "connected";
while(!nh.connected()) nh.spinOnce();
qDebug() << "Name " << response.name;
return a.exec();
}
I got no Errors. IP and Port are correct. When I stop the rosserial-server I get "Failed to receive data from server 10093" as response. Rosserial with Publishing and Subscribing to a topic works, Services without parameter too, but not with parameter.
When I execute "rosservice call /spawn 3 3 0 mikey" direct in Terminal, I get as response "[ INFO] [1458045806.306323136]: Spawning turtle [mikey] at x=[3], y=[3], theta=[0]" but when i execute the code above i got nothing.
I thought, maybe I have an evident failure in my code !?
Asked by Cornec on 2016-03-15 04:15:40 UTC
Comments
Well: what is the error (if any) that you receive? What did you try, what didn't work, and why do you think it should've worked, and what are your hypotheses for why it didn't work?
Asked by gvdhoorn on 2016-03-15 06:42:41 UTC
It may help if you could tell us a bit more what you are trying to do: why do you want to use
rosserial
, which platform is this running on and why do you feel you cannot use the normalroscpp
client library?Asked by gvdhoorn on 2016-03-16 06:53:29 UTC
Also: please don't bump your question (ie: edit with no real changes).
Asked by gvdhoorn on 2016-03-16 06:53:54 UTC