ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hi Ammar,
I think your have this problem because your subscriber object doesn't live outside its scope (constructor). You need to declare it as a private object in your class
private:
ros:Subscriber ...
then you can initialize it in the constructor. In the main function, when you create the object, you will have a running subscriber in your object.
2 | No.2 Revision |
Hi Ammar,
I think your have this problem because your subscriber object doesn't live outside its scope (constructor). You need to declare it as a private object in your class
private:
ros:Subscriber ...
sub;
then you can initialize it in the constructor. constructor:
sub = n.subscribe("chatter", 1000, &Listener::callback, &listener);
In the main function, when you create the object, you will have a running subscriber in your object.
3 | No.3 Revision |
Hi Ammar,
I think your you have this problem because your subscriber object doesn't live outside its scope (constructor). You need to declare it as a private object in your class
private:
ros:Subscriber sub;
then you can initialize it in the constructor:
sub = n.subscribe("chatter", 1000, &Listener::callback, &listener);
In the main function, when you create the object, you will have a running subscriber in your object.