diff --git a/src/igvc_description/launch/publisher.launch.py b/src/igvc_description/launch/publisher.launch.py index bee0e333..4d42542e 100644 --- a/src/igvc_description/launch/publisher.launch.py +++ b/src/igvc_description/launch/publisher.launch.py @@ -2,105 +2,93 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.conditions import IfCondition, UnlessCondition -from launch.substitutions import Command, LaunchConfiguration +from launch.substitutions import Command, LaunchConfiguration, PathJoinSubstitution from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare def generate_launch_description(): - + declared_arguments = [] # Set the path to this package. igvc_description_package = FindPackageShare(package='igvc_description').find('igvc_description') + default_urdf = PathJoinSubstitution( + [ + igvc_description_package, + 'urdf', + 'robot.urdf.xacro' + ] + ) + + + declared_arguments.append( + DeclareLaunchArgument( + 'urdf_model', + default_value=default_urdf, + description='Absolute path to robot urdf file' + ) + ) + declared_arguments.append( + DeclareLaunchArgument( + 'gui', + default_value='False', + description='Flag to enable joint_state_publisher_gui' + ) + ) - # Set the path to the URDF file - default_urdf_model_path = os.path.join(igvc_description_package , 'urdf/robot.urdf.xacro') + declared_arguments.append( + DeclareLaunchArgument( + 'use_robot_state_pub', + default_value='True', + description='Whether to start the robot state publisher' + ) + ) + declared_arguments.append( + DeclareLaunchArgument( + 'use_sim_time', + default_value='False', + description='Use simulation (Gazebo) clock if true' + ) + ) - # Launch configuration variables specific to simulation - gui = LaunchConfiguration('gui') urdf_model = LaunchConfiguration('urdf_model') + gui = LaunchConfiguration('gui') use_robot_state_pub = LaunchConfiguration('use_robot_state_pub') use_sim_time = LaunchConfiguration('use_sim_time') - # Declare the launch arguments - declare_urdf_model_path_cmd = DeclareLaunchArgument( - name='urdf_model', - default_value=default_urdf_model_path, - description='Absolute path to robot urdf file') - - declare_use_joint_state_publisher_cmd = DeclareLaunchArgument( - name='gui', - default_value='False', - description='Flag to enable joint_state_publisher_gui') - - declare_use_robot_state_pub_cmd = DeclareLaunchArgument( - name='use_robot_state_pub', - default_value='True', - description='Whether to start the robot state publisher') - declare_use_sim_time_cmd = DeclareLaunchArgument( - name='use_sim_time', - default_value='False', - description='Use simulation (Gazebo) clock if true') - - # Specify the actions - - # Publish the joint state values for the non-fixed joints in the URDF file. - start_joint_state_publisher_cmd = Node( - condition=UnlessCondition(gui), - package='joint_state_publisher', - executable='joint_state_publisher', - name='joint_state_publisher') - - # A GUI to manipulate the joint state values - start_joint_state_publisher_gui_node = Node( - condition=IfCondition(gui), - package='joint_state_publisher_gui', - executable='joint_state_publisher_gui', - name='joint_state_publisher_gui') - # Subscribe to the joint states of the robot, and publish the 3D pose of each link. - start_robot_state_publisher_cmd = Node( - condition=IfCondition(use_robot_state_pub), - package='robot_state_publisher', - executable='robot_state_publisher', - parameters=[{'use_sim_time': use_sim_time, - 'robot_description': Command( - [ - 'xacro ', urdf_model, - ' use_mock_hardware:=', LaunchConfiguration('use_mock_hardware') - ] - ), - }], + joint_state_publisher_node = Node( + package='joint_state_publisher', + executable='joint_state_publisher', + name='joint_state_publisher', + condition=UnlessCondition(gui) ) - - # Create foxglove bridge - start_foxglove_bridge_cmd = Node( - package='foxglove_bridge', - executable='foxglove_bridge' - ) - - # Create the launch description and populate - # Create the launch description and populate - launch_description = LaunchDescription( - [ - DeclareLaunchArgument( - 'use_mock_hardware', - default_value='false', - description='Run in Simulation' - ), - - ] + joint_state_publisher_gui_node = Node( + package='joint_state_publisher_gui', + executable='joint_state_publisher_gui', + name='joint_state_publisher_gui', + condition=IfCondition(gui) + ) + + robot_state_publisher_node = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + name='robot_state_publisher', + parameters=[{'use_sim_time': use_sim_time, + 'robot_description': Command([ + 'xacro ', urdf_model, + 'use_mock_hardware:=', LaunchConfiguration('use_mock_hardware') + ] + ) + }] + ) + foxglove_bridge_node = Node( + package='foxglove_bridge', + executable='foxglove_bridge' ) + Nodes = [ + joint_state_publisher_node, + joint_state_publisher_gui_node, + robot_state_publisher_node, + foxglove_bridge_node] + return LaunchDescription(declared_arguments + Nodes) - # Declare the launch options - launch_description.add_action(declare_urdf_model_path_cmd) - launch_description.add_action(declare_use_joint_state_publisher_cmd) - launch_description.add_action(declare_use_robot_state_pub_cmd) - launch_description.add_action(declare_use_sim_time_cmd) - - # Add any actions - launch_description.add_action(start_foxglove_bridge_cmd) - launch_description.add_action(start_joint_state_publisher_cmd) - launch_description.add_action(start_joint_state_publisher_gui_node) - launch_description.add_action(start_robot_state_publisher_cmd) - - return launch_description diff --git a/src/igvc_description/launch/rviz.launch.py b/src/igvc_description/launch/rviz.launch.py index 2fd8630e..56ad4744 100644 --- a/src/igvc_description/launch/rviz.launch.py +++ b/src/igvc_description/launch/rviz.launch.py @@ -8,20 +8,81 @@ from launch_ros.substitutions import FindPackageShare def generate_launch_description(): - + declared_arguments = [] # Set the path to this package. igvc_description_package = FindPackageShare(package='igvc_description').find('igvc_description') - - # Set the path to the RViz configuration settings default_rviz_config_path = os.path.join(igvc_description_package, 'rviz/rviz_settings.rviz') - - # Set the path to the URDF file default_urdf_model_path = os.path.join(igvc_description_package, 'urdf/robot.urdf.xacro') - - # Set the path to the Publisher launch file publisher_launch_path = os.path.join(igvc_description_package, 'launch/publisher.launch.py') - # Launch configuration variables specific to simulation + declared_arguments.append( + DeclareLaunchArgument( + 'urdf_model', + default_value=default_urdf_model_path, + description='Absolute path to robot urdf file' + ) + ) + declared_arguments.append( + DeclareLaunchArgument( + 'gui', + default_value='True', + description='Flag to enable joint_state_publisher_gui' + ) + ) + declared_arguments.append( + DeclareLaunchArgument( + 'use_robot_state_pub', + default_value='True', + description='Whether to start the robot state publisher' + ) + ) + declared_arguments.append( + DeclareLaunchArgument( + 'use_sim_time', + default_value='True', + description='Use simulation (Gazebo) clock if true' + ) + ) + declared_arguments.append( + DeclareLaunchArgument( + 'rviz_config_file', + default_value=default_rviz_config_path, + description='Full path to the RVIZ config file to use' + ) + ) + declared_arguments.append( + DeclareLaunchArgument( + 'use_rviz', + default_value='true', + description='Whether to start RVIZ' + ) + ) + urdf_model = LaunchConfiguration('urdf_model') + gui = LaunchConfiguration('gui') + use_robot_state_pub = LaunchConfiguration('use_robot_state_pub') + use_sim_time = LaunchConfiguration('use_sim_time') + rviz_config_file = LaunchConfiguration('rviz_config_file') + use_rviz = LaunchConfiguration('use_rviz') + + + + rviz_node = Node( + package='rviz2', + executable='rviz2', + name='rviz2', + condition=IfCondition(use_rviz), + output='screen', + arguments=['-d', rviz_config_file] + ) + Node = [ + rviz_node + ] + return LaunchDescription(declared_arguments + Node) + + + +""" + # Launch configuration variables specific to simulation gui = LaunchConfiguration('gui') urdf_model = LaunchConfiguration('urdf_model') rviz_config_file = LaunchConfiguration('rviz_config_file') @@ -59,7 +120,7 @@ def generate_launch_description(): name='use_sim_time', default_value='True', description='Use simulation (Gazebo) clock if true') - + # Specify the publisher action start_publisher_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource(publisher_launch_path), @@ -70,7 +131,6 @@ def generate_launch_description(): 'use_sim_time' : use_sim_time, }.items() ) - # Launch RViz start_rviz_cmd = Node( condition=IfCondition(use_rviz), @@ -80,7 +140,7 @@ def generate_launch_description(): output='screen', arguments=['-d', rviz_config_file]) - # Create the launch description and populate + # Create the launch description and populate launch_description = LaunchDescription() # Declare the launch options @@ -96,3 +156,4 @@ def generate_launch_description(): launch_description.add_action(start_rviz_cmd) return launch_description +""" \ No newline at end of file diff --git a/src/igvc_gazebo/launch/empty_world.launch.py b/src/igvc_gazebo/launch/empty_world.launch.py index d47892b5..41a730ab 100644 --- a/src/igvc_gazebo/launch/empty_world.launch.py +++ b/src/igvc_gazebo/launch/empty_world.launch.py @@ -1,47 +1,44 @@ import os - from ament_index_python.packages import get_package_share_directory - from launch import LaunchDescription from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration from launch_ros.substitutions import FindPackageShare - from launch_ros.actions import Node def generate_launch_description(): + declared_arguments = [] + igvc_description_package = FindPackageShare(package='igvc_description').find('igvc_description') ros_gz_sim_package = get_package_share_directory('ros_gz_sim') - package_description = FindPackageShare(package='igvc_description').find('igvc_description') - gz_launch_path = os.path.join(ros_gz_sim_package, 'launch', 'gz_sim.launch.py') - world = LaunchConfiguration('world') - - default_world = os.path.join( - get_package_share_directory('igvc_gazebo'), - 'worlds', - 'empty_world.sdf' - ) - - world_arg = DeclareLaunchArgument( - 'world', - default_value=default_world, - description='World to load' + bridge_params = os.path.join(get_package_share_directory('igvc_gazebo'), 'config', 'gz_bridge.yaml') + default_world = os.path.join(get_package_share_directory('igvc_gazebo'), 'worlds','empty_world.sdf') + + declared_arguments.append( + DeclareLaunchArgument( + 'world', + default_value=default_world, + description='World to load' + ) ) - - gazebo = IncludeLaunchDescription( + declared_arguments.append( + DeclareLaunchArgument( + 'gazebo', PythonLaunchDescriptionSource(gz_launch_path), launch_arguments={'gz_args': ['-r -v4 ', world], 'on_exit_shutdown': 'true'}.items() ) + ) - spawn_entity = Node(package='ros_gz_sim', executable='create', + + spawn_entity = Node( + package='ros_gz_sim', executable='create', arguments=['-topic', 'robot_description', '-name', 'igvc_robot'], output='screen' ) - bridge_params = os.path.join(get_package_share_directory('igvc_gazebo'), 'config', 'gz_bridge.yaml') ros_gz_bridge = Node( package="ros_gz_bridge", @@ -52,10 +49,11 @@ def generate_launch_description(): f'config_file:={bridge_params}', ] ) - - return LaunchDescription([ - world_arg, - gazebo, + Node = [ spawn_entity, ros_gz_bridge - ]) + ] + return LaunchDescription(declared_arguments + Node) + + + \ No newline at end of file diff --git a/src/igvc_hardware/launch/control.launch.py b/src/igvc_hardware/launch/control.launch.py index 83a66bed..bf718805 100644 --- a/src/igvc_hardware/launch/control.launch.py +++ b/src/igvc_hardware/launch/control.launch.py @@ -1,78 +1,51 @@ from launch import LaunchDescription -from launch.substitutions import PathJoinSubstitution +from launch.actions import DeclareLaunchArgument +from launch.substitutions import PathJoinSubstitution, LaunchConfiguration from launch_ros.substitutions import FindPackageShare from launch_ros.actions import Node -from launch.substitutions import PathJoinSubstitution, LaunchConfiguration -from launch.event_handlers import OnProcessExit -from launch.actions import DeclareLaunchArgument, RegisterEventHandler - -from launch.conditions import UnlessCondition - def generate_launch_description(): # Declare args declared_arguments = [] - + declared_arguments.append( DeclareLaunchArgument( name="use_sim", default_value="false", - description="Wether or not the robot is launching in simulation" + description="Whether or not the robot is launching in simulation" ) ) - + use_sim = LaunchConfiguration("use_sim") # Get nodes - robot_controllers = PathJoinSubstitution( - [ - FindPackageShare("igvc_hardware"), - "config", - "bot_controllers.yaml", - ] - ) - + robot_controllers = PathJoinSubstitution([ + FindPackageShare("igvc_hardware"), + "config", + "bot_controllers.yaml", + ]) + control_node = Node( package="controller_manager", executable="ros2_control_node", parameters=[ - # TODO in the ODrive botwheel explorer example, the description contents are also passed in here. robot_controllers ], output="both", - condition = UnlessCondition(use_sim) ) robot_controller_spawner = Node( package="controller_manager", executable="spawner", - arguments=["bot_drive_controller", - "--controller-manager", "/controller_manager"], - remappings=[('~/cmd_vel','/cmd_vel')] - - ) - - - joint_state_broadcaster_spawner = Node( - package="controller_manager", - executable="spawner", - arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"], - ) - - - delay_robot_controller_spawner_after_joint_state_broadcaster_spawner = RegisterEventHandler( - event_handler=OnProcessExit( - target_action=joint_state_broadcaster_spawner, - on_exit=[robot_controller_spawner], - ) + arguments=[ + "bot_drive_controller", + "--controller-manager", "/controller_manager" + ], ) - - nodes = [ control_node, - joint_state_broadcaster_spawner, robot_controller_spawner ] - return LaunchDescription(declared_arguments + nodes) + return LaunchDescription(declared_arguments + nodes) \ No newline at end of file diff --git a/src/igvc_nav/launch/igvc_nav.launch.py b/src/igvc_nav/launch/igvc_nav.launch.py index 221c536c..600a059b 100644 --- a/src/igvc_nav/launch/igvc_nav.launch.py +++ b/src/igvc_nav/launch/igvc_nav.launch.py @@ -1,25 +1,32 @@ import os - from ament_index_python.packages import get_package_share_directory - from launch import LaunchDescription from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource def generate_launch_description(): + declared_arguments = [] nav2_bringup_package = get_package_share_directory('nav2_bringup') igvc_nav_package = get_package_share_directory('igvc_nav') - nav2_launch_path = os.path.join(nav2_bringup_package , 'launch', 'navigation_launch.py') config_path = os.path.join(igvc_nav_package, 'config', 'nav2_params.yaml') - + nav2 = IncludeLaunchDescription( PythonLaunchDescriptionSource(nav2_launch_path), launch_arguments={ 'params_file' : config_path }.items() ) + declared_arguments.append( + IncludeLaunchDescription( + PythonLaunchDescriptionSource(nav2_launch_path), + launch_arguments={ + 'params_file' : config_path + }.items() + ) + ) + Nodes = [ + ] - return LaunchDescription([ - nav2 - ]) \ No newline at end of file + return LaunchDescription(declared_arguments + Nodes) + \ No newline at end of file