2020-01-30 17:18:48 -05:00
|
|
|
# Example:
|
2024-11-30 17:28:16 -08:00
|
|
|
#
|
|
|
|
|
# Bringup turtlebot3:
|
|
|
|
|
# $ export TURTLEBOT3_MODEL=waffle
|
|
|
|
|
# $ export LDS_MODEL=LDS-01
|
|
|
|
|
# $ ros2 launch turtlebot3_bringup robot.launch.py
|
2021-10-01 18:48:45 -04:00
|
|
|
#
|
2022-01-15 20:18:12 -05:00
|
|
|
# SLAM:
|
2024-11-30 17:28:16 -08:00
|
|
|
# $ ros2 launch rtabmap_demos turtlebot3_rgbd.launch.py
|
2022-01-15 20:18:12 -05:00
|
|
|
#
|
|
|
|
|
# Navigation (install nav2_bringup package):
|
2024-11-30 17:28:16 -08:00
|
|
|
# $ ros2 launch nav2_bringup navigation_launch.py
|
2022-01-15 20:18:12 -05:00
|
|
|
# $ 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')
|
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,
|
|
|
|
|
'Reg/Force3DoF':'true',
|
2024-11-30 17:28:16 -08:00
|
|
|
'Grid/RayTracing':'true', # Fill empty space
|
|
|
|
|
'Grid/3D':'false', # Use 2D occupancy
|
|
|
|
|
'Grid/RangeMax':'3',
|
|
|
|
|
'Grid/NormalsSegmentation':'false', # Use passthrough filter to detect obstacles
|
|
|
|
|
'Grid/MaxGroundHeight':'0.05', # All points above 5 cm are obstacles
|
|
|
|
|
'Grid/MaxObstacleHeight':'0.4', # All points over 1 meter are ignored
|
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=[
|
2022-01-29 18:01:08 -05:00
|
|
|
('rgb/image', '/camera/image_raw'),
|
|
|
|
|
('rgb/camera_info', '/camera/camera_info'),
|
|
|
|
|
('depth/image', '/camera/depth/image_raw')]
|
2020-01-30 17:18:48 -05:00
|
|
|
|
|
|
|
|
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
|
|
|
|
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),
|
2023-02-26 18:05:08 -08:00
|
|
|
package='rtabmap_slam', 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),
|
2023-02-26 18:05:08 -08:00
|
|
|
package='rtabmap_slam', executable='rtabmap', output='screen',
|
2022-01-15 20:18:12 -05:00
|
|
|
parameters=[parameters,
|
|
|
|
|
{'Mem/IncrementalMemory':'False',
|
|
|
|
|
'Mem/InitWMWithAllNodes':'True'}],
|
|
|
|
|
remappings=remappings),
|
2020-01-30 17:18:48 -05:00
|
|
|
|
|
|
|
|
Node(
|
2023-02-26 18:05:08 -08:00
|
|
|
package='rtabmap_viz', executable='rtabmap_viz', output='screen',
|
2022-01-15 20:18:12 -05:00
|
|
|
parameters=[parameters],
|
2020-01-30 17:18:48 -05:00
|
|
|
remappings=remappings),
|
2024-11-30 17:28:16 -08:00
|
|
|
|
|
|
|
|
# Obstacle detection with the camera for nav2 local costmap.
|
|
|
|
|
# First, we need to convert depth image to a point cloud.
|
|
|
|
|
# Second, we segment the floor from the obstacles.
|
|
|
|
|
Node(
|
|
|
|
|
package='rtabmap_util', executable='point_cloud_xyz', output='screen',
|
|
|
|
|
parameters=[{'decimation': 2,
|
|
|
|
|
'max_depth': 3.0,
|
|
|
|
|
'voxel_size': 0.02}],
|
|
|
|
|
remappings=[('depth/image', '/camera/depth/image_raw'),
|
|
|
|
|
('depth/camera_info', '/camera/camera_info'),
|
|
|
|
|
('cloud', '/camera/cloud')]),
|
|
|
|
|
Node(
|
|
|
|
|
package='rtabmap_util', executable='obstacles_detection', output='screen',
|
|
|
|
|
parameters=[parameters],
|
|
|
|
|
remappings=[('cloud', '/camera/cloud'),
|
|
|
|
|
('obstacles', '/camera/obstacles'),
|
|
|
|
|
('ground', '/camera/ground')]),
|
2020-01-30 17:18:48 -05:00
|
|
|
])
|