0
$\begingroup$

Anywhere I search I can see that gazebo_ros2_control can be installed in the Humble distribution with Ubuntu 22 with just an apt command. My problem is that ros2 seems to not be finding the plugin.

[gazebo-3] [Err] [Model.cc:1160] Exception occured in the Load function of plugin with name[gazebo_ros2_control] and filename[libgazebo_ros2_control.so]. This plugin will not run. 

For example in here it is mentioned:

A Gazebo plugin is added with this lines in the URDF:

 <plugin filename="plugin_name.so" name="some_name" > plugin args... </plugin> 

However you will need to export the plugins path to advertise Gazebo where to find custom plugins. Take a look at this tutorial, you whould be able to follow it until the end, where you will find how to export and launch the plugin.

I am wondering, maybe I need to source /usr/share/gazebo/ or gazebo-11 for that matter. I tried with some repositories that are instantly triable. Same error. I actually thought of using the universal robots repo, which installs in the workspace the different ros2-control, gazebo-ros2-control.

ls ../workspaces/ur_gazebo/src/ gazebo_ros2_control moveit_msgs learm_ros2 ros2_control learm_ros2_description ros2_controllers learm_ros2_moveit_config Universal_Robots_ROS2_Gazebo_Simulation moveit2 ur_description 

But I am getting the same. I got at some point a message to "override" paths.

My main question is: After installing gazebo_ros2_control, does ANYTHING ELSE need to be done? Adding to a CMakesList.txt, or to package.xml, setup.py? I read in here that it might be related to GAZEBO_MODEL_PATH. Something related to rosdep maybe?

Code:

import os from launch_ros.actions import Node from launch import LaunchDescription from launch.substitutions import Command from launch.actions import ExecuteProcess from ament_index_python.packages import get_package_share_directory def generate_launch_description(): #robot_model = 'm1013' xacro_file = get_package_share_directory('learm_ros2') + '/urdf/learm-gazebo.urdf.xacro' # Robot State Publisher robot_state_publisher = Node(package ='robot_state_publisher', executable ='robot_state_publisher', name ='robot_state_publisher', output ='both', parameters =[{'robot_description': Command(['xacro', ' ', xacro_file]) }]) # Spawn the robot in Gazebo spawn_entity_robot = Node(package ='gazebo_ros', executable ='spawn_entity.py', arguments = ['-entity', 'learm_ros2', '-topic', 'robot_description'], output ='screen') # Gazebo world_file_name = 'table_world.world' world = os.path.join(get_package_share_directory('learm_ros2'), 'worlds', world_file_name) gazebo_node = ExecuteProcess(cmd=['gazebo', '--verbose', world,'-s', 'libgazebo_ros_factory.so'], output='screen') # These are not working.... # load_joint_state_broadcaster = ExecuteProcess( # cmd=['ros2', 'control', 'load_controller', '--set-state', 'start','joint_state_broadcaster'], # output='screen') # load_joint_trajectory_controller = ExecuteProcess( # cmd=['ros2', 'control', 'load_controller', '--set-state', 'start', 'joint_trajectory_controller'], # output='screen') return LaunchDescription([robot_state_publisher, spawn_entity_robot, gazebo_node, ]) 

Complete log:

