How to prevent Simulink Pacer from resetting ROS time?

1 次查看(过去 30 天)
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.
Thanks,
Bye
Sebastian
AMZ Racing - Driverless Control
  1 个评论
Jakobus Louw
Jakobus Louw 2021-6-17
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
make
to rebuild the plugin.

请先登录,再进行评论。

回答(1 个)

Amrtanshu Raj
Amrtanshu Raj 2021-4-20
Hi,
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.

Community Treasure Hunt

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

Start Hunting!

Translated by