0
$\begingroup$

Rosanswers logo

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


Originally posted by Andreu on ROS Answers with karma: 169 on 2011-08-04

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by tfoote with karma: 58457 on 2011-08-08

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.