0
$\begingroup$

Rosanswers logo

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();


Originally posted by maruchi on ROS Answers with karma: 157 on 2012-01-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by DimitriProsser with karma: 11163 on 2012-01-12

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by DimitriProsser on 2012-01-13:
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.

Comment by maruchi on 2012-01-13:
Yes, I set "use_sim_time" parameter true

Comment by DimitriProsser on 2012-01-13:
Do you have the "use_sim_time" parameter set to true?

Comment by maruchi on 2012-01-12:
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 ?

Comment by DimitriProsser on 2012-01-12:
Do you start them in the same launch file or in two separate terminals?

Comment by maruchi on 2012-01-12:
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++ ?

$\endgroup$

Your Answer

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