|
| 1 | +# Brings up everything the arm needs on board: the CAN loop, the arm hardware |
| 2 | +# nodes and the lighting translator. |
| 3 | +# |
| 4 | +# ros2 launch arm_hardware_interface launch_arm_common.launch.py |
| 5 | +# |
| 6 | +# The CAN arguments are forwarded to generic_can_interface_bringup_on_board, ie |
| 7 | +# |
| 8 | +# ros2 launch arm_hardware_interface launch_arm_common.launch.py \ |
| 9 | +# can_interface:=can1 bring_up_interface:=true |
| 10 | + |
| 11 | +import os |
| 12 | + |
| 13 | +from ament_index_python.packages import get_package_share_directory |
| 14 | +from launch import LaunchDescription |
| 15 | +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription |
| 16 | +from launch.launch_description_sources import PythonLaunchDescriptionSource |
| 17 | +from launch.substitutions import LaunchConfiguration |
| 18 | + |
| 19 | + |
| 20 | +def generate_launch_description(): |
| 21 | + launch_dir = os.path.join( |
| 22 | + get_package_share_directory('arm_hardware_interface'), 'launch') |
| 23 | + |
| 24 | + default_can_config = os.path.join( |
| 25 | + get_package_share_directory('arm_hardware_interface'), |
| 26 | + 'config', |
| 27 | + 'can_loop_on_board.yaml') |
| 28 | + |
| 29 | + default_lighting_config = os.path.join( |
| 30 | + get_package_share_directory('rover_lighting'), |
| 31 | + 'config', |
| 32 | + 'lighting_translator.yaml') |
| 33 | + |
| 34 | + args = [ |
| 35 | + DeclareLaunchArgument( |
| 36 | + 'loop_name', default_value='main', |
| 37 | + description="Topics are published under /can/<loop_name>/"), |
| 38 | + DeclareLaunchArgument( |
| 39 | + 'can_interface', default_value='can0', |
| 40 | + description='SocketCAN interface name, ie can0'), |
| 41 | + DeclareLaunchArgument( |
| 42 | + 'config_file', default_value=default_can_config, |
| 43 | + description="Path to the CAN loop's yaml config"), |
| 44 | + DeclareLaunchArgument( |
| 45 | + 'bring_up_interface', default_value='false', |
| 46 | + description='Run can_bringup.sh before starting the node. Needs passwordless sudo.'), |
| 47 | + DeclareLaunchArgument( |
| 48 | + 'lighting_config', default_value=default_lighting_config, |
| 49 | + description='Parameter file for the lighting translator'), |
| 50 | + ] |
| 51 | + |
| 52 | + can_bringup = IncludeLaunchDescription( |
| 53 | + PythonLaunchDescriptionSource( |
| 54 | + os.path.join(launch_dir, 'generic_can_interface_bringup_on_board.launch.py')), |
| 55 | + launch_arguments={ |
| 56 | + 'loop_name': LaunchConfiguration('loop_name'), |
| 57 | + 'can_interface': LaunchConfiguration('can_interface'), |
| 58 | + 'config_file': LaunchConfiguration('config_file'), |
| 59 | + 'bring_up_interface': LaunchConfiguration('bring_up_interface'), |
| 60 | + }.items(), |
| 61 | + ) |
| 62 | + |
| 63 | + arm_hardware = IncludeLaunchDescription( |
| 64 | + PythonLaunchDescriptionSource( |
| 65 | + os.path.join(launch_dir, 'arm_hardware_bringup.launch.py'))) |
| 66 | + |
| 67 | + lighting_translator = IncludeLaunchDescription( |
| 68 | + PythonLaunchDescriptionSource( |
| 69 | + os.path.join(launch_dir, 'lighting_translator.launch.py')), |
| 70 | + launch_arguments={ |
| 71 | + 'config': LaunchConfiguration('lighting_config'), |
| 72 | + }.items(), |
| 73 | + ) |
| 74 | + |
| 75 | + return LaunchDescription(args + [can_bringup, arm_hardware, lighting_translator]) |
0 commit comments