Revision history [back]

The first answer to Significance of ros::spinOnce() will probably help you.you. Also: roscpp/Overview/Callbacks and Spinning from roscpp.

The first answer to Significance of ros::spinOnce() will probably help you. Also: roscpp/Overview/Callbacks and Spinning from roscpp.

Edit:

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

ros::spin();

return 0;
}


The ros::spin() will never return, and is probably why your other callbacks aren't being serviced. As you can read in the Significance of ros::spinOnce() answer, replacing it with something like:

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

while (ros::ok() && smart_ray_ok())
{
// let the smart ray event loop do its thing
process_smart_ray_events()

// let ros do its things
ros::spinOnce();
}


Will give the smart ray SDK a chance to process its incoming data (and call the registered UserCB).

As I have no experience with that particular SDK, I cannot say what process_smart_ray_events() should really be, that is something you'll have to figure out yourself.

The first answer to Significance of ros::spinOnce() will probably help you. Also: roscpp/Overview/Callbacks and Spinning from roscpp.

Edit:

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

ros::spin();

return 0;
}


The ros::spin() will never return, and is probably why your other callbacks aren't being serviced. As you can read in the Significance of ros::spinOnce() answer, replacing it with something like:

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

while (ros::ok() && smart_ray_ok())
{
// let the smart ray event loop do its thing
process_smart_ray_events()

// let ros do its things
ros::spinOnce();
}


Will give the smart ray SDK a chance to process its incoming data (and call the registered UserCB).

As I have no experience with that particular SDK, I cannot say what process_smart_ray_events() should really be, that is something you'll have to figure out yourself.

As an alternative to the above, you could use an AsyncSpinner, which would remove the need for the while loop and the ros::spinOnce(). See the linked roscpp/Overview/Callbacks and Spinning page for more information on that.

The first answer to Significance of ros::spinOnce() will probably help you. Also: roscpp/Overview/Callbacks and Spinning from roscpp.

Edit:

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

ros::spin();

return 0;
}


The ros::spin() will never return, and is probably why your other callbacks aren't being serviced. As you can read in the Significance of ros::spinOnce() answer, replacing it with something like:

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

while (ros::ok() && smart_ray_ok())
{
// let the smart ray event loop do its thing
process_smart_ray_events()

// let ros do its things
ros::spinOnce();
}


Will give the smart ray SDK a chance to process its incoming data (and call the registered UserCB).

As I have no experience with that particular SDK, I cannot say what smart_ray_ok() and process_smart_ray_events() should really be, be (or if they even exist), that is something you'll have to figure out yourself.

As an alternative to the above, you could use an AsyncSpinner, which would remove the need for the while loop and the ros::spinOnce(). See the linked roscpp/Overview/Callbacks and Spinning page for more information on that.

The first answer to Significance of ros::spinOnce() will probably help you. Also: roscpp/Overview/Callbacks and Spinning from roscpp.

Edit:

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

ros::spin();

return 0;
}


The ros::spin() will never return, and is probably why your other callbacks aren't being serviced. As you can read in the Significance of ros::spinOnce() answer, replacing it with something like:

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

ros::Rate loop_rate(10);

while (ros::ok() && smart_ray_ok())
{
// let the smart ray event loop do its thing
process_smart_ray_events()

// let ros do its things
ros::spinOnce();

// sleep some (only if needed)
loop_rate.sleep();
}


Will give the smart ray SDK a chance to process its incoming data (and call the registered UserCB).

As I have no experience with that particular SDK, I cannot say what smart_ray_ok() and process_smart_ray_events() should really be (or if they even exist), that is something you'll have to figure out yourself.

As an alternative to the above, you could use an AsyncSpinner, which would remove the need for the while loop and the ros::spinOnce(). See the linked roscpp/Overview/Callbacks and Spinning page for more information on that.