0
$\begingroup$

I am working on a project using ROS2 Humble and Gazebo, and I am facing an issue where the ROS2 control is not working as expected. Here are the details of my setup and the problem I am encountering:

ROS2 Distro: Humble Gazebo Version: Gazebo 11 Hardware: Stepper motor controlled via Arduino URDF File: Contains a prismatic joint and uses gazebo_ros2_control plugin Controller Configuration: Includes joint state broadcaster and position controller

URDF File (test_cart_position.xacro.urdf):

<?xml version="1.0" ?>
<robot name="cart">

  <!-- ROS2 Control Plugin -->
  <ros2_control name="GazeboSystem" type="system">
    <hardware>
      <plugin>gazebo_ros2_control/GazeboSystem</plugin>
    </hardware>
    <joint name="slider_to_cart">
      <command_interface name="position">
        <param name="min">-2.5</param>
        <param name="max">2.5</param>
      </command_interface>
      <state_interface name="position">
        <param name="initial_value">1.0</param>
      </state_interface>
      <state_interface name="velocity"/>
      <state_interface name="effort"/>
    </joint>
  </ros2_control>

  <!-- Prismatic Joint Definition -->
  <joint name="slider_to_cart" type="prismatic">
    <axis xyz="1 0 0"/>
    <origin xyz="0.0 0.0 0.0"/>
    <parent link="slideBar"/>
    <child link="cart"/>
    <limit effort="1000.0" lower="-2.5" upper="2.5" velocity="30"/>
    <dynamics damping="0.0" friction="0.0"/>
  </joint>

</robot>

According to the loaded plugin descriptions the class gazebo_ros2_control/GazeboSystem with base class type hardware_interface::SystemInterface does not exist. Declared types are fake_components/GenericSystem mock_components/GenericSystem test_hardware_components/TestSystemCommandModes test_hardware_components/TestTwoJointSystem

Launch File (cart_control.launch.py):

import os
import xacro

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import RegisterEventHandler, TimerAction
from launch.event_handlers import OnProcessStart
from launch_ros.actions import Node

def generate_launch_description():
    # 패키지 이름 정의
    package_name = 'gazebo_ros2_control_demos'

    # URDF 파일 경로
    xacro_file = os.path.join(get_package_share_directory(package_name), 'urdf', 'test_cart_position.xacro.urdf')

    # URDF 파일 파싱 및 로딩
    doc = xacro.process_file(xacro_file)
    robot_description = {'robot_description': doc.toxml()}

    # Robot State Publisher 노드
    node_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[robot_description]
    )

    # 컨트롤러 매니저 노드
    controller_manager = Node(
        package='controller_manager',
        executable='ros2_control_node',
        parameters=[robot_description,
                    os.path.join(get_package_share_directory(package_name), 'config', 'controllers.yaml')],
        output='screen'
    )

    # 컨트롤러 로드
    load_joint_state_broadcaster = Node(
        package='controller_manager',
        executable='spawner',
        arguments=['joint_state_broadcaster', '--controller-manager', '/controller_manager'],
        output='screen'
    )

    load_position_controller = Node(
        package='controller_manager',
        executable='spawner',
        arguments=['position_controller', '--controller-manager', '/controller_manager'],
        output='screen'
    )

    # Arduino 통신 노드 실행
    arduino_comm_node = Node(
        package='ros2_arduino_comm',
        executable='talker',
        name='arduino_comm_node',
        output='screen',
    )

    return LaunchDescription([
        node_robot_state_publisher,
        TimerAction(period=3.0, actions=[controller_manager]),
        RegisterEventHandler(
            event_handler=OnProcessStart(
                target_action=controller_manager,
                on_start=[load_joint_state_broadcaster],
            )
        ),
        RegisterEventHandler(
            event_handler=OnProcessStart(
                target_action=load_joint_state_broadcaster,
                on_start=[load_position_controller],
            )
        ),
        arduino_comm_node,
    ])

