I have been stuck for several weeks unable to run ign_ros2_control in gazebo. I am using ros2 humble. below is the error message I get.
I have been able to run ignition ros2 control demos successfully but this is just not working. I even tried using gz_ros2_control and it still didnt work. I also tried the project on ros2 jazzy with gz_ros2_control and it showed a similar error saying it cant find gz_ros2_control with base class class SystemInterfaces.
below are my files. Any help in solving this issue will be highly appreciated.
gazebo.launch.py
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import (
DeclareLaunchArgument,
SetEnvironmentVariable,
IncludeLaunchDescription,
)
from launch.launch_description_sources import PythonLaunchDescriptionSource
import os
from pathlib import Path
from ament_index_python.packages import get_package_share_directory
from launch_ros.parameter_descriptions import ParameterValue
from launch.substitutions import Command, LaunchConfiguration
def generate_launch_description():
bumperbot_description_dir = get_package_share_directory("bumperbot_description")
ros_distro = os.environ["ROS_DISTRO"]
is_ignition = "True" if ros_distro == "humble" else "False"
model_arg = DeclareLaunchArgument(
name="model",
default_value=os.path.join(
bumperbot_description_dir, "urdf", "bumperbot.urdf.xacro"
),
description="Absolute path to robot URDF file",
)
robot_description = ParameterValue(
Command(
["xacro ", LaunchConfiguration("model"), " ", "is_ignition:=", is_ignition]
),
value_type=str,
)
robot_state_publisher = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
parameters=[{"robot_description": robot_description}],
)
gazebo_resource_path = SetEnvironmentVariable(
name="GZ_SIM_RESOURCE_PATH",
value=[str(Path(bumperbot_description_dir).parent.resolve())],
)
print(
"Setting GZ_SIM_RESOURCE_PATH to:",
str(Path(bumperbot_description_dir).parent.resolve()),
)
gazebo = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
os.path.join(get_package_share_directory("ros_gz_sim"), "launch"),
"/gz_sim.launch.py",
]
),
launch_arguments=[("gz_args", ["-v 4", " -r"])],
)
gz_spawn_entity = Node(
package="ros_gz_sim",
executable="create",
arguments=["-topic", "robot_description", "-name", "bumperbot"],
output="screen",
)
return LaunchDescription(
[
model_arg,
robot_state_publisher,
gazebo_resource_path,
gazebo,
gz_spawn_entity,
]
)
package.xml
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>bumperbot_description</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="basit@todo.todo">basit</maintainer>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>urdf</exec_depend>
<exec_depend>joint_state_publisher_gui</exec_depend>
<exec_depend>rviz2</exec_depend>
<exec_depend>xacro</exec_depend>
<exec_depend>ros2launch</exec_depend>
<exec_depend>ros_gz_sim</exec_depend>
<exec_depend condition="$ROS_DISTRO >= iron">gz_ros2_control</exec_depend>
<exec_depend condition="$ROS_DISTRO == humble">ign_ros2_control</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
bumperbot_gazebo.xacro.
<?xml version="1.0"?>
<robot name="bumperbot"
xmlns:xacro="http://ros.org/wiki/xacro">
<gazebo reference="wheel_right_link">
<mu1>100000000000000.0</mu1>
<mu2>100000000000000.0</mu2>
<kp>1000000000000.0</kp>
<kd>10.0</kd>
<minDepth>0.001</minDepth>
<maxVel>0.1</maxVel>
<fdir>1 0 0</fdir>
</gazebo>
<gazebo reference="wheel_left_link">
<mu1>100000000000000.0</mu1>
<mu2>100000000000000.0</mu2>
<kp>1000000000000.0</kp>
<kd>10.0</kd>
<minDepth>0.001</minDepth>
<maxVel>0.1</maxVel>
<fdir>1 0 0</fdir>
</gazebo>
<gazebo reference="caster_front_link">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>1000000.0</kp>
<kd>100.0</kd>
<minDepth>0.001</minDepth>
<maxVel>0.1</maxVel>
</gazebo>
<gazebo reference="caster_rear_link">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>1000000.0</kp>
<kd>100.0</kd>
<minDepth>0.001</minDepth>
<maxVel>0.1</maxVel>
</gazebo>
<gazebo>
<xacro:if value="$(arg is_ignition)">
<plugin filename="ign_ros2_control-system" name="ign_ros2_control::IgnitionROS2ControlPlugin">
<parameters>
$(find bumperbot_controller)/config/bumperbot_controllers.yaml
</parameters>
</plugin>
</xacro:if>
<xacro:unless value="$(arg is_ignition)">
<plugin filename="gz_ros2_control-system" name="gz_ros2_control::GazeboSimROS2ControlPlugin">
<parameters>$(find bumperbot_controller)/config/bumperbot_controllers.yaml</parameters>
</plugin>
</xacro:unless>
</gazebo>
</robot>
bumperbot_ros2_control.xacro
<?xml version="1.0"?>
<robot name="bumperbot"
xmlns:xacro="http://ros.org/wiki/xacro">
<ros2_control name="RobotSystem" type="system">
<!-- <hardware>
<plugin>gazebo_ros2_control/GazeboSystem</plugin>
</hardware>
-->
<xacro:if value="$(arg is_ignition)">
<hardware>
<plugin>
ign_ros2_control/IgnitionSystem
</plugin>
</hardware>
</xacro:if>
<xacro:unless value="$(arg is_ignition)">
<hardware>
<plugin>
gz_ros2_control/GazeboSimSystem
</plugin>
</hardware>
</xacro:unless>
<joint name="wheel_right_joint">
<command_interface name="velocity">
<param name="min">-1</param>
<param name="max">1</param>
</command_interface>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
<joint name="wheel_left_joint">
<command_interface name="velocity">
<param name="min">-1</param>
<param name="max">1</param>
</command_interface>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
</ros2_control>
</robot>
bumperbot.urdf.xacro
<?xml version="1.0"?>
<robot name="bumperbot" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:arg name="is_ignition" default="true" />
<!-- Include Gazebo Parameters -->
<xacro:include filename="$(find bumperbot_description)/urdf/bumperbot_gazebo.xacro" />
<!-- ROS 2 Control -->
<xacro:include filename="$(find bumperbot_description)/urdf/bumperbot_ros2_control.xacro" />
<link name="base_footprint" />
<link name="base_link">
<inertial>
<origin xyz="0 0 0.04" rpy="0.0 0.25 0.3" />
<mass value="8.2573504e-01" />
<inertia ixx="2.2124416e-02" ixy="-1.2294101e-04" ixz="3.4938785e-04"
iyy="2.1193702e-02" iyz="-5.0120904e-05"
izz="2.0064271e-02" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://bumperbot_description/meshes/base_link.STL" />
</geometry>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://bumperbot_description/meshes/base_link.STL" />
</geometry>
</collision>
</link>
<joint name="base_joint" type="fixed">
<parent link="base_footprint" />
<child link="base_link" />
<origin xyz="0 0 0.033" rpy="0 0 0" />
</joint>
<link name="wheel_right_link">
<inertial>
<origin xyz="0 -0.014 0" rpy="0 0 0" />
<mass value="0.0530086090966721" />
<inertia ixx="1.88176298336665E-05" ixy="-4.8444933029987E-10" ixz="1.88163708851143E-08"
iyy="3.11510738647764E-05" iyz="-6.93560663069607E-11"
izz="1.8801969558182E-05" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="1.57 0 0" />
<geometry>
<mesh filename="package://bumperbot_description/meshes/wheel_right_link.STL" />
</geometry>
</visual>
<collision>
<origin xyz="0 -0.015 0" rpy="1.57 0 0" />
<geometry>
<sphere radius="0.033" />
</geometry>
</collision>
</link>
<joint name="wheel_right_joint" type="continuous">
<origin xyz="0 -0.0701101849418637 0" rpy="0 0 0" />
<parent link="base_link" />
<child link="wheel_right_link" />
<axis xyz="0 1 0" />
</joint>
<link
name="wheel_left_link">
<inertial>
<origin xyz="0 0.014 0" rpy="0 0 0" />
<mass value="0.0530086043217644" />
<inertia ixx="1.8792911368909E-05" ixy="3.31256392204584E-10" ixz="-1.14082001662767E-08"
iyy="3.11510738759073E-05" iyz="-3.60499245082192E-10"
izz="1.88266886146847E-05" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="-1.57 0 0" />
<geometry>
<mesh filename="package://bumperbot_description/meshes/wheel_left_link.STL" />
</geometry>
</visual>
<collision>
<origin xyz="0 0.015 0" rpy="-1.57 0 0" />
<geometry>
<sphere radius="0.033" />
</geometry>
</collision>
</link>
<joint name="wheel_left_joint" type="continuous">
<origin xyz="0 0.0701101849418642 0" rpy="0 0 0" />
<parent link="base_link" />
<child link="wheel_left_link" />
<axis xyz="0 1 0" />
</joint>
<link name="caster_front_link">
<inertial>
<origin xyz="3.89968128948481E-07 2.40073004698083E-07 0.00219173397061506" rpy="0 0 0" />
<mass value="1.44379265037903E-06" />
<inertia ixx="7.23075276010246E-11" ixy="-6.10956883467859E-16" ixz="2.22849693525031E-15"
iyy="3.8713793085917E-11" iyz="2.93909858781952E-15"
izz="1.00967486676306E-10" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://bumperbot_description/meshes/caster_front_link.STL" />
</geometry>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<sphere radius="0.005" />
</geometry>
</collision>
</link>
<joint name="caster_front_joint" type="fixed">
<origin xyz="0.04755 0 -0.0275" rpy="0 0 0" />
<parent link="base_link" />
<child link="caster_front_link" />
<axis xyz="0 0 0" />
</joint>
<link name="caster_rear_link">
<inertial>
<origin xyz="3.8996812895542E-07 2.40073004698083E-07 0.00219173397061509" rpy="0 0 0" />
<mass value="1.44379265037902E-06" />
<inertia ixx="7.23075276010246E-11" ixy="-6.10956872363424E-16" ixz="2.22849693527207E-15"
iyy="3.87137930859167E-11" iyz="2.939098587861E-15"
izz="1.00967486676306E-10" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://bumperbot_description/meshes/caster_rear_link.STL" />
</geometry>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<sphere radius="0.005" />
</geometry>
</collision>
</link>
<joint name="caster_rear_joint" type="fixed">
<origin xyz="-0.04755 0 -0.0275" rpy="0 0 0" />
<parent link="base_link" />
<child link="caster_rear_link" />
<axis xyz="0 0 0" />
</joint>
</robot>```
bumperbot_controller)/config/bumperbot_controllers.yaml
controller_manager:
ros__parameters:
update_rate: 100
use_sim_time: true
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster
simple_velocity_controller:
type: velocity_controllers/JointGroupVelocityController
simple_velocity_controller:
ros__parameters:
joints:
- wheel_left_joint
- wheel_right_joint
CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
project(bumperbot_description)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES “Clang”)
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake REQUIRED)
install(
DIRECTORY meshes urdf launch rviz
DESTINATION share/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()