Home | Tutorials | Wiki | Issues
Ask Your Question

peek - Finding location of models after specified time

asked 2015-09-02 02:02:47 -0500

AbdealiJK gravatar image

updated 2015-09-02 23:15:50 -0500

I want to find the estimated position of a model after a time X. So, I basically want gazebo to run the simulation for time X and give back the ModelState after it runs it for time X.

I am currently using the ROS Service /gazebo/get_model_state and /gazebo/pause_physics with /gazebo/unpause_physics to:

unpause -> wait for time X -> pause -> query model state

But this is giving inaccurate results. I guess because the "wait for time X" is bad. I need it to give the same positions repeatably.

How do I do something like what I want ?

EDIT: This is the algorithm I wish to run:

  1. Launch file is run, Node1 and gazebo started. Gazebo is paused initially.
  2. Node1 sets some motor velocities
  3. Gazebo is unpaused. As soon as 1 sec passes in simulation time, gazebo pauses and give back the state of the model
  4. Node1 finds the new motor velocities to set, and it publishes that.
  5. Goto step 3
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-09-02 15:33:25 -0500

niall gravatar image

I expect when you say you're using ROS Service that you're calling it from the command line? If so then yes it will always be a little off.

You could write a ROS node that checks the rostopic /clock and if the time is right, calls the service get_model_state to get your model position. You have to enable use_sime_time when starting Gazebo though to make sure the clocks are synchronized (http://answers.gazebosim.org/question/3172/timing-synchronisation-between-gazebo-and-ros/). The node can run as fast as you want so it will check the time every Gazebo iteration making it fast enough for your needs I expect. Good luck!

edit flag offensive delete link more


When I said I was using the ros service, I did it through a C code (where I used the usleep function for the time gap). I'll try the /clock you mentioned and see if that works out. I hope the simulation does not become considerably slower because of the topic to /clock

AbdealiJK gravatar imageAbdealiJK ( 2015-09-02 22:40:13 -0500 )edit

niall, I tried subscribing to /clock, but I had to set my queueDepth to 10000, as with queueDepth=1, it skipped a lot of clock ticks. I found that the rosnode was lagging behind the actual gazebo simulation. I need to set a new velocity every time I query the current state, and as the rosnode and gazebo are running at different speeds, I the action is being set in the future according to gazebo. You mentioned I can make the rosnode "can run as fast as I want" - what did you mean by that ?

AbdealiJK gravatar imageAbdealiJK ( 2015-09-02 23:08:50 -0500 )edit

Did you try use_sim_time? This will sync Gazebo and ROS clock. With run as fast as you want I mean it can be set to run every time a callback is received from clock, that is a lot faster then you want to do anything.

niall gravatar imageniall ( 2015-09-03 09:54:12 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2015-09-02 02:02:47 -0500

Seen: 183 times

Last updated: Sep 02 '15