Revision history [back]

In both yours:

while (ros::ok()) {
...
}


you must call:

ros::spinOnce();


otherwise callbacks are not called/executed

In both yours:

while (ros::ok()) {
...
}


you must call:

ros::spinOnce();


otherwise callbacks are not called/executed

Furthermore in the first script you call the constructor of the class, but af the end it will automatically call your destructor since you intialize your class, do nothing, and then you go back to main.

In both yours:

while (ros::ok()) {
...
}


you must call:

ros::spinOnce();


otherwise callbacks are not called/executed

Furthermore in the first script you call the constructor of the class, but af the end it will automatically call your destructor since you intialize your class, do nothing, and then you go back to main.

To understand what I mean try something like that:

TeleopAgv::TeleopAgv()
{
...
ROS_INFO("Calling the constructor of class bla bla");
}

TeleopAgv::~TeleopAgv()
{
ROS_INFO("Calling the destructor of class bla bla");
}