ros2 launch learm_ros2 my_gazebo_controller.launch.py [INFO] [launch]: All log files can be found below /home/mk/.ros/log/2024-04-11-09-15-23-807156-mk-5577 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [robot_state_publisher-1]: process started with pid [5579] [INFO] [spawn_entity.py-2]: process started with pid [5581] [INFO] [gazebo-3]: process started with pid [5583] [robot_state_publisher-1] [INFO] [1712819724.075684381] [robot_state_publisher]: got segment base_link [robot_state_publisher-1] [INFO] [1712819724.075815637] [robot_state_publisher]: got segment finger_left_link [robot_state_publisher-1] [INFO] [1712819724.075825642] [robot_state_publisher]: got segment finger_right_link [robot_state_publisher-1] [INFO] [1712819724.075831179] [robot_state_publisher]: got segment forearm_link [robot_state_publisher-1] [INFO] [1712819724.075835984] [robot_state_publisher]: got segment grip_left_link [robot_state_publisher-1] [INFO] [1712819724.075840953] [robot_state_publisher]: got segment grip_right_link [robot_state_publisher-1] [INFO] [1712819724.075845599] [robot_state_publisher]: got segment hand_link [robot_state_publisher-1] [INFO] [1712819724.075850323] [robot_state_publisher]: got segment humerus_link [robot_state_publisher-1] [INFO] [1712819724.075855091] [robot_state_publisher]: got segment shoulder_link [robot_state_publisher-1] [INFO] [1712819724.075859804] [robot_state_publisher]: got segment tendon_left_link [robot_state_publisher-1] [INFO] [1712819724.075864539] [robot_state_publisher]: got segment tendon_right_link [robot_state_publisher-1] [INFO] [1712819724.075869254] [robot_state_publisher]: got segment world [robot_state_publisher-1] [INFO] [1712819724.075873869] [robot_state_publisher]: got segment wrist_link [gazebo-3] Gazebo multi-robot simulator, version 11.10.2 [gazebo-3] Copyright (C) 2012 Open Source Robotics Foundation. [gazebo-3] Released under the Apache 2 License. [gazebo-3] http://gazebosim.org [gazebo-3] [spawn_entity.py-2] [INFO] [1712819724.364785269] [spawn_entity]: Spawn Entity started [spawn_entity.py-2] [INFO] [1712819724.365130349] [spawn_entity]: Loading entity published on topic robot_description [spawn_entity.py-2] /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead. [spawn_entity.py-2] warnings.warn( [spawn_entity.py-2] [INFO] [1712819724.366856777] [spawn_entity]: Waiting for entity xml on robot_description [gazebo-3] Gazebo multi-robot simulator, version 11.10.2 [gazebo-3] Copyright (C) 2012 Open Source Robotics Foundation. [gazebo-3] Released under the Apache 2 License. [gazebo-3] http://gazebosim.org [gazebo-3] [spawn_entity.py-2] [INFO] [1712819724.472695945] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30 [spawn_entity.py-2] [INFO] [1712819724.473441392] [spawn_entity]: Waiting for service /spawn_entity [gazebo-3] [INFO] [1712819724.887534290] [gazebo_ros_node]: ROS was initialized without arguments. [spawn_entity.py-2] [INFO] [1712819725.229984757] [spawn_entity]: Calling service /spawn_entity [spawn_entity.py-2] [INFO] [1712819725.546704340] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [learm_ros2] [INFO] [spawn_entity.py-2]: process has finished cleanly [pid 5581] [gazebo-3] [Msg] Waiting for master. [gazebo-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345 [gazebo-3] [Msg] Publicized address: 192.168.1.49 [gazebo-3] [Msg] Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. [gazebo-3] [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call [gazebo-3] [INFO] [1712819726.206974140] [gazebo_ros2_control]: Loading gazebo_ros2_control plugin [gazebo-3] [INFO] [1712819726.208899511] [gazebo_ros2_control]: Starting gazebo_ros2_control plugin in namespace: / [gazebo-3] [INFO] [1712819726.209095469] [gazebo_ros2_control]: Starting gazebo_ros2_control plugin in ros 2 node: gazebo_ros2_control [gazebo-3] [INFO] [1712819726.210755756] [gazebo_ros2_control]: connected to service!! robot_state_publisher [gazebo-3] [INFO] [1712819726.211154584] [gazebo_ros2_control]: Received urdf from param server, parsing... [gazebo-3] [INFO] [1712819726.211194783] [gazebo_ros2_control]: Loading parameter files /home/mk/ros2_ws/install/learm_ros2_description/share/learm_ros2_description/config/combined_controllers.yaml [gazebo-3] [INFO] [1712819726.219434473] [gazebo_ros2_control]: Loading joint: shoulder_pan...(#hiding other joints for log) [gazebo-3] [INFO] [1712819726.221340144] [resource_manager]: Initialize hardware 'GazeboSystem' [gazebo-3] [INFO] [1712819726.221351965] [resource_manager]: Successful initialization of hardware 'GazeboSystem' [gazebo-3] [INFO] [1712819726.221431741] [gazebo_ros2_control]: Loading controller_manager [gazebo-3] [Msg] Waiting for master. [gazebo-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345 [gazebo-3] [Msg] Publicized address: 192.168.1.49 [gazebo-3] [Msg] Loading world file [/home/mk/ros2_ws/install/learm_ros2/share/learm_ros2/worlds/table_world.world] [gazebo-3] [Err] [Model.cc:1160] Exception occured in the Load function of plugin with name[gazebo_ros2_control] and filename[libgazebo_ros2_control.so]. This plugin will not run. [gazebo-3] [Err] [Connection.cc:547] Connection[16] Closed during Read [gazebo-3] [Err] [TransportIface.cc:385] Unable to read from master [ERROR] [gazebo-3]: process has died [pid 5583, exit code 255, cmd 'gazebo --verbose /home/mk/ros2_ws/install/learm_ros2/share/learm_ros2/worlds/table_world.world -s libgazebo_ros_factory.so']. [gazebo-3] [gazebo-3] ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT) [robot_state_publisher-1] [INFO] [1712819751.927358582] [rclcpp]: signal_handler(signum=2) [INFO] [robot_state_publisher-1]: process has finished cleanly [pid 5579] 

