0
$\begingroup$

As stated, I am encountering this error when launching a ROS 2 simulation. I am currently using ROS 2 Iron and Gazebo Classic.

I am spawning the robot system from a pythonlaunch file as it follows:

spawn_robot = Node( package='gazebo_ros', executable='spawn_entity.py', arguments=['-topic', 'robot_description', '-entity', 'arm', '-x' , '0', '-y', '0', '-z', '0.1'], remappings=[ ('/camera_R/image_raw', 'image_R'), ('/camera_L/image_raw', 'image_L'), ('/laser_controller/out', 'laser_scan')], output='screen') 

The robot description is parsed as it follows:

xacro_file = os.path.join(get_package_share_directory(pkg_name), 'models', 'arm', 'model.xacro') robot_description_raw = xacro.process_file(xacro_file).toxml() params = {'robot_description': robot_description_raw, 'verbose': True, 'use_sim_time': True} rsp = Node(package='robot_state_publisher', executable='robot_state_publisher', output='screen', parameters=[params]) 

When I try to visualize it in Rviz I encounter the error No transform from [shoulder] to [base_link] and the following picture:

Rviz visualization

The xacro file that contains the model has the following definition:

<?xml version="1.0" ?> <!-- =================================================================================== --> <!-- | This document was autogenerated by xacro from robot_models/models/simple_DDR/model.xacro | --> <!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | --> <!-- =================================================================================== --> <robot xmlns:xacro="http://www.ros.org/wiki/xacro"> <xacro:include filename="$(find robot_models)/models/arm/variables.xacro"/> <link name="base_link"></link> <link name="base"> <inertial> <origin xyz="${xmass_base} ${ymass_base} ${zmass_base}" rpy="0.0 0.0 0.0"/> <mass value="${mass_base}"/> <inertia ixx="${ixx_base}" ixy="0.0" ixz="0.0" iyy="${iyy_base}" iyz="0.0" izz="${izz_base}"/> </inertial> <collision> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <mesh filename="file://$(find robot_models)/models/arm/meshes/collision/base.stl" scale="1 1 1"/> </geometry> </collision> <virtual> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <mesh filename="file://$(find robot_models)/models/arm/meshes/visual/base.dae" scale="1 1 1"/> </geometry> </virtual> </link> <joint name="joint_base" type="fixed"> <parent link="base_link"/> <child link="base"/> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> </joint> <link name="shoulder"> <inertial> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <mass value="${mass_shoulder}"/> <inertia ixx="${ixx_shoulder}" ixy="0.0" ixz="0.0" iyy="${iyy_shoulder}" iyz="0.0" izz="${izz_shoulder}"/> </inertial> <collision> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <mesh filename="file://$(find robot_models)/models/arm/meshes/collision/shoulder.stl" scale="1 1 1"/> </geometry> </collision> </link> <joint name="joint_shoulder" type="revolute"> <parent link="base"/> <child link="shoulder"/> <origin rpy="0.0 0.0 0.0" xyz="0.0 0.0 0.163"/> <axis xyz="0 0 1"/> <limit effort="150.0" lower="-6.28318530718" upper="6.28318530718" velocity="3.14"/> <dynamics damping="0.0" friction="0.0"/> </joint> </robot> 
$\endgroup$

1 Answer 1

0
$\begingroup$

The robot state publisher used to get the visualization in rviz requires the joint states to be published, see here (first paragraph).

Because the joint_base joint is fixed, the transformation is already available. The joint_shoulder transformation is unknown (without the gazebo plugin) because this joint can move.

You can get the joint states by using following plugin in your gazebo robot model:

Gazebo Classic

Install the required package (the metapackage with the plugin)

sudo apt install ros-iron-gazebo-ros-pkgs 

Add this to your model

<plugin name="gazebo_ros_joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so"> <joint_name>joint_shoulder</joint_name> </plugin> 

Gazebo Sim

Install the required package (the metapackage with the plugin)

sudo apt install ros-iron-ros-gz 

Add this to your model

<gazebo> <plugin name="gz::sim::systems::JointStatePublisher" filename="gz-sim-joint-state-publisher-system"> <topic>/joint_states</topic> <joint_name>joint_shoulder</joint_name> </plugin> </gazebo> 
$\endgroup$
2
  • $\begingroup$ Is this also valid for classic? $\endgroup$ Commented Feb 24, 2024 at 22:02
  • $\begingroup$ I missed the "Classic" part of your question. Updated the answer to include the Gazebo Classic approach. $\endgroup$ Commented Feb 24, 2024 at 23:48

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.