import os import launch import launch_ros import xacro from ament_index_python import get_package_share_directory def get_package_file(package, file_path): """Get the location of a file installed in an ament package""" package_path = get_package_share_directory(package) absolute_file_path = os.path.join(package_path, file_path) return absolute_file_path def generate_launch_description(): xacro_file = get_package_file('openarm_grip_description', 'urdf/openarm_grip.xacro') urdf = xacro.process_file(xacro_file).toprettyxml(indent=' ') rviz_config_file = get_package_file('openarm_grip_description', 'config/display.rviz') return launch.LaunchDescription([ launch_ros.actions.Node( name='robot_state_publisher', package='robot_state_publisher', executable='robot_state_publisher', output='screen', parameters=[{'robot_description': urdf}], ), launch_ros.actions.Node( name='joint_state_publisher_gui', package='joint_state_publisher_gui', executable='joint_state_publisher_gui', output='screen', ), launch_ros.actions.Node( name='rviz', package='rviz2', executable='rviz2', output='screen', arguments=['-d', rviz_config_file] ) ])