Process blocking when using rosbags and rate sleep [closed]

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 ?

Andreu

edit retag 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

Sort by » oldest newest most voted

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.

more

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

more

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

more