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

how to get the starting simulation time from gazebo ?

asked 2012-01-12 07:34:04 -0600

maruchi gravatar image

Dear, I have a controller for a simple robot in gazebo. In my controller, I need to get the starting simulated time because there is lag between starting gazebo simulation and starting my controller. In my controller, I used this line (Init_time) to get the starting simulation time, but it always got out 0.

Init_time = ros::Time::now().toSec();

double time = odom->header.stamp.toSec();

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-01-12 07:40:44 -0600

DimitriProsser gravatar image

updated 2012-01-12 07:41:27 -0600

When you use sim time, the time starts at zero. That's not an error, that's just where time begins when you launch Gazebo. If you do a rostopic echo /clock, you will see that it's close to zero.

edit flag offensive delete link more

Comments

I start gazebo simulation first and then load my controller. When the gazebo simulation start, 'Sim Time' has passed by. When I start my controller, I want to use the 'Sim Time' when my controller loaded. What should I edit in my controller which is written as C++ ?
maruchi gravatar image maruchi  ( 2012-01-12 07:50:00 -0600 )edit
Do you start them in the same launch file or in two separate terminals?
DimitriProsser gravatar image DimitriProsser  ( 2012-01-12 08:00:04 -0600 )edit
I start them in two separate terminals. Do you think I have to start them in the same launch file ? If I start them in the same launch file, how can I put my cpp file in the lauch file? Could you guide me a tutorial ?
maruchi gravatar image maruchi  ( 2012-01-12 08:08:06 -0600 )edit
Do you have the "use_sim_time" parameter set to true?
DimitriProsser gravatar image DimitriProsser  ( 2012-01-13 00:59:46 -0600 )edit
Yes, I set "use_sim_time" parameter true
maruchi gravatar image maruchi  ( 2012-01-13 02:24:47 -0600 )edit
If you do `rostopic echo /clock`, does it show a simulated time properly? Also, try running your node without gazebo and use_sim_time and see if it works then.
DimitriProsser gravatar image DimitriProsser  ( 2012-01-13 03:07:48 -0600 )edit

Question Tools

Stats

Asked: 2012-01-12 07:34:04 -0600

Seen: 2,422 times

Last updated: Jan 12 '12