ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Process blocking when using rosbags and rate sleep [closed]

asked 2011-08-04 20:33:35 -0500

updated 2011-09-02 11:52:02 -0500

mmwise gravatar image

Hi !

I'm launching a rosbag file from a launch. At the start of the launch I have:

  <param name="/use_sim_time" value="True"/>

then I call the rosbag as:

   <node pkg="rosbag" type="rosbag" name="rosbag"
         args="play --clock /home/andreu/rosbags/platformLaserFME.bag" />`

Finnally I call the node that I'm debugging:

   <node pkg="localization3d_node" type="localization3d_node" 
         name="localization3d_node"
         args="" output="screen"/>`

In my node localization3d_node, the mainThread() is just as follows:

  {
    this->myStuff();
    this->loop_rate_.sleep();
  }

where loop_rate_ is a ros::Rate type variable.

And at the localization3d_node constructor I set:

this->loop_rate_ = 5;//in [Hz]

So, the issue appears at execution: my node gets blocked since it executes the myStuff() function only once and then it stops sleeping for ever.

Observation: I recorded the rosbag also with the clock topic, so I don't see any difference in terms of published topics when I call rosbag play with/without the --clock option.

The question is: what I'm doing wrong to block my process ?

Thanks for your answers !!

Andreu

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Andreu
close date 2015-07-01 09:02:53.413519

3 Answers

Sort by ยป oldest newest most voted
1

answered 2011-08-08 08:36:01 -0500

tfoote gravatar image

The Rate.sleep() method will just sleep for the rest of the period.

You need to put it inside a for loop or while loop in your code if you want myStuff to be called multiple times.

edit flag offensive delete link more
0

answered 2011-08-24 19:13:37 -0500

hi all,

just to report that I was using rosbags in a confusing way, so that it could provoke the failure.

I was using a rosbag (let me call it as RB2) recorded from an original rosbag (RB1). In the recording process to obtain RB2 I called rosbag play without the --clock parameter, and, moreover, I only recorded two topics (/scan and /odometry). So I suppose that /clock was not recorded and /clock data of the RB1 was lost in that step.

It seems that when playing back RB2 with --clock option, timestamps of /tf and timestamps of /clock were completely different and this could be a cause to block my process.

thanks to all,

andreu

edit flag offensive delete link more
0

answered 2011-08-08 18:50:02 -0500

Thanks for the answer,

Yes, I've forgot to put a while(1) in my post, sorry! So to be more explicit the mainThread() is just as follows:

 {
      while(1)
      {
        this->myStuff();
        this->loop_rate_.sleep();
      }
  }

I've observed that if I call the rosbag with --clock the process gets blocked while if I remove the "--clock" option, the process iterates well, but in the later case I've (obvioulsy) problems with tf.

Thanks !

Andreu

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-08-04 20:33:35 -0500

Seen: 1,252 times

Last updated: Sep 02 '11