I am running ROS2 Humble and am unable to launch my robot arm when using the yaml file in my robot description files. When I launch my gazebo.launch.py file, first I get an error telling me: "process has died [pid ####, exit code 255, cmd 'gzserver-slibgazeo_ros_inti.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so"].
Then, the launch appears to get hung-up on: [spawn_entity]: Calling service /spawn_entity.
The files are located like this:
rad_ws
|
-agbot_controller
|
-agbot_arm_controllers.yaml
|
-agbot_description
|
-launch
|
-agbot_arm_gazebo.launch.py
|
-urdf
|
-agbot_arm_gazebo.xacro
-agbot_arm_ros2_control.xacro
-agbot_arm.urdf.xacro
-common_properties.xacro
This is the printout from the command prompt:
$ ros2 launch agbot_description agbot_arm_gazebo.launch.py
[INFO] [launch]: All log files can be found below /home/<name>/.ros/log/2024-08-05-15-12-33-847895-<name>-humble-46747
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [gzserver-1]: process started with pid [46774]
[INFO] [gzclient-2]: process started with pid [46776]
[INFO] [robot_state_publisher-3]: process started with pid [46778]
[INFO] [joint_state_publisher-4]: process started with pid [46780]
[INFO] [spawn_entity.py-5]: process started with pid [46782]
[robot_state_publisher-3] [INFO] [1722888757.807251488] [robot_state_publisher]: got segment base_link
[robot_state_publisher-3] [INFO] [1722888757.809209275] [robot_state_publisher]: got segment base_plate
[robot_state_publisher-3] [INFO] [1722888757.809238379] [robot_state_publisher]: got segment claw_support
[robot_state_publisher-3] [INFO] [1722888757.809256654] [robot_state_publisher]: got segment forward_drive_arm
[robot_state_publisher-3] [INFO] [1722888757.809272541] [robot_state_publisher]: got segment gripper_left
[robot_state_publisher-3] [INFO] [1722888757.809287732] [robot_state_publisher]: got segment gripper_right
[robot_state_publisher-3] [INFO] [1722888757.809302495] [robot_state_publisher]: got segment horizontal_arm
[robot_state_publisher-3] [INFO] [1722888757.809317909] [robot_state_publisher]: got segment rgb_camera
[robot_state_publisher-3] [INFO] [1722888757.809333502] [robot_state_publisher]: got segment rgb_camera_optical
[robot_state_publisher-3] [INFO] [1722888757.809347551] [robot_state_publisher]: got segment world
[ERROR] [gzserver-1]: process has died [pid 46774, exit code 255, cmd 'gzserver -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so'].
[joint_state_publisher-4] [INFO] [1722888758.440425625] [joint_state_publisher]: Waiting for robot_description to be published on the robot_description topic...
[spawn_entity.py-5] [INFO] [1722888758.529314499] [spawn_entity]: Spawn Entity started
[spawn_entity.py-5] [INFO] [1722888758.529869639] [spawn_entity]: Loading entity published on topic robot_description
[spawn_entity.py-5] /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-5] warnings.warn(
[spawn_entity.py-5] [INFO] [1722888758.532804003] [spawn_entity]: Waiting for entity xml on robot_description
[spawn_entity.py-5] [INFO] [1722888758.545007329] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
[spawn_entity.py-5] [INFO] [1722888758.546015708] [spawn_entity]: Waiting for service /spawn_entity
[spawn_entity.py-5] [INFO] [1722888758.555230062] [spawn_entity]: Calling service /spawn_entity
The process does not go beyond this point. Below are the relevant files....
This is the urdf.xacro file...
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="agbot_arm">
<xacro:property name = "forward_drive_arm_length" value = "1.00" />
<xacro:property name = "forward_drive_arm_width" value = "0.26" />
<xacro:property name = "forward_drive_arm_height" value = "0.02" />
<xacro:property name = "horizontal_arm_length" value = "0.750" />
<xacro:property name = "horizontal_arm_width" value = "0.26" />
<xacro:property name = "horizontal_arm_height" value = "0.02" />
<!-- Include Gazebo Parameters -->
<xacro:include filename="$(find agbot_description)/urdf/agbot_arm_gazebo.xacro" />
<!-- Include ros2_control Plugins -->
<xacro:include filename="$(find agbot_description)/urdf/agbot_arm_ros2_control.xacro" />
<xacro:include filename="$(find agbot_description)/urdf/common_properties.xacro" />
<!-- Useful XACRO Variables (Properties) -->
<xacro:property name="PI" value="3.14159265359" />
<xacro:property name="effort" value="30.0" />
<xacro:property name="velocity" value="10.0" />
<xacro:property name="scale" value="0.0075 0.0075 0.0075"/>
<!-- Useful Macros -->
<xacro:macro name="default_inertia" params="mass">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="${mass}" />
<inertia ixx="1.0" ixy="0.0" ixz="0.0"
iyy="1.0" iyz="0.0"
izz="1.0" />
</inertial>
</xacro:macro>
<xacro:macro name="default_transmission" params="name">
<transmission name="${name}_transmission">
<plugin>transmission_interface/SimpleTransmission</plugin>
<actuator name="{name}_motor" role="actuator1"/>
<joint name="{name}_joint" role="joint1">
<mechanical_reduction>1.0</mechanical_reduction>
</joint>
</transmission>
</xacro:macro>
<!-- Link Descriptions -->
<link name="world"/>
<link name="base_link">
<xacro:default_inertia mass="1.0"/>
<visual>
<origin xyz="-0.35 -0.37 0" rpy="0 0 0"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/basement.STL" scale="${scale}"/>
</geometry>
<material name="blue"/>
</visual>
<collision>
<origin xyz="-0.35 -0.37 0" rpy="0 0 0"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/basement.STL" scale="${scale}"/>
</geometry>
</collision>
</link>
<link name="base_plate">
<xacro:default_inertia mass="0.1"/>
<visual>
<origin xyz="-0.261 -0.295 -0.5" rpy="0 0 0"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/base_plate.STL" scale="${scale}"/>
</geometry>
<material name="red"/>
</visual>
<collision>
<origin xyz="-0.261 -0.295 -0.5" rpy="0 0 0"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/base_plate.STL" scale="${scale}"/>
</geometry>
</collision>
</link>
<link name="forward_drive_arm">
<xacro:default_inertia mass="0.1"/>
<visual>
<origin xyz="0.01 -0.006 0.55" rpy="0 ${PI / 2} ${PI / 2}"/>
<geometry>
<box size="${forward_drive_arm_length} ${forward_drive_arm_width} ${forward_drive_arm_height}" />
</geometry>
<material name="yellow"/>
</visual>
<collision>
<origin xyz="0.01 0.006 0.55" rpy="0 -${PI / 2} ${PI / 2}"/>
<geometry>
<box size="${forward_drive_arm_length} ${forward_drive_arm_width} ${forward_drive_arm_height}" />
</geometry>
</collision>
</link>
<link name="horizontal_arm">
<xacro:default_inertia mass="0.1"/>
<visual>
<origin xyz="0.1 0 0.37" rpy="0 ${PI / 2} ${PI / 2}"/>
<geometry>
<box size="${horizontal_arm_length} ${horizontal_arm_width} ${horizontal_arm_height}" />
</geometry>
<material name="green"/>
</visual>
<collision>
<origin xyz="0.1 0 0.37" rpy="0 ${PI / 2} ${PI / 2}"/>
<geometry>
<box size="${horizontal_arm_length} ${horizontal_arm_width} ${horizontal_arm_height}" />
</geometry>
</collision>
</link>
<link name="claw_support">
<xacro:default_inertia mass="0.05"/>
<visual>
<origin xyz="-.1 0 0" rpy="0 -${PI/2} -${PI / 2}"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/claw_support.STL" scale="${scale}"/>
</geometry>
<material name="pink"/>
</visual>
<collision>
<origin xyz="-.1 0 0" rpy="0 -${PI/2} -${PI / 2}"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/claw_support.STL" scale="${scale}"/>
</geometry>
</collision>
</link>
<link name="gripper_right">
<xacro:default_inertia mass="0.01"/>
<visual>
<origin xyz="0.078 0.005 0.36" rpy="0 ${PI / 2} ${PI / 2}"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/right_finger.STL" scale="${scale}"/>
</geometry>
<material name="purple"/>
</visual>
<collision>
<origin xyz="0.078 0.005 0.36" rpy="0 ${PI / 2} ${PI / 2}"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/right_finger.STL" scale="${scale}"/>
</geometry>
</collision>
</link>
<link name="gripper_left">
<xacro:default_inertia mass="0.01"/>
<visual>
<origin xyz="0.03 0.005 0.36" rpy="0 ${PI / 2} ${PI / 2}"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/left_finger.STL" scale="${scale}"/>
</geometry>
<material name="purple"/>
</visual>
<collision>
<origin xyz="0.03 0.005 0.36" rpy="0 ${PI / 2} ${PI / 2}"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/left_finger.STL" scale="${scale}"/>
</geometry>
</collision>
</link>
<link name="rgb_camera_optical" >
</link>
<link name="rgb_camera">
<xacro:default_inertia mass="0.001"/>
<visual>
<origin xyz="-0.07 -0.105 0.095" rpy="0 ${PI/2} 0"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/pi_camera.STL" scale="${scale}"/>
</geometry>
<material name="blue"/>
</visual>
<collision>
<origin xyz="-0.07 -0.105 0.095" rpy="0 ${PI/2} 0"/>
<geometry>
<mesh filename="file://$(find agbot_description)/meshes/pi_camera.STL" scale="${scale}"/>
</geometry>
</collision>
</link>
<!-- Joint Descriptions -->
<joint name="virtual_joint" type="fixed">
<parent link="world"/>
<child link="base_link"/>
<origin xyz="0 0 0" rpy="0 0 ${PI/2}"/>
</joint>
<joint name ="base_joint" type="revolute">
<parent link="base_link"/>
<child link = "base_plate"/>
<origin xyz="0 0 0.309"/>
<axis xyz="0 0 1"/>
<limit lower="-${PI}" upper="${PI}"
effort="${effort}" velocity="${velocity}"/>
</joint>
<joint name="shoulder_joint" type="revolute">
<parent link="base_plate"/>
<child link="forward_drive_arm"/>
<origin xyz="0 0.006 0.23" rpy="-2.0 0 0"/>
<axis xyz="1 0 0"/>
<limit lower="0" upper="4.0" effort="${effort}" velocity="${velocity}"/>
</joint>
<joint name="elbow_joint" type="revolute">
<parent link="forward_drive_arm"/>
<child link="horizontal_arm"/>
<origin xyz="0.27 0 1.07" rpy="-${PI} 0 0"/>
<axis xyz="1 0 0"/>
<limit lower="-${PI}" upper="0" effort="${effort}" velocity="${velocity}"/>
</joint>
<joint name="wrist_joint" type="revolute">
<parent link="horizontal_arm"/>
<child link="claw_support"/>
<origin xyz="0.05 0 ${horizontal_arm_length}" />
<axis xyz="1 0 0"/>
<limit lower="-${PI / 2}" upper="${PI / 2}" effort="${effort}" velocity="${velocity}"/>
</joint>
<joint name="gripper_right_joint" type="revolute">
<parent link="claw_support"/>
<child link="gripper_right"/>
<origin xyz="-.075 -.03 0.175"/>
<axis xyz="0 1 0"/>
<limit lower="-${PI / 2}" upper="0.0" effort="${effort}" velocity="${velocity}"/>
</joint>
<joint name="gripper_left_joint" type="revolute">
<mimic joint="gripper_right_joint" multiplier="-1"/>
<parent link="claw_support"/>
<child link="gripper_left"/>
<origin xyz="0.065 -.03 0.175"/>
<axis xyz="0 1 0"/>
<limit lower="0.0" upper="${PI / 2}" effort="${effort}" velocity="${velocity}"/>
</joint>
<joint name="camera_optical_joint" type="fixed">
<parent link="claw_support"/>
<child link="rgb_camera_optical"/>
<origin xyz = "0 .22 0.2" rpy = "0 0 0" />
</joint>
<joint name = "rgb_camera_joint" type = "fixed" >
<parent link = "rgb_camera_optical" />
<child link = "rgb_camera" />
<origin xyz="0 0 0" rpy="${PI/2} -${PI/2} -${PI/2}"/>
</joint>
<xacro:default_transmission name="base_joint" />
<xacro:default_transmission name="shoulder_joint" />
<xacro:default_transmission name="elbow_joint" />
<xacro:default_transmission name="wrist_joint" />
<xacro:default_transmission name="gripper_right_joint" />
</robot>
This is the gazebo.xacro file...
<?xml version="1.0" encoding="utf-8"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="agbot_arm">
<xacro:property name="PI" value="3.141592653589793238464" />
<!-- Gazebo ros2_control plugin -->
<gazebo>
<plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control">
<robot_param>robot_description</robot_param>
<robot_param_node>robot_state_publisher</robot_param_node>
<parameters>$(find agbot_arm_controller)/config/agbot_arm_controllers.yaml</parameters>
</plugin>
</gazebo>
<gazebo reference="rgb_camera">
<sensor name="camera_sensor" type="camera">
<pose>0 0 0 0 0 0</pose>
<visualize>true</visualize>
<update_rate>60.0</update_rate>
<plugin filename="libgazebo_ros_camera.so" name="camera_controller">
<frame_name>rgb_camera_optical</frame_name>
</plugin>
</sensor>
</gazebo>
<gazebo reference="base_link">
<material>Gazebo/Blue</material>
</gazebo>
<gazebo reference="base_plate">
<material>Gazebo/Red</material>
</gazebo>
<gazebo reference="forward_drive_arm">
<material>Gazebo/Yellow</material>
</gazebo>
<gazebo reference="horizontal_arm">
<material>Gazebo/Green</material>
</gazebo>
<gazebo reference="claw_support">
<material>Gazebo/Yellow</material>
</gazebo>
<gazebo reference="gripper_right">
<material>Gazebo/Purple</material>
</gazebo>
<gazebo reference="gripper_left">
<material>Gazebo/Purple</material>
</gazebo>
<gazebo reference="rgb_camera">
<material>Gazebo/Blue</material>
</gazebo>
</robot>
This is the control.xacro file...
<?xml version="1.0" encoding="utf-8"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="agbot_arm">
<ros2_control name="RobotSystem" type="system">
<xacro:property name="PI" value="3.14159265359" />
<!-- ros2_control Gazebo -->
<hardware>
<plugin>gazebo_ros2_control/GazeboSystem</plugin>
<param name="position_state_following_offset">0.0</param>
</hardware>
<joint name="base_joint">
<command_interface name="position">
<param name="min">-${PI}</param>
<param name="max">${PI}</param>
</command_interface>
<state_interface name="position"/>
</joint>
<joint name="shoulder_joint">
<command_interface name="position">
<param name="min">0</param>
<param name="max">4</param>
</command_interface>
<state_interface name="position"/>
</joint>
<joint name="elbow_joint">
<command_interface name="position">
<param name="min">-${PI}</param>
<param name="max">0</param>
</command_interface>
<state_interface name="position"/>
</joint>
<joint name="wrist_joint">
<command_interface name="position">
<param name="min">-${PI/2}</param>
<param name="max">${PI/2}</param>
</command_interface>
<state_interface name="position"/>
</joint>
<joint name="gripper_right_joint">
<command_interface name="position">
<param name="min">-${PI/2}</param>
<param name="max">0</param>
</command_interface>
<state_interface name="position"/>
</joint>
<joint name="gripper_left_joint">
<param name="mimic">gripper_right_joint</param>
<param name="multiplier">-1</param>
<command_interface name="position">
<param name="min">0</param>
<param name="max">${PI/2}</param>
</command_interface>
</joint>
</ros2_control>
</robot>
This is the controllers.yaml file...
controller_manager:
ros__parameters:
update_rate: 100 # Hz
arm_controller:
type: joint_trajectory_controller/JointTrajectoryController
gripper_controller:
type: joint_trajectory_controller/JointTrajectoryController
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster
arm_controller:
ros__parameters:
joints:
- base_joint
- shoulder_joint
- elbow_joint
- wrist_joint
command_interfaces:
- position
state_interfaces:
- position
open_loop_control: true
allow_integration_in_goal_trajectories: true
gripper_controller:
ros__parameters:
joints:
- gripper_right_joint
command_interfaces:
- position
state_interfaces:
- position
open_loop_control: true
allow_integration_in_goal_trajectories: true
This is the common properties file. It's just a bunch of colors for rviz to use.
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- Init colour -->
<material name="black">
<color rgba="0.0 0.0 0.0 1.0"/>
</material>
<material name="dark">
<color rgba="0.3 0.3 0.3 1.0"/>
</material>
<material name="light_black">
<color rgba="0.4 0.4 0.4 1.0"/>
</material>
<material name="blue">
<color rgba="0.0 0.0 0.8 1.0"/>
</material>
<material name="green">
<color rgba="0.0 0.8 0.0 1.0"/>
</material>
<material name="grey">
<color rgba="0.5 0.5 0.5 1.0"/>
</material>
<material name="orange">
<color rgba="1.0 0.4235 0.0392 1.0"/>
</material>
<material name="brown">
<color rgba="0.8706 0.8118 0.7647 1.0"/>
</material>
<material name="red">
<color rgba="0.8 0.0 0.0 1.0"/>
</material>
<material name="white">
<color rgba="1.0 1.0 1.0 1.0"/>
</material>
<material name="yellow">
<color rgba="1.0 0.93 0.7 1" />
</material>
<material name="purple">
<color rgba="0.4 0.23 0.72 1" />
</material>
<material name="turquoise" >
<color rgba="0.05 0.737 0.690 1.0" />
</material>
<material name="skyblue" >
<color rgba="0.2 1.0 1.0" />
</material>
<material name="pink" >
<color rgba="1.0 0 1.0 1.0" />
</material>
</robot>
And this is the launch file...
import os
from os import pathsep
from ament_index_python.packages import get_package_share_directory, get_package_prefix
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, SetEnvironmentVariable
from launch.substitutions import Command, LaunchConfiguration
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node
from launch_ros.parameter_descriptions import ParameterValue
def generate_launch_description():
agbot_arm_description = get_package_share_directory('agbot_description')
agbot_arm_description_share = get_package_prefix('agbot_description')
gazebo_ros_dir = get_package_share_directory('gazebo_ros')
model_arg = DeclareLaunchArgument(name='model', default_value=os.path.join(
agbot_arm_description, 'urdf', 'agbot_arm.urdf.xacro'
),
description='Absolute path to robot urdf file'
)
model_path = os.path.join(agbot_arm_description, "models")
model_path += pathsep + os.path.join(agbot_arm_description_share, "share")
env_var = SetEnvironmentVariable("GAZEBO_MODEL_PATH", model_path)
robot_description = ParameterValue(Command(['xacro ', LaunchConfiguration('model')]),
value_type=str)
robot_state_publisher_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
parameters=[{"robot_description": robot_description},
{"use_sim_time": True}]
)
joint_state_publisher_node = Node(
package = 'joint_state_publisher',
executable = 'joint_state_publisher',
name = 'joint_state_publisher',
parameters =[
{'source_list':['joint_state_broadcaster/joint_states'],
'rate' : 20.0
}]
)
world = os.path.join(
get_package_share_directory('agbot_description'),
'worlds',
'empty_world.world'
)
start_gazebo_server = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(gazebo_ros_dir, 'launch', 'gzserver.launch.py')
),
# launch_arguments={'world': world}.items()
)
start_gazebo_client = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(gazebo_ros_dir, 'launch', 'gzclient.launch.py')
)
)
spawn_robot = Node(package='gazebo_ros',
executable='spawn_entity.py',
arguments=['-entity',
'agbot_arm',
'-topic',
'robot_description'
],
output='screen'
)
return LaunchDescription([
env_var,
model_arg,
start_gazebo_server,
start_gazebo_client,
robot_state_publisher_node,
joint_state_publisher_node,
spawn_robot
])
I have searched online for an answer, but nothing I try seems to work. Oddly (?) when I comment out the line "$(find agbot_arm_controller)/config/agbot_arm_controllers.yaml" in the gazebo.xacro file, gazebo starts with the arm in the correct position and then gravity will make the robot arm collapse. When I leave the yaml file in the gazebo.xacro file, gazebo starts, but the robot does not feel the effects of gravity. This issue has been driving me nuts for a week now. I would be extremely grateful to anyone who can help me with this!! Thanks, in advance for any and all assistance.