ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I think you cant intialise a ServiceServer in your header file as it isn't really called in your main code. Your function to be called can be in your header file, but try moving your

get_version_srv = node_.advertiseService("get_version", &Eddie::get_board_version, this);

plus any referencing of your node (it probably cant be declared in a header file) into your main code, and instead of using "this" as the last parameter, you need &eddie.

I had this same problem and it was do to an incorrect value in the third parameter.

so that your main code is:

int main(int argc, char** argv) {

ROS_INFO("Initializing the robot's control board");

ros::init(argc, argv, "parallax_board");

Eddie eddie;

//plus initialisation of _node

get_version_srv = node_.advertiseService("get_version", &Eddie::get_board_version, &eddie);

ros::Rate loop_rate(10);

return 0; }

I think you cant intialise a ServiceServer in your header file as it isn't really called in your main code. Your function to be called can be in your header file, but try moving your

get_version_srv = node_.advertiseService("get_version", &Eddie::get_board_version, this);

plus any referencing of your node (it probably cant be declared in a header file) into your main code, and instead of using "this" as the last parameter, you need &eddie.

I had this same problem and it was do to an incorrect value in the third parameter.

so that your main code is:

int main(int argc, char** argv) {

{ ROS_INFO("Initializing the robot's control board");

board"); ros::init(argc, argv, "parallax_board");

"parallax_board"); Eddie eddie;

eddie; //plus initialisation of _node

_node get_version_srv = node_.advertiseService("get_version", &Eddie::get_board_version, &eddie);

&eddie); ros::Rate loop_rate(10); return 0; }

ros::Rate loop_rate(10);

return 0; }