controller.yaml:

controller_manager: ros__parameters: update_rate: 30.0 use_sim_time: true joint_state_controller: type: joint_state_controller/JointStateController publish_rate: 50.0 joint_state_broadcaster: type: joint_state_broadcaster/JointStateBroadcaster arm_controller: type: joint_trajectory_controller/JointTrajectoryController arm_controller: ros__parameters: publish_rate: 50.0 base_frame_id: base_link command_interfaces: - position state_interfaces: - position - velocity joints: - shoulder_pan - shoulder_lift - elbow - wrist_flex - wrist_roll - grip_left 

And finally my urdf.xacro file that has included <xacro:include filename = "ros2_control.xacro" /> and my ros2_control.xacro: has

<?xml version="1.0" ?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro"> <ros2_control name="GazeboSystem" type="system"> <hardware> <plugin>gazebo_ros2_control/GazeboSystem</plugin> </hardware> <joint name="shoulder_pan"> <command_interface name="position"> <param name="min">-1.57</param> <param name="max">1.57</param> </command_interface> <command_interface name="velocity"> <param name="min">-0.5</param> <param name="max">0.5</param> </command_interface> <command_interface name="effort"> <param name="min">-1000</param> <param name="max">1000</param> </command_interface> <state_interface name="position"/> <state_interface name="velocity"/> <state_interface name="effort"/> 
and all the info relevant to the joints, and at the end:
<plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control"> <parameters>$(find learm_ros2_description)/config/combined_controllers.yaml</parameters> </plugin> 

EDIT:

I used the same launch.py file as in [cart_example_position.launch.py]4.

Running ros2 launch gazebo_ros2_control_demos cart_example_position.launch.py and ros2 run gazebo_ros2_control_demos example_position works perfectly fine. copying all the contents, creating a new.run.launch.py file and editing

gazebo_ros2_control_demos_path = os.path.join( get_package_share_directory('learm_ros2')) xacro_file = os.path.join(gazebo_ros2_control_demos_path, 'urdf', 'learm-gazebo-xacroTurdf.urdf') 

Still gives me errors.

[gazebo_ros2_control]: Loading controller_manager [ERROR] [gzserver-1]: process has died [pid 23581, exit code -11, cmd 'gzserver -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so']. [ros2-5] Could not contact service /controller_manager/load_controller [ERROR] [ros2-5]: process has died [pid 23669, exit code 1, cmd 'ros2 control load_controller --set-state active joint_state_broadcaster']. [INFO] [ros2-6]: process started with pid [23794] [ros2-6] Could not contact service /controller_manager/load_controller [ERROR] [ros2-6]: process has died [pid 23794, exit code 1, cmd 'ros2 control load_controller --set-state active joint_trajectory_controller']. ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT) [robot_state_publisher-3] [INFO] [1712843686.506268158] [rclcpp]: signal_handler(signum=2) [INFO] [robot_state_publisher-3]: process has finished cleanly [pid 23585] [INFO] [gzclient-2]: process has finished cleanly [pid 23583] 