What I've Tried: Verified gazebo_ros2_control package is installed. Checked controllers.yaml and URDF files for correct configuration. Verified that the launch file correctly loads the robot description and controllers.

error log:

[INFO] [launch]: All log files can be found below /home/dev/.ros/log/2024-08-06-16-42-19-807446-dev-dev-12468
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [12469]
[robot_state_publisher-1] [INFO] [1722930139.902683320] [robot_state_publisher]: got segment camera_link
[robot_state_publisher-1] [INFO] [1722930139.902758090] [robot_state_publisher]: got segment camera_link_optical
[robot_state_publisher-1] [INFO] [1722930139.902766576] [robot_state_publisher]: got segment cart
[robot_state_publisher-1] [INFO] [1722930139.902771493] [robot_state_publisher]: got segment computer
[robot_state_publisher-1] [INFO] [1722930139.902776127] [robot_state_publisher]: got segment laser_frame
[robot_state_publisher-1] [INFO] [1722930139.902780482] [robot_state_publisher]: got segment lidar
[robot_state_publisher-1] [INFO] [1722930139.902784831] [robot_state_publisher]: got segment slideBar
[robot_state_publisher-1] [INFO] [1722930139.902788996] [robot_state_publisher]: got segment support1
[robot_state_publisher-1] [INFO] [1722930139.902793048] [robot_state_publisher]: got segment support2
[robot_state_publisher-1] [INFO] [1722930139.902797067] [robot_state_publisher]: got segment support3
[robot_state_publisher-1] [INFO] [1722930139.902800981] [robot_state_publisher]: got segment support4
[robot_state_publisher-1] [INFO] [1722930139.902804905] [robot_state_publisher]: got segment water_tank
[robot_state_publisher-1] [INFO] [1722930139.902809051] [robot_state_publisher]: got segment world
[INFO] [ros2_control_node-3]: process started with pid [12491]
[INFO] [spawner-4]: process started with pid [12493]
[INFO] [spawner-5]: process started with pid [12495]
[ros2_control_node-3] [WARN] [1722930143.255055918] [controller_manager]: [Deprecated] Passing the robot description parameter directly to the control_manager node is deprecated. Use '~/robot_description' topic from 'robot_state_publisher' instead.
[ros2_control_node-3] [INFO] [1722930143.255281655] [resource_manager]: Loading hardware 'GazeboSystem' 
[ros2_control_node-3] terminate called after throwing an instance of 'pluginlib::LibraryLoadException'
[ros2_control_node-3]   what():  According to the loaded plugin descriptions the class gazebo_ros2_control/GazeboSystem with base class type hardware_interface::SystemInterface does not exist. Declared types are  fake_components/GenericSystem mock_components/GenericSystem test_hardware_components/TestSystemCommandModes test_hardware_components/TestTwoJointSystem
[ros2_control_node-3] Stack trace (most recent call last):
[ros2_control_node-3] #16   Object "", at 0xffffffffffffffff, in 
[ros2_control_node-3] #15   Object "/opt/ros/humble/lib/controller_manager/ros2_control_node", at 0x5d134f7e1d84, in 
[ros2_control_node-3] #14   Source "../csu/libc-start.c", line 392, in __libc_start_main_impl [0x7f64be229e3f]
[ros2_control_node-3] #13   Source "../sysdeps/nptl/libc_start_call_main.h", line 58, in __libc_start_call_main [0x7f64be229d8f]
[ros2_control_node-3] #12   Object "/opt/ros/humble/lib/controller_manager/ros2_control_node", at 0x5d134f7e189e, in 
[ros2_control_node-3] #11   Object "/opt/ros/humble/lib/libcontroller_manager.so", at 0x7f64bebcce79, in controller_manager::ControllerManager::ControllerManager(std::shared_ptr<rclcpp::Executor>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rclcpp::NodeOptions const&)
[ros2_control_node-3] #10   Object "/opt/ros/humble/lib/libcontroller_manager.so", at 0x7f64bebc86bf, in controller_manager::ControllerManager::init_resource_manager(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[ros2_control_node-3] #9    Object "/opt/ros/humble/lib/libhardware_interface.so", at 0x7f64be5c0d9d, in hardware_interface::ResourceManager::load_urdf(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool)
[ros2_control_node-3] #8    Object "/opt/ros/humble/lib/libhardware_interface.so", at 0x7f64be5bf1ce, in 
[ros2_control_node-3] #7    Object "/opt/ros/humble/lib/libhardware_interface.so", at 0x7f64be5a032a, in 
[ros2_control_node-3] #6    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30", at 0x7f64be6ae4d7, in __cxa_throw
[ros2_control_node-3] #5    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30", at 0x7f64be6ae276, in std::terminate()
[ros2_control_node-3] #4    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30", at 0x7f64be6ae20b, in 
[ros2_control_node-3] #3    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30", at 0x7f64be6a2b9d, in 
[ros2_control_node-3] #2    Source "./stdlib/abort.c", line 79, in abort [0x7f64be2287f2]
[ros2_control_node-3] #1    Source "../sysdeps/posix/raise.c", line 26, in raise [0x7f64be242475]
[ros2_control_node-3] #0  | Source "./nptl/pthread_kill.c", line 89, in __pthread_kill_internal
[ros2_control_node-3]     | Source "./nptl/pthread_kill.c", line 78, in __pthread_kill_implementation
[ros2_control_node-3]       Source "./nptl/pthread_kill.c", line 44, in __pthread_kill [0x7f64be2969fc]
[ros2_control_node-3] Aborted (Signal sent by tkill() 12491 1000)
[ERROR] [ros2_control_node-3]: process has died [pid 12491, exit code -6, cmd '/opt/ros/humble/lib/controller_manager/ros2_control_node --ros-args --params-file /tmp/launch_params_p_q49ynx --params-file /home/dev/ros2_ws/install/gazebo_ros2_control_demos/share/gazebo_ros2_control_demos/config/controllers.yaml'].
[spawner-4] [INFO] [1722930145.313640754] [spawner_joint_state_broadcaster]: Waiting for '/controller_manager' services to be available
[spawner-5] [INFO] [1722930145.324437375] [spawner_position_controller]: Waiting for '/controller_manager' node to exist
[spawner-4] [INFO] [1722930147.341653039] [spawner_joint_state_broadcaster]: Waiting for '/controller_manager' services to be available
[spawner-5] [INFO] [1722930147.352387749] [spawner_position_controller]: Waiting for '/controller_manager' node to exist
[spawner-4] [INFO] [1722930149.370987700] [spawner_joint_state_broadcaster]: Waiting for '/controller_manager' services to be available
[spawner-5] [INFO] [1722930149.390733566] [spawner_position_controller]: Waiting for '/controller_manager' node to exist
[spawner-4] [INFO] [1722930151.400977121] [spawner_joint_state_broadcaster]: Waiting for '/controller_manager' services to be available
[spawner-5] [INFO] [1722930151.426732626] [spawner_position_controller]: Waiting for '/controller_manager' node to exist
[spawner-4] [ERROR] [1722930153.428113874] [spawner_joint_state_broadcaster]: Controller manager not available
[spawner-5] [ERROR] [1722930153.453752718] [spawner_position_controller]: Controller manager not available
[ERROR] [spawner-5]: process has died [pid 12495, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner position_controller --controller-manager /controller_manager --ros-args'].
[ERROR] [spawner-4]: process has died [pid 12493, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner joint_state_broadcaster --controller-manager /controller_manager --ros-args'].

```
$\endgroup$

1 Answer 1

0
$\begingroup$
  • Have you sourced your workspace? (source /opt/ros/humble/setup.bash)
  • what does ros2 pkg xml -t version gazebo_ros2_control report?
  • have you run rosdep, e.g., rosdep install -riy --from-paths src?
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.