[ros-users] Weird ros::ok() actionlib::SimpleActionClient interactions...

Felix Ingrand felix at laas.fr
Thu Feb 3 10:01:02 UTC 2011


I am getting OpenPRS connected to ROS to supervise our PR2.

So far, I have done some testing with topics (subscribing and publishing)/services and all is good.

Trying to play with SimpleAction (which seem to be the best tool in ROS to supervise nodes) I am witnessing a weird problem.

- the version of OpenPRS I use is NOT multithreaded, but it uses SIGALARM
- I have an evaluable predicate which automatically and periodically (100 Hz) call 
  if (ros::ok()) {
 and this takes care of all the callbacks (and indeed, it works with subscribed topics).

Now, when I create a SimpleAction client (using the Fibonacci server example) with this code:

 if (PUGetOprsParameters(terms, 1,
			  INTEGER, &seq)) {
    // Create the action client
    Client ac("fibonacci", true);
    ROS_INFO("Waiting for action server to start.");
    ROS_INFO("Action server started, sending goal.");

    // Send Goal
    learning_actionlib::FibonacciGoal goal;
    goal.order = seq;
    ac.sendGoal(goal, &doneCb, &activeCb, &feedbackCb);
It works, and shortly after (even before calling spinOnce explicitly), I get the activeCb called (once) and the feedbackCB called (only once with seq value 3). So I guess that there is an implicit spinOnce done somewhere here in the sendGoal.

If I put the following code just after the sendGoal:

    while (ros::ok()) {
    ros::spinOnce();		// This will call the callbacks.

Then the sequence callback is called for all the values and the doneCB (to which I added at the end a ros::Shutdown to let the ros::ok return false and leave the loop) is also called. good...

But if I comment this loop, and rely on the evaluable predicate which will be called later by the OpenPRS main loop, then ros::ok() return true until I call the function doing the sendGoal, after which it returns false.

I am running all this on Ubuntu 10.4 (based on the VirtualBox machine proposed by WG, and properly up to date).

Before I dig further, any idea what I may be doing wrong here? I can see that SimpleActionClient starts a lot of threads, still the code I use to spin ROS after the sendGoal OR in the evaluable predicate are executing in the same thread (the main one)... why does it work when it is just "after" the sendGoal and not a few milliseconds later? 

Moreover, the SIGALARM handler does NOT execute the spinOnce, it merely flip a flag to tell the OpenPRS main loop to check for evaluable predicates.

Thanks for any help,

PS: is there a way to trace/see what is the reason why a node is suddenly returning ros::ok() false?
You think you are making economical rational decisions...

More information about the ros-users mailing list