So I am currently lost. Editing my controllers.yaml to the yaml file they use, gives me different errors, but as if it managed to connect! So my errors are probably in the controller.yaml or urdf.

$\endgroup$

2 Answers 2

1
$\begingroup$

If you install gazebo_ros2_control via apt, this should be fine and all dependencies should be installed. Can you follow the steps described https://control.ros.org/humble/doc/ros2_control_demos/example_9/doc/userdoc.html or here?

Note that you have to source source /usr/share/gazebo/setup.sh, but from your console output it seems that gazebo itself is loading fine.

$\endgroup$
4
  • $\begingroup$ Thanks for the quick reply. I can see it's working fine.. when running ros2 launch gazebo_ros2_control_demos cart_example_position.launch.py and example_position. I will check the files and try to adjust mines to that, and update whenever I find something. Thanks again. $\endgroup$ Commented Apr 11, 2024 at 13:27
  • 1
    $\begingroup$ Fine. For statistics purposes, please mark that the question is answered (a green tick beside my answer). $\endgroup$ Commented Apr 11, 2024 at 13:35
  • $\begingroup$ I was using a xacro file, but I converted it to urdf to follow the exact same code as in cart_example_position.launch.py . No gazebo_ros2_control right now, just with ros2_control, when loading controller_manager. I might open a github issue, it might be better to inspect more extensive code as in the urdf.xacro or whatever... $\endgroup$ Commented Apr 11, 2024 at 13:57
  • $\begingroup$ I managed to fix it, but I will keep yours as an answer as it can serve better for a generic reference! Thanks again! $\endgroup$ Commented Apr 11, 2024 at 15:25
0
$\begingroup$

Thanks to @christoph-froehlich I was pointed in the right direction. The main conflict that was happening was the controller.yaml file. I only left:

controller_manager: ros__parameters: update_rate: 30 use_sim_time: true joint_state_broadcaster: type: joint_state_broadcaster/JointStateBroadcaster arm_controller: type: joint_trajectory_controller/JointTrajectoryController arm_controller: ros__parameters: publish_rate: 50.0 base_frame_id: base_link command_interfaces: - position state_interfaces: - position - velocity joints: - shoulder_pan - shoulder_lift - elbow - wrist_flex - wrist_roll - grip_left 

It seems that the structure I was following to load everything was not the best, I will try to stick from now on to how they use it!

Finally and as an addition in case in can help anybody: The robot is spawned and withstands without falling (correctly ros2_control). I created a file just to check if I could move the robot with the now corrected arm_controller and its topic trajectory_publisher, with the appropiate msg in JointTrajectory()

class TrajectoryPublisher(Node): def __init__(self): super().__init__('trajectory_publisher') self.publisher_ = self.create_publisher(JointTrajectory, '/arm_controller/joint_trajectory', 10) timer_period = 2 # seconds self.timer = self.create_timer(timer_period, self.publish_trajectory) def publish_trajectory(self): msg = JointTrajectory() msg.joint_names = ['shoulder_pan', 'shoulder_lift', 'elbow', 'wrist_flex', 'wrist_roll', 'grip_left'] point = JointTrajectoryPoint() point.positions = [0.5, 0.0, -0.5, 0.0, 0.0, 0.0] # Example positions point.time_from_start.sec = 2 # Move to the position in 2 seconds msg.points.append(point) self.publisher_.publish(msg) self.get_logger().info('Publishing trajectory') def main(args=None): rclpy.init(args=args) trajectory_publisher = TrajectoryPublisher() rclpy.spin(trajectory_publisher) trajectory_publisher.destroy_node() rclpy.shutdown() 

And this is the result! Thanks Again to Christoph and the other sources for pointing out in the right direction!

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.