Skip to content

Gazebo Sim crashes when using gz_ros2_control-system after terminating simulation process #552

@AJedancov

Description

@AJedancov

Describe the bug
Hello! In my project I use diff_drive_controller to control a mobile robot in Gazebo Sim. In accordance with the documentation, I connect the gz_ros2_control-system via URDF. The simulation and plugin run without any problems. But when I terminate simulation (Ctrl+C in terminal) I get an error from Gazebo that the process was died with a following stack trace:

[gazebo-2] [INFO] [1744890780.773079465] [controller_manager.pal_statistics]: Async messages lost 0
[gazebo-2] [INFO] [1744890780.773219714] [controller_manager.pal_statistics]: publish_async_failures_ 0
[gazebo-2] Stack trace (most recent call last):
[gazebo-2] #31   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e8657b49, in rb_vm_exec
[gazebo-2] #30   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e865462b, in 
[gazebo-2] #29   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e865013e, in 
[gazebo-2] #28   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e864d92f, in 
[gazebo-2] #27   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e858e049, in 
[gazebo-2] #26   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e84b71d6, in rb_protect
[gazebo-2] #25   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e865c2d9, in rb_yield
[gazebo-2] #24   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e8657b49, in rb_vm_exec
[gazebo-2] #23   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e865462b, in 
[gazebo-2] #22   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e865013e, in 
[gazebo-2] #21   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e864d92f, in 
[gazebo-2] #20   Object "/usr/lib/x86_64-linux-gnu/ruby/3.2.0/fiddle.so", at 0x7470e68f7b13, in 
[gazebo-2] #19   Object "/lib/x86_64-linux-gnu/libruby-3.2.so.3.2", at 0x7470e861637b, in rb_nogvl
[gazebo-2] #18   Object "/usr/lib/x86_64-linux-gnu/ruby/3.2.0/fiddle.so", at 0x7470e68f743b, in 
[gazebo-2] #17   Object "/lib/x86_64-linux-gnu/libffi.so.8", at 0x7470e682b0bd, in ffi_call
[gazebo-2] #16   Object "/lib/x86_64-linux-gnu/libffi.so.8", at 0x7470e68283ee, in 
[gazebo-2] #15   Object "/lib/x86_64-linux-gnu/libffi.so.8", at 0x7470e682bb15, in 
[gazebo-2] #14   Object "/opt/ros/jazzy/opt/gz_sim_vendor/lib/libgz-sim8-gz.so.8.9.0", at 0x7470e47456d4, in runServer
[gazebo-2] #13   Object "/opt/ros/jazzy/opt/gz_sim_vendor/lib/libgz-sim8.so.8", at 0x7470e1d3993c, in gz::sim::v8::Server::~Server()
[gazebo-2] #12   Object "/opt/ros/jazzy/opt/gz_sim_vendor/lib/libgz-sim8.so.8", at 0x7470e1d492e4, in 
[gazebo-2] #11   Object "/opt/ros/jazzy/opt/gz_sim_vendor/lib/libgz-sim8.so.8", at 0x7470e1d48e17, in gz::sim::v8::SimulationRunner::~SimulationRunner()
[gazebo-2] #10   Object "/opt/ros/jazzy/opt/gz_sim_vendor/lib/libgz-sim8.so.8", at 0x7470e1d5a83c, in 
[gazebo-2] #9    Object "/opt/ros/jazzy/opt/gz_plugin_vendor/lib/libgz-plugin2.so.2", at 0x7470e47d7644, in gz::plugin::Plugin::~Plugin()
[gazebo-2] #8    Object "/opt/ros/jazzy/opt/gz_plugin_vendor/lib/libgz-plugin2.so.2", at 0x7470e47d6b35, in 
[gazebo-2] #7    Object "/opt/ros/jazzy/lib/libgz_ros2_control-system.so", at 0x7470d16446af, in std::_Function_handler<void (void*), gz::plugin::detail::MakeInfo<gz_ros2_control::GazeboSimROS2ControlPlugin, gz::sim::v8::System, gz::sim::v8::ISystemConfigure, gz::sim::v8::ISystemPreUpdate, gz::sim::v8::ISystemPostUpdate>()::{lambda(void*)#1}>::_M_invoke(std::_Any_data const&, void*&&)
[gazebo-2] #6    Object "/opt/ros/jazzy/lib/libgz_ros2_control-system.so", at 0x7470d1632a6f, in gz_ros2_control::GazeboSimROS2ControlPlugin::~GazeboSimROS2ControlPlugin()
[gazebo-2] #5    Object "/opt/ros/jazzy/lib/libgz_ros2_control-system.so", at 0x7470d1638165, in 
[gazebo-2] #4    Object "/opt/ros/jazzy/lib/libcontroller_manager.so", at 0x7470d0cb42d4, in controller_manager::ControllerManager::~ControllerManager()
[gazebo-2] #3    Object "/opt/ros/jazzy/lib/libcontroller_manager.so", at 0x7470d0cb40ea, in controller_manager::ControllerManager::~ControllerManager()
[gazebo-2] #2    Object "/opt/ros/jazzy/lib/libgz_ros2_control-system.so", at 0x7470d163cbdb, in 
[gazebo-2] #1    Object "/opt/ros/jazzy/lib/libhardware_interface.so", at 0x7470d039fe9e, in hardware_interface::ResourceManager::~ResourceManager()
[gazebo-2] #0    Object "/opt/ros/jazzy/lib/libhardware_interface.so", at 0x7470d03c295d, in 
[gazebo-2] Segmentation fault (Address not mapped to object [0x7470c3f582a0])
[ERROR] [gazebo-2]: process has died

If I remove the gz_ros2_control plugin (system), Gazebo terminates its work without any errors.

To Reproduce
Steps to reproduce the behavior:

  1. Run Gazebo Sim with gz_ros2_control-system
  2. Terminate the simulation process via terminal (Ctrl+C)
  3. See error

Expected behavior
Completing the simulation process without any errors

Screenshots

Code from URDF:

<gazebo>
      <plugin filename="gz_ros2_control-system" name="gz_ros2_control::GazeboSimROS2ControlPlugin">
            <parameters> $(find twr_control)/config/twr_diff_drive_controller.yaml </parameters>
      </plugin>
</gazebo>

YAML Configuration file:

controller_manager:
  ros__parameters:
    update_rate: 1000 #Hz
    use_sim_time: true

    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster

diff_drive_controller:
  ros__parameters:
    type: diff_drive_controller/DiffDriveController

    odom_frame_id: odom
    base_frame_id: base_link

    left_wheel_names: ["left_wheel_joint"]
    right_wheel_names: ["right_wheel_joint"]
    wheel_separation: 0.222
    wheel_radius: 0.05

    enable_odom_tf: false

Environment:

  • OS: Kubuntu 24.04
  • Version: ROS Jazzy, Gazebo Sim 8.9.0

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions