simulation with bag play data get different results
hi, I got a ros2 node
, and the node subscribes topics (say /input
) and publishes topics (say /output
).
I also got a ros2 bag logged_input_in_run_mode
contains the topics /input
in real-time-run env, which i wish to make a simulation with bag play
it as well as run with the node
, to collect the /output
in sim-mode(say the collected bag is logged_output_in_sim_mode
), for offline analysis.
but i found the result (say some calculated velocity states) is different between logged_output_in_sim_mode
and logged_output_in_run_mode
, and even different between logged_output_in_sim_mode_1st_run
and logged_output_in_sim_mode_2nd_run
.
i.e. simulation with bag play data get different results...
i think it's something related to the time or clock issue when someone implements some part of the node
, e.g. the node
use some inner-clock-source instead of outer-clock-source (maybe for integral operation), and i cannot locate the code of this part, which is beyond my access.
so i tried clock
and use_sim_time
in the following shell
script to run the simulation and collect bag, but no improve:
ros2 run package node &
# the `node` is started in the same way and machine both in run-mode and sim-mode
ros2 param set /node use_sim_time True &
ros2 bag play --clock ./logged_input_in_run_mode/ &
ros2 bag record /output -o ./logged_output_in_sim_mode &
i understand the sequence of these cmd
and time-delay between them may influence the results, but in my case it's insignificant and negligible.
my question is:
- is my usage and understanding about
--clock
anduse_sim_time
right? for this kind of problem? - is there any other possible reason for this kind of problem? sim with bag data get different results?
- is there any other method to make the simulated results consistent when play the same bag data and run the same version node?
thanks for any advice or discussion.