ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I haven't tried out empty world yet, but I did set up a more stripped down test that uses a sim clock from a python script https://github.com/lucasw/simple_sim_ros/tree/master/sim_clock
rosparam set /use_sim_time true
rosrun sim_clock timer_test
rosrun sim_clock sim_clock.py
...
<< ", wall: " << ros::WallTime::now() - wall_start
<< ", now: " << ros::Time::now() - start
<< ", expected: " << (e.current_expected - start).toSec()
<< ", real: " << (e.current_real - start).toSec()
...
[ INFO] [/test] [/home/lucasw/catkin_ws/src/simple_sim_ros/sim_clock/src/timer_test.cpp]:[40] [, wall: 1504364679.261232420, now: 0.230000000]
callback 1, wall: 0.1024454, now: 0.10, expected: 0.1, real: 0.1
callback 1, wall: 0.2032164, now: 0.20, expected: 0.2, real: 0.2
callback 1, wall: 0.3050205, now: 0.30, expected: 0.3, real: 0.3
callback 1, wall: 0.4067237, now: 0.40, expected: 0.4, real: 0.4
callback 1, wall: 0.5088974, now: 0.50, expected: 0.5, real: 0.5
callback 1, wall: 0.6099449, now: 0.60, expected: 0.6, real: 0.6
callback 1, wall: 0.7113141, now: 0.70, expected: 0.7, real: 0.7
callback 1, wall: 0.8135823, now: 0.80, expected: 0.8, real: 0.8
callback 1, wall: 0.9157257, now: 0.90, expected: 0.9, real: 0.9
callback 2, wall: 1.0178376, now: 1.00, expected: 1, real: 1
callback 1, wall: 1.0178843, now: 1.00, expected: 1, real: 1
...
The odd thing I see is the sim time is 0.23 when it should be much closer to 0 after the sleep:
ros::init(argc, argv, "test");
ros::NodeHandle n;
// don't get the wall time until a clock has been received
ros::Duration(0.0001).sleep();
start = ros::Time::now();
wall_start = ros::WallTime::now();
ROS_INFO_STREAM("wall: " << wall_start
<< ", now: " << start);
I'm curious what gazebo is doing with publishing /clock at start time (I'll try out empty.world and update this later) - it could be that it publish it once but then takes a second to initialize other things (and repeats that once more?).
2 | No.2 Revision |
I haven't tried out empty world yet, but I did set up a more stripped down test that uses a sim clock from a python script https://github.com/lucasw/simple_sim_ros/tree/master/sim_clock
rosparam set /use_sim_time true
rosrun sim_clock timer_test
rosrun sim_clock sim_clock.py
...
<< ", wall: " << ros::WallTime::now() - wall_start
<< ", now: " << ros::Time::now() - start
<< ", expected: " << (e.current_expected - start).toSec()
<< ", real: " << (e.current_real - start).toSec()
...
[ INFO] [/test] [/home/lucasw/catkin_ws/src/simple_sim_ros/sim_clock/src/timer_test.cpp]:[40] [, wall: 1504364679.261232420, now: 0.230000000]
callback 1, wall: 0.1024454, 0.10244, now: 0.10, expected: 0.1, real: 0.1
callback 1, wall: 0.2032164, 0.20321, now: 0.20, expected: 0.2, real: 0.2
callback 1, wall: 0.3050205, 0.30502, now: 0.30, expected: 0.3, real: 0.3
callback 1, wall: 0.4067237, 0.40672, now: 0.40, expected: 0.4, real: 0.4
callback 1, wall: 0.5088974, 0.50889, now: 0.50, expected: 0.5, real: 0.5
callback 1, wall: 0.6099449, 0.60994, now: 0.60, expected: 0.6, real: 0.6
callback 1, wall: 0.7113141, 0.71131, now: 0.70, expected: 0.7, real: 0.7
callback 1, wall: 0.8135823, 0.81358, now: 0.80, expected: 0.8, real: 0.8
callback 1, wall: 0.9157257, 0.91572, now: 0.90, expected: 0.9, real: 0.9
callback 2, wall: 1.0178376, 1.01783, now: 1.00, expected: 1, real: 1
callback 1, wall: 1.0178843, 1.01788, now: 1.00, expected: 1, real: 1
...
The odd thing I see is the sim time is 0.23 when it should be much closer to 0 after the sleep:
ros::init(argc, argv, "test");
ros::NodeHandle n;
// don't get the wall time until a clock has been received
ros::Duration(0.0001).sleep();
start = ros::Time::now();
wall_start = ros::WallTime::now();
ROS_INFO_STREAM("wall: " << wall_start
<< ", now: " << start);
I'm curious what gazebo is doing with publishing /clock at start time (I'll try out empty.world and update this later) - it could be that it publish it once but then takes a second to initialize other things (and repeats that once more?).