1
$\begingroup$

Ros Humble/Ignition Fortress/Ubuntu 22.04

Hey Ya'll, I'm attempting to load a UR10e into Gazebo Fortress so I can control it with Moveit, and I'm running into an issue. To start, I modified the generated ros2_control.xacro file so that it included the needed plugins for the controller manager:

    <xacro:macro name="robot_gazebo_control" params="name initial_positions_file">
        <xacro:property name="initial_positions" value="${load_yaml(initial_positions_file)['initial_positions']}"/>

        <ros2_control name="${name}" type="system">
            <hardware>
                <plugin>ign_ros2_control/IgnitionSystem</plugin>
            </hardware>
            
            <!-- Manipulator Joints -->
            <joint name="shoulder_pan_joint">
            <command_interface name="position">
                <param name="min">-3.14</param>
                <param name="max">3.14</param>
            </command_interface>
            <state_interface name="position">
                <param name="initial_value">${initial_positions['shoulder_pan_joint']}</param>
        </state_interface>
        <state_interface name="velocity"/>
        <state_interface name="effort"/>
        </joint>
        <joint name="shoulder_lift_joint">
        <command_interface name="position">
            <param name="min">-1.57</param>
            <param name="max">1.57</param>
        </command_interface>
        <state_interface name="position">
            <param name="initial_value">${initial_positions['shoulder_lift_joint']}</param>
            </state_interface>
            <state_interface name="velocity"/>
            <state_interface name="effort"/>
            </joint>
            <joint name="elbow_joint">
            <command_interface name="position">
                <param name="min">-3.14</param>
                <param name="max">3.14</param>
            </command_interface>
            <state_interface name="position">
                <param name="initial_value">${initial_positions['elbow_joint']}</param>
        </state_interface>
        <state_interface name="velocity"/>
        <state_interface name="effort"/>
        </joint>
        <joint name="wrist_1_joint">
        <command_interface name="position">
            <param name="min">-3.14</param>
            <param name="max">3.14</param>
        </command_interface>
        <state_interface name="position">
            <param name="initial_value">${initial_positions['wrist_1_joint']}</param>
            </state_interface>
            <state_interface name="velocity"/>
            <state_interface name="effort"/>
            </joint>
            <joint name="wrist_2_joint">
            <command_interface name="position">
                <param name="min">-3.14</param>
                <param name="max">3.14</param>
            </command_interface>
            <state_interface name="position">
                <param name="initial_value">${initial_positions['wrist_2_joint']}</param>
        </state_interface>
        <state_interface name="velocity"/>
        <state_interface name="effort"/>
        </joint>
        <joint name="wrist_3_joint">
        <command_interface name="position">
            <param name="min">-3.14</param>
            <param name="max">3.14</param>
        </command_interface>
        <state_interface name="position">
            <param name="initial_value">${initial_positions['wrist_3_joint']}</param>
            </state_interface>
            <state_interface name="velocity"/>
            <state_interface name="effort"/>
            </joint>
            
            <!-- Gripper Joint -->
            <joint name="robotiq_85_left_knuckle_joint">
            <command_interface name="position">
                <param name="min">0.0</param>
                <param name="max">0.8</param>
            </command_interface>
            <state_interface name="position">
                <param name="initial_value">${initial_positions['robotiq_85_left_knuckle_joint']}</param>
        </state_interface>
        <state_interface name="velocity"/>
        <state_interface name="effort"/>
        </joint>
    </ros2_control>
    <gazebo>
      <!-- Ignition Gazebo ROS2 control plugin -->
    <plugin filename="ign_ros2_control-system" name="ign_ros2_control::IgnitionROS2ControlPlugin">
          <parameters>$(find robot_moveit_config)/config/ros2_controllers.yaml</parameters>
          </plugin>
        </gazebo>
    </xacro:macro>

I copied the gazebo and hardware plugins from the ign_ros2_control_demo example here

I then copied and modified the launch file from the same example:

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.actions import RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration

from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory


import os
import xacro

