2020-01-30 17:18:48 -05:00
|
|
|
# Requirements:
|
|
|
|
|
# Install Turtlebot3 packages
|
|
|
|
|
# Install https://github.com/mlherd/ros2_turtlebot3_waffle_intel_realsense
|
|
|
|
|
# Example:
|
2021-10-04 19:29:19 -04:00
|
|
|
# $ export TURTLEBOT3_MODEL=waffle
|
2020-01-30 17:18:48 -05:00
|
|
|
# $ ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
|
2021-10-01 18:48:45 -04:00
|
|
|
#
|
2022-01-15 20:18:12 -05:00
|
|
|
# SLAM:
|
2020-01-30 17:18:48 -05:00
|
|
|
# $ ros2 launch rtabmap_ros turtlebot3_rgbd.launch.py
|
2021-10-01 18:48:45 -04:00
|
|
|
# OR
|
|
|
|
|
# $ ros2 launch rtabmap_ros rtabmap.launch.py visual_odometry:=false frame_id:=base_footprint odom_topic:=/odom args:="-d" use_sim_time:=true rgb_topic:=/intel_realsense_r200_depth/image_raw depth_topic:=/intel_realsense_r200_depth/depth/image_raw camera_info_topic:=/intel_realsense_r200_depth/camera_info approx_sync:=true
|
2022-01-15 20:18:12 -05:00
|
|
|
#
|
|
|
|
|
# Navigation (install nav2_bringup package):
|
|
|
|
|
# $ ros2 launch rtabmap_ros nav2_bringup_launch.py use_sim_time:=True
|
|
|
|
|
# $ ros2 launch nav2_bringup rviz_launch.py
|
|
|
|
|
#
|
|
|
|
|
# Teleop:
|
|
|
|
|
# $ ros2 run turtlebot3_teleop teleop_keyboard
|
2020-01-30 17:18:48 -05:00
|
|
|
|
|
|
|
|
from launch import LaunchDescription
|
|
|
|
|
from launch.actions import DeclareLaunchArgument, SetEnvironmentVariable
|
|
|
|
|
from launch.substitutions import LaunchConfiguration
|
2022-01-15 20:18:12 -05:00
|
|
|
from launch.conditions import IfCondition, UnlessCondition
|
2020-10-16 18:02:08 +03:00
|
|
|
from launch_ros.actions import Node
|
2020-01-30 17:18:48 -05:00
|
|
|
|
|
|
|
|
def generate_launch_description():
|
|
|
|
|
|
|
|
|
|
use_sim_time = LaunchConfiguration('use_sim_time')
|
2021-11-08 18:36:19 -05:00
|
|
|
qos = LaunchConfiguration('qos')
|
2022-01-15 20:18:12 -05:00
|
|
|
localization = LaunchConfiguration('localization')
|
2020-01-30 17:18:48 -05:00
|
|
|
|
2022-01-15 20:18:12 -05:00
|
|
|
parameters={
|
2020-01-30 17:18:48 -05:00
|
|
|
'frame_id':'base_footprint',
|
|
|
|
|
'use_sim_time':use_sim_time,
|
2021-10-05 18:01:30 -04:00
|
|
|
'subscribe_depth':True,
|
2022-01-15 20:18:12 -05:00
|
|
|
'use_action_for_goal':True,
|
2021-11-08 18:36:19 -05:00
|
|
|
'qos_image':qos,
|
|
|
|
|
'qos_imu':qos,
|
2022-01-15 20:18:12 -05:00
|
|
|
'Reg/Force3DoF':'true',
|
2021-10-05 18:01:30 -04:00
|
|
|
'Optimizer/GravitySigma':'0' # Disable imu constraints (we are already in 2D)
|
2022-01-15 20:18:12 -05:00
|
|
|
}
|
2020-01-30 17:18:48 -05:00
|
|
|
|
|
|
|
|
remappings=[
|
|
|
|
|
('rgb/image', '/intel_realsense_r200_depth/image_raw'),
|
|
|
|
|
('rgb/camera_info', '/intel_realsense_r200_depth/camera_info'),
|
|
|
|
|
('depth/image', '/intel_realsense_r200_depth/depth/image_raw')]
|
|
|
|
|
|
|
|
|
|
return LaunchDescription([
|
|
|
|
|
|
|
|
|
|
# Launch arguments
|
|
|
|
|
DeclareLaunchArgument(
|
|
|
|
|
'use_sim_time', default_value='true',
|
|
|
|
|
description='Use simulation (Gazebo) clock if true'),
|
2021-11-08 18:36:19 -05:00
|
|
|
|
|
|
|
|
DeclareLaunchArgument(
|
|
|
|
|
'qos', default_value='2',
|
|
|
|
|
description='QoS used for input sensor topics'),
|
2022-01-15 20:18:12 -05:00
|
|
|
|
|
|
|
|
DeclareLaunchArgument(
|
|
|
|
|
'localization', default_value='false',
|
|
|
|
|
description='Launch in localization mode.'),
|
2020-01-30 17:18:48 -05:00
|
|
|
|
|
|
|
|
# Nodes to launch
|
2022-01-15 20:18:12 -05:00
|
|
|
|
|
|
|
|
# SLAM mode:
|
2020-01-30 17:18:48 -05:00
|
|
|
Node(
|
2022-01-15 20:18:12 -05:00
|
|
|
condition=UnlessCondition(localization),
|
2021-07-13 09:05:07 +02:00
|
|
|
package='rtabmap_ros', executable='rtabmap', output='screen',
|
2022-01-15 20:18:12 -05:00
|
|
|
parameters=[parameters],
|
2020-01-30 17:18:48 -05:00
|
|
|
remappings=remappings,
|
2022-01-15 20:18:12 -05:00
|
|
|
arguments=['-d']), # This will delete the previous database (~/.ros/rtabmap.db)
|
|
|
|
|
|
|
|
|
|
# Localization mode:
|
|
|
|
|
Node(
|
|
|
|
|
condition=IfCondition(localization),
|
|
|
|
|
package='rtabmap_ros', executable='rtabmap', output='screen',
|
|
|
|
|
parameters=[parameters,
|
|
|
|
|
{'Mem/IncrementalMemory':'False',
|
|
|
|
|
'Mem/InitWMWithAllNodes':'True'}],
|
|
|
|
|
remappings=remappings),
|
2020-01-30 17:18:48 -05:00
|
|
|
|
|
|
|
|
Node(
|
2021-07-13 09:05:07 +02:00
|
|
|
package='rtabmap_ros', executable='rtabmapviz', output='screen',
|
2022-01-15 20:18:12 -05:00
|
|
|
parameters=[parameters],
|
2020-01-30 17:18:48 -05:00
|
|
|
remappings=remappings),
|
|
|
|
|
])
|