Ros2_control issues

Hi everybody,

i’m working on a 4 wheel autonomous robot simulation with ROS and Gazebo.
Currently it operates with the diff-drive plugin but i’m planning on switching to an ackerman steering approach. Therefore im trying to setup ros2_control, but i got quiet some problems with it:

My setup:
Ubuntu 20.04
Ros Foxy
Gazebo 11.11.0
installed ros2_control package via sudo apt install ros-foxy-gazebo-ros2-control
installed gazebo_ros2_control package via sudo apt install ros-foxy-gazebo-ros2-control

Inside my URDF File i configured ros2_control as follows:

  <!-- Position Config -->
  <ros2_control name="GazeboSystem" type="system">
    <hardware>
      <plugin>gazebo_ros2_control/GazeboSystem</plugin>
      <!-- <plugin>test_system</plugin> -->
    </hardware> 
    <joint name="front_right_steer_joint">
      <command_interface name="position">
        <param name="min">-0.45</param>
        <param name="max">0.45</param>
      </command_interface>
      <state_interface name="position"/>
      <state_interface name="velocity"/>
      <state_interface name="effort"/>
    </joint>
    <joint name="front_left_steer_joint">
      <command_interface name="position">
        <param name="min">-0.45</param>
        <param name="max">0.45</param>
      </command_interface>
      <state_interface name="position"/>
      <state_interface name="velocity"/>
      <state_interface name="effort"/>
    </joint>
  </ros2_control>

I also added the gazebo_ros2_control plugin to the URDF file:

  <gazebo>
    <plugin filename="libgazebo-ros2_control.so" name="gazebo_ros2_control">
      <parameters>$(find tunnel_bot)/config/steering_controller_position.yaml</parameters>
    </plugin>
  </gazebo>

And thats the used config file steering_controller_position.yaml:

controller_manager:
  ros__parameters:
    update_rate: 1  # Hz

    joint_trajectory_controller:
      type: joint_trajectory_controller/JointTrajectoryController

    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster

joint_trajectory_controller:
  ros__parameters:
    joints:
      - front_right_steer_joint
      - front_left_steer_joint
    interface_name: position
    command_interfaces:
      - position
    state_interfaces:
      - position
      - velocity

Now lets get into the issue:
When using the ros2_control hardware plugin gazebo_ros2_control/GazeboSystem im getting the following error:

[ros2_control_node-1] terminate called after throwing an instance of 'pluginlib::LibraryLoadException'
[ros2_control_node-1]   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 test_hardware_components/TestSystemCommandModes test_hardware_components/TestTwoJointSystem test_system

what finally leads to:

[ERROR] [ros2_control_node-1]: process has died [pid 135528, exit code -6, cmd '/opt/ros/foxy/lib/controller_manager/ros2_control_node --ros-args --params-file /tmp/launch_params_3n96b75a --params-file /home/ima-untow/dev_ws/install/tunnel_bot/share/tunnel_bot/config/steering_controller_position.yaml'].

but when i search for the gazebo_ros2_control package i find inside /opt/ros/foxy/share/gazebo_ros2_control/gazebo_hardware_plugins.xml this:

<library path="gazebo_hardware_plugins">
  <class
    name="gazebo_ros2_control/GazeboSystem"
    type="gazebo_ros2_control::GazeboSystem"
    base_class_type="gazebo_ros2_control::GazeboSystemInterface">
    <description>
      GazeboPositionJoint
    </description>
  </class>
</library>

which in my eyes indicates that the plugin indeed is available.

If i use the test_system plugin istead:

  <ros2_control name="GazeboSystem" type="system">
    <hardware>
      <!-- <plugin>gazebo_ros2_control/GazeboSystem</plugin> -->
      <plugin>test_system</plugin>
    </hardware> 
    ...(same as above)...
  </ros2_control>

i get the following error:

[ros2_control_node-1] terminate called after throwing an instance of 'std::runtime_error'
[ros2_control_node-1]   what():  Wrong state or command interface configuration.
[ros2_control_node-1] missing state interfaces:
[ros2_control_node-1] ' front_right_steer_joint/effort '	' front_left_steer_joint/effort '	
[ros2_control_node-1] missing command interfaces:
[ros2_control_node-1] ' front_right_steer_joint/position '	' front_left_steer_joint/position '

So at this point i’m totally confused, because in my opinion the interfaces aren’t missing. Dont get me wrong, im trying to use the gazebo_ros2_control/GazeboSystem but thought it may be relevant that the output changes when using the test_system.

Can anyone help me out? Any hint is appreciated.
Thanks alot in advance.

P.S. If any further documentation or log-files are needed just say so - i’m quiet new to this.

Hey! Great question. This is also the first example of the inevitable issue where this is really a question that would be better suited to ROS answers so I’d want to encourage people to post questions there first, and then if they find an answer elsewhere (e.g. here) to go back and answer their own post.

That being said, I’d still like to help and I think I might have a solution (this is tied into the stuff for the video I’m currently working on!).

I think the problem is simply that when you added the libgazebo_ros2_control.so plugin, you have a hyphen after gazebo where there should be an underscore.
As far as I can tell, the actual interface plugin (which you managed to find) is not “visible” by default, but loading the other plugin makes it available, but that plugin is not being loaded correctly due to the wrong name.

So try fixing that and let us know how it goes, if it’s still not working we can keep looking :slight_smile:

Edit: Also, you probably know this but you will want to use the DiffDriveController rather than the JointTrajectoryController that you’ve mentioned.

1 Like

Hi Josh,
I’m speechless right now… thats such a dumb mistake… I tried fixing it for days.
You helped a lot, thank you so much!

I’m looking forward to your ros2_control video. Keep up the good work!
Greetings from Germany :slight_smile:

1 Like

Awesome! Good luck with the rest of the robot! (and feel free to post in the projects category if you’d like to show it off to others :slight_smile: )

1 Like

Hi Josh thanks a lot for the videos, They helped me a lot to understand ROS2 and how to build a differential drive bot. I am working on a 4 WD and have been following your tutorials until " [Using ros2_control to drive our robot (off the edge of the bench...)](https://www.youtube.com/watch?v=4VVrTCnxvSw&t=601s)" video. I am facing some trouble after changing to ros2_control, The issue is that my robot is not moving either left or right in gazebo but it seems to move in Rviz as expected. I have searched all the online resources but did not find anything that helps.
here is the link to my repo GitHub - BooraKaushik/autobot
Video of what is happening, IMG_5920.mov - Google Drive
as you can see it is turning fine in rviz but not in gazebo.

I would really appreciate any help.
Thanks,
Kaushik Boora

Hello @JoshNewans and @martoliod. I am currently trying to make my own 4 wheel autonomous robot following the Articulated Robotics series.

My setup is using Ubuntu-MATE 22.04 and ROS Humble. Is there a version of the ROS_Arduino_Bridge for 4 motors? Or should I be looking to use something else?

I have a Raspberry Pi 4 connected to an Arduino Mega that controls my 4 motors. If anyone has any advice please let me know.