import os from ament_index_python import get_package_share_directory from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, RegisterEventHandler, TimerAction from launch.substitutions import LaunchConfiguration, PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare def generate_launch_description(): namespace = LaunchConfiguration('namespace') declared_args = [ DeclareLaunchArgument( 'namespace', default_value='', description='ROS namespace for all robot nodes (e.g. "robot1").' ), ] rviz_config_dir = os.path.join( get_package_share_directory('raspbot_v2_sim'), 'rviz', 'raspbot_v2.rviz') bringup_robot = IncludeLaunchDescription( PythonLaunchDescriptionSource([ PathJoinSubstitution([ FindPackageShare('raspbot_v2_bringup'), 'launch', 'raspbot_v2_bringup.launch.py' ]) ]), launch_arguments={ 'namespace': namespace, 'use_sim_time': 'false', }.items() ) return LaunchDescription([ *declared_args, bringup_robot, Node( package="rviz2", executable="rviz2", name="rviz2", arguments=['-d', rviz_config_dir], output='screen', ) ])