50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
|
import os
|
||
|
|
||
|
from launch import LaunchDescription
|
||
|
from launch.actions import DeclareLaunchArgument
|
||
|
from launch.substitutions import LaunchConfiguration
|
||
|
from launch_ros.actions import Node
|
||
|
from ament_index_python.packages import get_package_share_directory
|
||
|
|
||
|
|
||
|
def generate_launch_description():
|
||
|
use_sim_time = LaunchConfiguration("use_sim_time")
|
||
|
slam_params_file = LaunchConfiguration("slam_params_file")
|
||
|
|
||
|
remappings = [
|
||
|
("/map", "map"),
|
||
|
("/scan", "scan"),
|
||
|
("/tf", "tf"),
|
||
|
("/tf_static", "tf_static"),
|
||
|
]
|
||
|
|
||
|
declare_use_sim_time_argument = DeclareLaunchArgument(
|
||
|
"use_sim_time", default_value="true", description="Use simulation/Gazebo clock"
|
||
|
)
|
||
|
declare_slam_params_file_cmd = DeclareLaunchArgument(
|
||
|
"slam_params_file",
|
||
|
default_value=os.path.join(
|
||
|
get_package_share_directory("slam_toolbox"),
|
||
|
"config",
|
||
|
"mapper_params_online_sync.yaml",
|
||
|
),
|
||
|
description="Full path to the ROS2 parameters file to use for the slam_toolbox node",
|
||
|
)
|
||
|
|
||
|
start_sync_slam_toolbox_node = Node(
|
||
|
parameters=[slam_params_file, {"use_sim_time": use_sim_time}],
|
||
|
package="slam_toolbox",
|
||
|
executable="sync_slam_toolbox_node",
|
||
|
name="slam_toolbox",
|
||
|
output="screen",
|
||
|
remappings=remappings,
|
||
|
)
|
||
|
|
||
|
ld = LaunchDescription()
|
||
|
|
||
|
ld.add_action(declare_use_sim_time_argument)
|
||
|
ld.add_action(declare_slam_params_file_cmd)
|
||
|
ld.add_action(start_sync_slam_toolbox_node)
|
||
|
|
||
|
return ld
|