ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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; }
2 | No.2 Revision |
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::Rate loop_rate(10);
return 0; }