Skip to content

Commit

Permalink
create generic launch_world ros2 file
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Dec 22, 2024
1 parent 1f6069a commit 03b7955
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ if (BUILD_FOR_ROS)
definitions
mvsim_tutorial
models
launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

Expand Down
75 changes: 75 additions & 0 deletions launch/launch_world.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Generic ROS2 launch file

from launch import LaunchDescription
from launch.substitutions import TextSubstitution
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
import os


def generate_launch_description():

# args that can be set from the command line or a default will be used
world_file_launch_arg = DeclareLaunchArgument(
"world_file", description='Path to the *.world.xml file to load')

headless_launch_arg = DeclareLaunchArgument(
"headless", default_value='False')

do_fake_localization_arg = DeclareLaunchArgument(
"do_fake_localization", default_value='True', description='publish fake identity tf "map" -> "odom"')

publish_tf_odom2baselink_arg = DeclareLaunchArgument(
"publish_tf_odom2baselink", default_value='True', description='publish tf "odom" -> "base_link"')

force_publish_vehicle_namespace_arg = DeclareLaunchArgument(
"force_publish_vehicle_namespace", default_value='False',
description='Use vehicle name namespace even if there is only one vehicle')

use_rviz_arg = DeclareLaunchArgument(
'use_rviz', default_value='True',
description='Whether to launch RViz2'
)

rviz_config_file_arg = DeclareLaunchArgument(
'rviz_config_file', default_value='',
description='If use_rviz:="True", the configuration file for rviz'
)

mvsim_node = Node(
package='mvsim',
executable='mvsim_node',
name='mvsim',
output='screen',
parameters=[
{
"world_file": LaunchConfiguration('world_file'),
"headless": LaunchConfiguration('headless'),
"do_fake_localization": LaunchConfiguration('do_fake_localization'),
"publish_tf_odom2baselink": LaunchConfiguration('publish_tf_odom2baselink'),
"force_publish_vehicle_namespace": LaunchConfiguration('force_publish_vehicle_namespace'),
}]
)

rviz2_node = Node(
condition=IfCondition(LaunchConfiguration('use_rviz')),
package='rviz2',
executable='rviz2',
name='rviz2',
arguments=[] if LaunchConfiguration('rviz_config_file') == '' else [
'-d', LaunchConfiguration('rviz_config_file')]
)

return LaunchDescription([
world_file_launch_arg,
headless_launch_arg,
do_fake_localization_arg,
publish_tf_odom2baselink_arg,
force_publish_vehicle_namespace_arg,
use_rviz_arg,
rviz_config_file_arg,
mvsim_node,
rviz2_node
])

0 comments on commit 03b7955

Please sign in to comment.