URDF not visualizing correctly in rviz2
Hi all
I am running ROS2 Foxy on Ubuntu 12.04.
I am a NEWBIE.
As my first attempt at modelling my hexapod robot, I learnt URDF and XACRO and I am attempting to now visualize my robot in RVIZ2. - As part of learning my 'orientations' of joints, I throught that I could use the visualization to check design - so some orientations are probably still wrong as I learn how joints work! First problems first though!
After I launch RVIZ2 (launch file included later) and add the RobotModel component, I change the RobotModel/Description Source to 'file' and the description file to my urdf file, and my GlobalOptions/Fixed Frame to base_link. RVIZ now displays the 'body' of my robot only. When I look at the RobotModel/Links it lists all of the links. When I ask to show any of the child link axes it shows them at the center of my robot 'body'.
I appreciate any pointers on how to continue to troubleshoot this!
[launch file]
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node
def generate_launch_description():
# Get the launch directory
bringup_dir = get_package_share_directory('hex1')
launch_dir = os.path.join(bringup_dir, 'launch')
# Launch configuration variables specific to simulation
rviz_config_file = LaunchConfiguration('rviz_config_file')
use_robot_state_pub = LaunchConfiguration('use_robot_state_pub')
use_joint_state_pub = LaunchConfiguration('use_joint_state_pub')
use_rviz = LaunchConfiguration('use_rviz')
urdf_file= LaunchConfiguration('urdf_file')
declare_rviz_config_file_cmd = DeclareLaunchArgument(
'rviz_config_file',
default_value=os.path.join(bringup_dir, 'rviz', 'view.rviz'),
description='Full path to the RVIZ config file to use')
declare_use_robot_state_pub_cmd = DeclareLaunchArgument(
'use_robot_state_pub',
default_value='True',
description='Whether to start the robot state publisher')
declare_use_joint_state_pub_cmd = DeclareLaunchArgument(
'use_joint_state_pub',
default_value='True',
description='Whether to start the joint state publisher')
declare_use_rviz_cmd = DeclareLaunchArgument(
'use_rviz',
default_value='True',
description='Whether to start RVIZ')
declare_urdf_cmd = DeclareLaunchArgument(
'urdf_file',
default_value=os.path.join(bringup_dir, 'urdf', 'hex1.xacro'),
description='Whether to start RVIZ')
start_robot_state_publisher_cmd = Node(
condition=IfCondition(use_robot_state_pub),
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
#parameters=[{'use_sim_time': use_sim_time}],
arguments=[urdf_file])
start_joint_state_publisher_cmd = Node(
condition=IfCondition(use_joint_state_pub),
package='joint_state_publisher_gui',
executable='joint_state_publisher_gui',
name='joint_state_publisher_gui',
output='screen',
arguments=[urdf_file])
rviz_cmd = Node(
condition=IfCondition(use_rviz),
package='rviz2',
executable='rviz2',
name='rviz2',
arguments=['-d', rviz_config_file],
output='screen')
# Create the launch description and populate
ld = LaunchDescription()
# Declare the launch options
ld.add_action(declare_rviz_config_file_cmd)
ld.add_action(declare_urdf_cmd)
ld.add_action(declare_use_robot_state_pub_cmd)
ld.add_action(declare_use_joint_state_pub_cmd)
ld.add_action(declare_use_rviz_cmd)
# Add any conditioned actions
ld.add_action(start_joint_state_publisher_cmd)
ld.add_action(start_robot_state_publisher_cmd)
ld.add_action(rviz_cmd)
return ld
[urdf file]
<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from hex1.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot name="hex1">
<material name="blue">
<color rgba="0 0 0.8 1"/>
</material>
<material name="white">
<color rgba=" 1 1 1 1"/>
</material>
<material name="black">
<color grba="0 0 0 1"/>
</material>
<material name="grey">
<color rgba="0.4 0.4 0.4 1.0"/>
< ...