Ask Your Question

ROS_INFO not printing anything after some point

asked 2012-08-12 12:58:46 -0500

130s gravatar image

updated 2012-08-13 09:05:11 -0500

In my code below, constructor of a class calls functions within the same class. All ROS_INFO in func1 print successfully but func2 doesn't print anything. Any idea?

Update 8/13/2012) Each action server is robot manipulation, which means there's fair amount of time before func2 gets called after func1.

#include <ros/ros.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <pointcloud_filter/PointCloudFilterBoxAction.h>
#include <pointcloud_filter/PointCloudFilterBoxGoal.h>
#include <pointcloud_segmenter/RGBPointCloudSegmenterAction.h>
#include <pointcloud_segmenter/RGBPointCloudSegmenterGoal.h>

class OurClass
    static const double DURATION = 30.0;
    void func1()
        ROS_INFO("msg 1-0");
        actionlib::SimpleActionClient<ourns::OurAction> ac("ourAction", true);
        bool finished_before_timeout = ac.waitForResult(ros::Duration(DURATION));
        if (finished_before_timeout)
            actionlib::SimpleClientGoalState state = ac.getState();
            ROS_INFO("msg 1-1");
            ROS_INFO("msg 1-2");

    void func2()
        ROS_INFO("msg 2-0 ");
        actionlib::SimpleActionClient<pointcloud_filter::PointCloudFilterBoxAction> ac_filter("PointCloudFilterBox", true);
        bool finished_before_timeout2 = ac_filter.waitForResult(ros::Duration(DURATION));
        if (finished_before_timeout2)
            actionlib::SimpleClientGoalState state = ac_filter.getState();

int main(int argc, char **argv)
    ros::init(argc, argv, "AcClient");

Environment) fuerte, Ubuntu 10.04

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-08-13 00:33:50 -0500

ipso gravatar image

If the code you posted really is 'all there is', then it seems to at least be missing a ros::spin() or similar statement. If the ros event loop is run somewhere else, the ros::init(..) seems out of place.

What is most likely going on is that the ros logging subsystem has 'enough' time to flush out the ROS_INFO(..) calls in func1(), but not for those in func2(). I've noticed this myself a few times, especially when trying to print some output at node(let) shutdown (to print statistics for instance).

Suggestions I've received included 'sleeping some time' before calling ros::shutdown(..) (if doing so explicitly) or before returning from your main.

edit flag offensive delete link more


Looks reasonable explanation although I can't test it since I don't have an access to the environment I was seeing the phenomenon...

130s gravatar image 130s  ( 2013-03-28 21:41:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-08-12 12:58:46 -0500

Seen: 2,625 times

Last updated: Aug 13 '12