| | import os |
| | from ament_index_python.packages import get_package_share_directory |
| | from launch import LaunchDescription |
| | from launch.actions import DeclareLaunchArgument |
| | from launch.substitutions import LaunchConfiguration |
| | from launch_ros.actions import Node |
| |
|
| |
|
| | def generate_launch_description(): |
| | |
| | pkg_share = get_package_share_directory('motion_player') |
| |
|
| | |
| | default_urdf_path = os.path.join(pkg_share, 'urdf', 'g1_custom_collision_29dof.urdf') |
| | default_rviz_config_path = os.path.join(pkg_share, 'rviz', 'robot.rviz') |
| |
|
| | |
| | urdf_file_arg = DeclareLaunchArgument( |
| | 'urdf_file', |
| | default_value=default_urdf_path, |
| | description='Path to the URDF file' |
| | ) |
| |
|
| | rviz_config_arg = DeclareLaunchArgument( |
| | 'rviz_config', |
| | default_value=default_rviz_config_path, |
| | description='Path to the RViz config file' |
| | ) |
| |
|
| | port_arg = DeclareLaunchArgument( |
| | 'port', |
| | default_value='11235', |
| | description='UDP port to listen for OSC mocap data' |
| | ) |
| |
|
| | robot_type_arg = DeclareLaunchArgument( |
| | 'robot_type', |
| | default_value='unitree_g1', |
| | description='Target robot type (unitree_g1 or unitree_g1_with_hands)' |
| | ) |
| |
|
| | human_height_arg = DeclareLaunchArgument( |
| | 'human_height', |
| | default_value='1.75', |
| | description='Human height in meters for scaling' |
| | ) |
| |
|
| | skeleton_offset_x_arg = DeclareLaunchArgument( |
| | 'skeleton_offset_x', |
| | default_value='1.0', |
| | description='X offset to place skeleton beside robot' |
| | ) |
| |
|
| |
|
| | |
| | with open(default_urdf_path, 'r') as urdf_file: |
| | robot_description_content = urdf_file.read() |
| |
|
| | robot_description = {'robot_description': robot_description_content} |
| |
|
| | |
| | robot_state_publisher_node = Node( |
| | package='robot_state_publisher', |
| | executable='robot_state_publisher', |
| | name='robot_state_publisher', |
| | output='screen', |
| | parameters=[robot_description] |
| | ) |
| |
|
| | |
| | motion_player_node = Node( |
| | package='motion_player', |
| | executable='motion_player', |
| | name='motion_player', |
| | output='screen', |
| | arguments=['--realtime'], |
| | parameters=[{ |
| | 'port': LaunchConfiguration('port'), |
| | 'robot_type': LaunchConfiguration('robot_type'), |
| | 'human_height': LaunchConfiguration('human_height'), |
| | 'skeleton_offset_x': LaunchConfiguration('skeleton_offset_x'), |
| | }] |
| | ) |
| |
|
| | |
| | rviz_node = Node( |
| | package='rviz2', |
| | executable='rviz2', |
| | name='rviz2', |
| | output='screen', |
| | arguments=['-d', LaunchConfiguration('rviz_config')] |
| | ) |
| |
|
| | return LaunchDescription([ |
| | urdf_file_arg, |
| | rviz_config_arg, |
| | port_arg, |
| | robot_type_arg, |
| | human_height_arg, |
| | skeleton_offset_x_arg, |
| | robot_state_publisher_node, |
| | motion_player_node, |
| | rviz_node |
| | ]) |
| |
|
| |
|