First and foremost I know my joint state publisher and robot state publisher are working, as when I call ros2 topic echo on them it prints what it should.
However, when I boot gazebo, the links that are coming from a mesh do not appear at all and the links that are connected via continuous joints show up at (0 0 0) instead of their correct position. Further adding to my confusion is the fact that all of these parts show up just fine in rViz
I have 2 relevant launch files for this, spawn.launch.py and state_publisher.launch.py whose code is below. The urdf file is named tb3_burger.urdf.
spawn.launch.py - -----------------------------------------------------------------------------------------------
from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os
def generate_launch_description():
urdf_file = os.path.join(
get_package_share_directory(‘ros2_urdf_project’), # Replace with actual package name
‘urdf’,
‘tb3_burger.urdf’ # Or .xacro
)
return LaunchDescription([
Node(
package='gazebo_ros',
executable='spawn_entity.py',
arguments=['-file', urdf_file, '-entity', 'tb3_burger'],
output='screen'
)
])
state_publisher.launch.py - -----------------------------------------------------------------------------------
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import Command, PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
def generate_launch_description():
robot_description = {'robot_description': Command(['cat ', LaunchConfiguration('urdf_file')])}
# Allow passing xacro file path as argument
declare_urdf_arg = DeclareLaunchArgument(
name='urdf_file',
default_value=PathJoinSubstitution([
'/home/user/ros2_ws/src/ros2_urdf_project', # <-- adjust this to your actual path,
'urdf',
'tb3_burger.urdf' # Replace with actual file
]),
description='URDF/Xacro file'
)
#robot_description = {'robot_description': Command(['xacro ', LaunchConfiguration('urdf_file')])}
return LaunchDescription([
declare_urdf_arg,
# Joint State Publisher GUI
Node(
package='joint_state_publisher_gui',
executable='joint_state_publisher_gui',
name='joint_state_publisher_gui',
output='screen',
),
# Robot State Publisher
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[robot_description],
)
])
If anyone could help me figure out what on earth is going awry, that would be great