Home | Tutorials | Wiki | Issues
Ask Your Question

What does multi_step in world_control.proto do?

asked 2018-08-14 10:04:54 -0600

LinasKo gravatar image

I am trying to execute several steps of Gazebo7 simulation by sending a msgs::WorldControl message to Gazebo where simulation is paused. In effect, I aim to advance the simulation by a varying amount of time. However, regardless of what number I pass using msg.set_multi_step(m_stepCount), I cannot seem to advance by more than 1 iteration.

Did I misunderstand what multi_step does?

Relevant code excerpt from one of my experiments:

    void OnUpdate() 
        // Throttle Publication

        m_step_count = m_step_count == 1 ? 700 : 1;

        msgs::WorldControl msg;

        // msgs::WorldControl stepMsg;
        // stepMsg.set_step(1);
        // this->pub->Publish(stepMsg);

        std::cout << "Publishing OnUpdate. Steps: " << m_step_count << std::endl;

The result is that every second:

  • Iteration increases by 1
  • Sim Time increases by 00 00:00:00.001
  • Real Time is increased by 00 00:00:01.000
  • 700 or 1 are printed in the output string, alternating on every tick
edit retag flag offensive close merge delete


The issue has been solved, but I will keep this question open for answers regarding the effects of setting the multi_step field.

LinasKo gravatar imageLinasKo ( 2018-08-15 03:52:22 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-14 12:07:55 -0600

If you're using a world plugin, OnUpdate is called at every iteration within the physics thread. So I think what's happening is that you're introducing a 1 s sleep to every iteration - it will take 700 s until your 700 steps are processed.

I recommend you use a standalone program like this one so you don't block the physics thread.

edit flag offensive delete link more


Is there a specific reason to not block the physics thread, as it seems to be exactly what I want to do. Basically, for cross-compatibility with another product I'm working on, I want to Sense -> run physics for time t0 -> Drive -> run physics for time t1 -> Repeat

LinasKo gravatar imageLinasKo ( 2018-08-15 03:44:08 -0600 )edit

Ultimately, with your help, I think figured it out. I have removed `MSleep` and will block the OnUpdate until a volatile boolean value is updated from another thread, resuming the simulation, instead of trying to advance it by setting multi_step. I am aware this might not be the best solution in the long term and will be investigating the more usual way of running it asynchronously as well. Thank you.

LinasKo gravatar imageLinasKo ( 2018-08-15 03:50:21 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-08-14 10:04:54 -0600

Seen: 84 times

Last updated: Aug 14 '18