97 lines
3.7 KiB
Python
97 lines
3.7 KiB
Python
|
# Copyright 2019 Open Source Robotics Foundation, Inc.
|
||
|
#
|
||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
# you may not use this file except in compliance with the License.
|
||
|
# You may obtain a copy of the License at
|
||
|
#
|
||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||
|
#
|
||
|
# Unless required by applicable law or agreed to in writing, software
|
||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
# See the License for the specific language governing permissions and
|
||
|
# limitations under the License.
|
||
|
#
|
||
|
# Author: Darby Lim
|
||
|
|
||
|
import os
|
||
|
|
||
|
from ament_index_python.packages import get_package_share_directory
|
||
|
from launch import LaunchDescription
|
||
|
from launch.actions import DeclareLaunchArgument
|
||
|
from launch.actions import IncludeLaunchDescription
|
||
|
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||
|
from launch.substitutions import LaunchConfiguration
|
||
|
from launch.substitutions import ThisLaunchFileDir
|
||
|
from launch_ros.actions import Node
|
||
|
|
||
|
|
||
|
def generate_launch_description():
|
||
|
use_sim_time = LaunchConfiguration('use_sim_time', default='true')
|
||
|
prefix = get_package_share_directory('gz_quadruped_playground')
|
||
|
cartographer_config_dir = LaunchConfiguration('cartographer_config_dir', default=os.path.join(
|
||
|
prefix, 'config', 'cartographer'))
|
||
|
configuration_basename = LaunchConfiguration('configuration_basename',
|
||
|
default='cartographer.lua')
|
||
|
|
||
|
resolution = LaunchConfiguration('resolution', default='0.05')
|
||
|
publish_period_sec = LaunchConfiguration('publish_period_sec', default='1.0')
|
||
|
|
||
|
rviz_config_dir = os.path.join(prefix, 'config', 'cartographer', 'cartographer.rviz')
|
||
|
|
||
|
return LaunchDescription([
|
||
|
DeclareLaunchArgument(
|
||
|
'cartographer_config_dir',
|
||
|
default_value=cartographer_config_dir,
|
||
|
description='Full path to config file to load'),
|
||
|
DeclareLaunchArgument(
|
||
|
'configuration_basename',
|
||
|
default_value=configuration_basename,
|
||
|
description='Name of lua file for cartographer'),
|
||
|
DeclareLaunchArgument(
|
||
|
'use_sim_time',
|
||
|
default_value='true',
|
||
|
description='Use simulation (Gazebo) clock if true'),
|
||
|
|
||
|
Node(
|
||
|
package='cartographer_ros',
|
||
|
executable='cartographer_node',
|
||
|
name='cartographer_node',
|
||
|
output='screen',
|
||
|
parameters=[{'use_sim_time': use_sim_time}],
|
||
|
arguments=['-configuration_directory', cartographer_config_dir,
|
||
|
'-configuration_basename', configuration_basename],
|
||
|
remappings=[
|
||
|
('/points2', '/scan/points'),
|
||
|
# ('/points2_2', '/rgbd_d435/points'),
|
||
|
('/imu', '/imu_sensor_broadcaster/imu'),
|
||
|
]
|
||
|
),
|
||
|
|
||
|
DeclareLaunchArgument(
|
||
|
'resolution',
|
||
|
default_value=resolution,
|
||
|
description='Resolution of a grid cell in the published occupancy grid'),
|
||
|
|
||
|
DeclareLaunchArgument(
|
||
|
'publish_period_sec',
|
||
|
default_value=publish_period_sec,
|
||
|
description='OccupancyGrid publishing period'),
|
||
|
|
||
|
Node(
|
||
|
package='cartographer_ros',
|
||
|
executable='cartographer_occupancy_grid_node',
|
||
|
name='cartographer_occupancy_grid_node',
|
||
|
output='screen',
|
||
|
parameters=[{'use_sim_time': use_sim_time}],
|
||
|
arguments=['-resolution', resolution, '-publish_period_sec', publish_period_sec]),
|
||
|
|
||
|
Node(
|
||
|
package='rviz2',
|
||
|
executable='rviz2',
|
||
|
name='rviz2',
|
||
|
arguments=['-d', rviz_config_dir],
|
||
|
parameters=[{'use_sim_time': use_sim_time}]
|
||
|
),
|
||
|
])
|