e938b6921f
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
from launch_ros.actions import Node
|
|
from launch import LaunchDescription
|
|
from launch.actions import DeclareLaunchArgument
|
|
from launch.substitutions import LaunchConfiguration
|
|
from launch.conditions import IfCondition, UnlessCondition
|
|
import xacro
|
|
import os
|
|
from ament_index_python.packages import get_package_share_directory
|
|
|
|
|
|
def generate_launch_description():
|
|
share_dir = get_package_share_directory('duru_urdf_description')
|
|
|
|
xacro_file = os.path.join(share_dir, 'urdf', 'duru_urdf.xacro')
|
|
robot_description_config = xacro.process_file(xacro_file)
|
|
robot_urdf = robot_description_config.toxml()
|
|
|
|
rviz_config_file = os.path.join(share_dir, 'config', 'display.rviz')
|
|
|
|
gui_arg = DeclareLaunchArgument(
|
|
name='gui',
|
|
default_value='True'
|
|
)
|
|
|
|
show_gui = LaunchConfiguration('gui')
|
|
|
|
robot_state_publisher_node = Node(
|
|
package='robot_state_publisher',
|
|
executable='robot_state_publisher',
|
|
name='robot_state_publisher',
|
|
parameters=[
|
|
{'robot_description': robot_urdf}
|
|
]
|
|
)
|
|
|
|
joint_state_publisher_node = Node(
|
|
condition=UnlessCondition(show_gui),
|
|
package='joint_state_publisher',
|
|
executable='joint_state_publisher',
|
|
name='joint_state_publisher'
|
|
)
|
|
|
|
joint_state_publisher_gui_node = Node(
|
|
condition=IfCondition(show_gui),
|
|
package='joint_state_publisher_gui',
|
|
executable='joint_state_publisher_gui',
|
|
name='joint_state_publisher_gui'
|
|
)
|
|
|
|
rviz_node = Node(
|
|
package='rviz2',
|
|
executable='rviz2',
|
|
name='rviz2',
|
|
arguments=['-d', rviz_config_file],
|
|
output='screen'
|
|
)
|
|
|
|
return LaunchDescription([
|
|
gui_arg,
|
|
robot_state_publisher_node,
|
|
joint_state_publisher_node,
|
|
joint_state_publisher_gui_node,
|
|
rviz_node
|
|
])
|