def generate_launch_description():
    # Launch Arguments
    use_sim_time = LaunchConfiguration('use_sim_time', default=True)

    spud_master_moveit_config_path = os.path.join(
        get_package_share_directory('robot_moveit_config'))

    xacro_file = os.path.join(robot_moveit_config_path,
                              'config',
                              'robot.urdf.xacro')

    doc = xacro.parse(open(xacro_file))
    xacro.process_doc(doc)
    params = {'robot_description': doc.toxml()}

    node_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[params]
    )

    ignition_spawn_entity = Node(
        package='ros_gz_sim',
        executable='create',
        output='screen',
        arguments=['-string', doc.toxml(),
                   '-name', 'robot',
                   '-allow_renaming', 'true'],
    )

    load_joint_state_broadcaster = ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
             'joint_state_broadcaster'],
        output='screen'
    )

    load_joint_trajectory_controller = ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
             'manipulator_controller'],
        output='screen'
    )

    load_gripper_controller = ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
             'gripper_controller'],
        output='screen'
    )

    return LaunchDescription([
        # Launch gazebo environment
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                [os.path.join(get_package_share_directory('ros_ign_gazebo'),
                              'launch', 'ign_gazebo.launch.py')]),
            launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
        RegisterEventHandler(
            event_handler=OnProcessExit(
                target_action=ignition_spawn_entity,
                on_exit=[load_joint_state_broadcaster],
            )
        ),
        RegisterEventHandler(
            event_handler=OnProcessExit(
                target_action=load_joint_state_broadcaster,
                on_exit=[load_joint_trajectory_controller],
            )
        ),
        RegisterEventHandler(
            event_handler=OnProcessExit(
                target_action=load_joint_trajectory_controller,
                on_exit=[load_gripper_controller],
            )
        ),
        node_robot_state_publisher,
        ignition_spawn_entity,
        # Launch Arguments
        DeclareLaunchArgument(
            'use_sim_time',
            default_value=use_sim_time,
            description='If true, use simulated clock'),
    ])

When launching, this error appears:

[ruby $(which ign) gazebo-1] [ERROR] [1718206910.755951737] [gz_ros2_control]: The plugin failed to load for some reason. Error: According to the loaded plugin descriptions the class mock_components/GenericSystem with base class type ign_ros2_control::IgnitionSystemInterface does not exist. Declared types are  ign_ros2_control/IgnitionSystem

which subsequently leads to this error:

[ruby $(which ign) gazebo-1] [INFO] [1718206913.472056748] [controller_manager]: Loading controller 'gripper_controller'
[ruby $(which ign) gazebo-1] [WARN] [1718206913.478586584] [gripper_controller]: [Deprecated]: "allow_nonzero_velocity_at_trajectory_end" is set to true. The default behavior will change to false.
[ruby $(which ign) gazebo-1] [INFO] [1718206913.483060042] [controller_manager]: Configuring controller 'gripper_controller'
[ruby $(which ign) gazebo-1] [WARN] [1718206913.483231156] [gripper_controller]: 'joints' parameter is empty.
[ruby $(which ign) gazebo-1] [INFO] [1718206913.483281593] [gripper_controller]: No specific joint names are used for command interfaces. Using 'joints' parameter.
[ruby $(which ign) gazebo-1] [ERROR] [1718206913.483310744] [gripper_controller]: 'command_interfaces' parameter is empty.
[ruby $(which ign) gazebo-1] [ERROR] [1718206913.483356589] [controller_manager]: After configuring, controller 'gripper_controller' is in state 'unconfigured' , expected inactive.
[ros2-6] Error configuring controller

and no loaded controllers. Is this the correct way to load controllers, or am I missing a configuration step that's causing this behavior? Finally, are there any tutorials that walk through the process of setting up controllers for ignition gazebo step-by-step that I can use to guide me in the future?

$\endgroup$

1 Answer 1

0
$\begingroup$

Are you sure that you don't have another plugin tag in your xacro file? Search for something like mock_components/GenericSystem. You can also use xacro <path-to-your-file> > robot.urdf to generate the full URDF for analysis.

The subsequent errors are not related, you just have misconfigured your controller. Set the command_interfaces as the error message suggests. You haven't posted your ros2_controllers.yaml, but it seems to be a joint_trajectory_controller.

$\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.