Ask Your Question

call nodeHandle->advertiseService

asked 2014-04-09 22:23:20 -0500

pkohout gravatar image


i try to advertise my service, but i am not able to compile.

Here is my msg file:

string sourceRobot
float64 x
float64 y

My srv file:

map_merger/pointFromRobot inputPoint
map_merger/pointFromRobot outputPoint

And here are the cpp parts according to the Service:

in map_merger.h:

 map_merger::pointFromRobot transformPoint(map_merger::transformPoint::Request req);

in map_merger.cpp:

 map_merger::pointFromRobot transformPoint(map_merger::transformPoint::Request req)
     map_merger::pointFromRobot returnValue;
    return returnValue;

in the Constructor the advertiseService is called (that does not work), here is the code:

 nodeHandle = new ros::NodeHandle("~");
    ros::ServiceServer service = nodeHandle->advertiseService("transformPoint",&MapMerger::transformPoint,this);

regard peter

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-04-09 22:30:15 -0500

If you have compile errors, you should always post them along with your question.

It appears you are not using the correct signature for the callback function, as described in Writing a Simple Service and Client (C++)), it should have two arguments (one for the request, one for the response).

edit flag offensive delete link more


i will post the error in future questions. I had to change the method to: bool transformPoint(map_merger::transformPoint::Request &req, map_merger::transformPoint::Response &res);

pkohout gravatar image pkohout  ( 2014-04-11 04:15:17 -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

1 follower


Asked: 2014-04-09 22:23:20 -0500

Seen: 754 times

Last updated: Apr 09 '14