Clear Filters
Clear Filters

How to prevent Simulink Pacer from resetting ROS time?

1 view (last 30 days)
There is however a major inconvenience as the Simulink pacer block only allows 2 options on simulation start:
  1. Reset Gazebo Simulation time
  2. Reset Gazebo Simulation time and state
I would like it to not reset anything at all, as I am working with an elaborate pipeline of ROS nodes which requires time to be monotonic and consistent with Gazebo, used to simulate sensor data.
I have actually already made a fix, by modifying the C++ source code of the Simulink Gazebo Plugin. I simply commented out where the world time is reset and it worked. It would be nice if you were to add it as a a third built in option.
Please let me know if this is not possible and maybe if I shouldn't be doing this at all or there is another way to do it without changing the plugin code.
AMZ Racing - Driverless Control
  1 Comment
Jakobus Louw
Jakobus Louw on 17 Jun 2021
Thank you so much for this. It helped me a lot. I needed to simulate PX4 with Gazebo and use a Simulink ROS node as a controller.
For those coming accross this same problem, edit the file in your GazeboPlugin folder: GazeboPlugin/src/gazeboserver/GazeboWorldImpl.cpp
Comment out the line in the resetTime() function like this:
void GazeboWorldImpl::resetTime() {
// return m_world->ResetTime();
Then go to the GazeboPlugin/build folder and run
to rebuild the plugin.

Sign in to comment.

Answers (1)

Amrtanshu Raj
Amrtanshu Raj on 20 Apr 2021
So the objective of the Gazebo Cosim feature is to design your logic in Simulink and the use Gazebo as a physics engine to simulate your robot. The idea is not to interface Simulink with ROS network but directly to Gazebo.
If you want to use Simulink as a node in a ROS network, you can check out the ROS Toolbox which aims to achieve the functionality you need.
Hope this helps.


Find more on Network Connection and Exploration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!