I followed this tutorial (ROS/Tutorials/WritingPublisherSubscriber(python) - ROS Wiki) and everything works fine for real/wall time.
But then I tested the same code with simulation time (in separate windows/terminals):
$ roscore
$ rosparam set use_sim_time true
$ ./talker.py
[INFO] [1688140481.155550, 0.000000]: hello world 0.0
$ ./listener.py
$ rostopic pub /clock rosgraph_msgs/Clock [1,0] --use-rostime
publishing and latching message. Press ctrl-C to terminate
The "talker" didn't react to the updated ROS time. Then I cancelled (Ctrl-c) and I tried:
$ rostopic pub /clock rosgraph_msgs/Clock [2,0] --use-rostime
publishing and latching message. Press ctrl-C to terminate
Then the talker printed two messages for time = 2.0 seconds:
[INFO] [1688140488.717273, 2.000000]: hello world 2.0
[INFO] [1688140488.719683, 2.000000]: hello world 2.0
This is not what I expected.
- Why doesn't the talker react to the new simulation time of 1 second?
- Why does the the talker see two messages, when the simulation time is updated to 2 seconds?
ROS environment variables:
ROS_VERSION=1
ROS_DISTRO=noetic
ROS_ETC_DIR=/opt/ros/noetic/etc/ros
ROSLISP_PACKAGE_DIRECTORIES=
ROS_MASTER_URI=http://localhost:11311
ROS_PYTHON_VERSION=3
ROS_ROOT=/opt/ros/noetic/share/ros
ROS_PACKAGE_PATH=/opt/ros/noetic/share
Originally posted by MaxGyver on ROS Answers with karma: 3 on 2023-07-04
Post score: 0