mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 16:57:46 +08:00
* Updating examples and README * updated main readme * odom: Added always_check_imu_tf parameter. sync: increased default sync_queue_size from 2 to 5 (to be more flexible to different hardware), added input and output diagnostics. rtabmap_viz: fixed node with same name redeclared warning. * update readme * Added husky demo * converted demo_robot_mapping.launch to ros2 * Converted stereo_outdoor demo from ros1 to ros2 * Converted multi-session demo to ros2 * Converted demo_find_object launch to ros2 * renamed files * uniformized default qos, increased sync_queue_size default to 10 * Added vlp16 + imu example * Added husky 3D lidar demos * moved demos in subdir * Added vlp16+zed example * rtabmap_viz: ignore odom update if tf not ready when not using topic (to avoid showing red screen). Added champ VSLAM demo. * forwarded camera_model arg for zed examples, removed qos for turtlebot4 demo * pointcloud_to_depthimage: added more error logs, removed output camera_info published twice and match ros1 namespaces * Created two base general examples for 3D lidar usage, then create hardware specific examples on top of them. * Added isaac sim demo * Final update of all demos. Fixed MapCloud rviz plugin crashing when floor/ceiling filtering is used and resulting cloud is empty. * Fixed 2d scan deskewing output frame, moved nav2 params under "params" folder, added number of topics processed/dropped for odometry, added icp_odometry option for turtlebot3 scan-only demo. * rtabmap_demos: added README with examples * Added TOC * bump version to 0.21.9
162 lines
5.5 KiB
Python
162 lines
5.5 KiB
Python
# Requirements:
|
|
# Install Turtlebot3 packages
|
|
# Modify turtlebot3_waffle SDF:
|
|
# 1) Edit /opt/ros/$ROS_DISTRO/share/turtlebot3_gazebo/models/turtlebot3_waffle/model.sdf
|
|
# 2) We can increase min scan range from 0.12 to 0.2 to avoid having scans
|
|
# hitting the robot itself
|
|
#
|
|
# Example:
|
|
# $ ros2 launch rtabmap_demos turtlebot3_sim_scan_demo.launch.py
|
|
#
|
|
# Teleop:
|
|
# $ ros2 run turtlebot3_teleop teleop_keyboard
|
|
|
|
from ament_index_python.packages import get_package_share_directory
|
|
|
|
from launch import LaunchDescription
|
|
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction
|
|
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
|
|
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
|
from launch_ros.substitutions import FindPackageShare
|
|
|
|
import os
|
|
|
|
def launch_setup(context, *args, **kwargs):
|
|
if not 'TURTLEBOT3_MODEL' in os.environ:
|
|
os.environ['TURTLEBOT3_MODEL'] = 'waffle'
|
|
|
|
# Directories
|
|
pkg_nav2_bringup = get_package_share_directory(
|
|
'nav2_bringup')
|
|
pkg_rtabmap_demos = get_package_share_directory(
|
|
'rtabmap_demos')
|
|
|
|
world_name = LaunchConfiguration('world').perform(context)
|
|
|
|
icp_odometry = LaunchConfiguration('icp_odometry').perform(context)
|
|
icp_odometry = icp_odometry == 'True' or icp_odometry == 'true'
|
|
if icp_odometry:
|
|
# modified nav2 params to use icp_odom instead odom frame
|
|
nav2_params_file = PathJoinSubstitution(
|
|
[FindPackageShare('rtabmap_demos'), 'params', 'turtlebot3_scan_nav2_params.yaml']
|
|
)
|
|
else:
|
|
# original nav2 params
|
|
nav2_params_file = PathJoinSubstitution(
|
|
[FindPackageShare('nav2_bringup'), 'params', 'nav2_params.yaml']
|
|
)
|
|
|
|
# Paths
|
|
nav2_launch = PathJoinSubstitution(
|
|
[pkg_nav2_bringup, 'launch', 'navigation_launch.py'])
|
|
rviz_launch = PathJoinSubstitution(
|
|
[pkg_nav2_bringup, 'launch', 'rviz_launch.py'])
|
|
rtabmap_launch = PathJoinSubstitution(
|
|
[pkg_rtabmap_demos, 'launch', 'turtlebot3', 'turtlebot3_scan.launch.py'])
|
|
|
|
# To use ICP odometry, we should increase clock rate of gazebo, we copied content of
|
|
# turtlebot3_gazebo/launch/turtlebot3_world.launch here
|
|
launch_file_dir = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'launch')
|
|
pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
|
|
|
|
world = os.path.join(
|
|
get_package_share_directory('turtlebot3_gazebo'),
|
|
'worlds',
|
|
f'turtlebot3_{world_name}.world'
|
|
)
|
|
|
|
import tempfile
|
|
with tempfile.NamedTemporaryFile(mode='w+t', delete=False) as clock_override_file:
|
|
clock_override_file.write("---\n"+
|
|
"gazebo:\n"+
|
|
" ros__parameters:\n"+
|
|
" publish_rate: 100.0")
|
|
|
|
gzserver_cmd = IncludeLaunchDescription(
|
|
PythonLaunchDescriptionSource(
|
|
os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')
|
|
),
|
|
launch_arguments={
|
|
'world': world,
|
|
'params_file': clock_override_file.name}.items()
|
|
)
|
|
|
|
gzclient_cmd = IncludeLaunchDescription(
|
|
PythonLaunchDescriptionSource(
|
|
os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py')
|
|
)
|
|
)
|
|
|
|
robot_state_publisher_cmd = IncludeLaunchDescription(
|
|
PythonLaunchDescriptionSource(
|
|
os.path.join(launch_file_dir, 'robot_state_publisher.launch.py')
|
|
),
|
|
launch_arguments={'use_sim_time': 'true'}.items()
|
|
)
|
|
|
|
spawn_turtlebot_cmd = IncludeLaunchDescription(
|
|
PythonLaunchDescriptionSource(
|
|
os.path.join(launch_file_dir, 'spawn_turtlebot3.launch.py')
|
|
),
|
|
launch_arguments={
|
|
'x_pose': LaunchConfiguration('x_pose'),
|
|
'y_pose': LaunchConfiguration('y_pose')
|
|
}.items()
|
|
)
|
|
|
|
nav2 = IncludeLaunchDescription(
|
|
PythonLaunchDescriptionSource([nav2_launch]),
|
|
launch_arguments=[
|
|
('use_sim_time', 'true'),
|
|
('params_file', nav2_params_file)
|
|
]
|
|
)
|
|
rviz = IncludeLaunchDescription(
|
|
PythonLaunchDescriptionSource([rviz_launch])
|
|
)
|
|
rtabmap = IncludeLaunchDescription(
|
|
PythonLaunchDescriptionSource([rtabmap_launch]),
|
|
launch_arguments=[
|
|
('localization', LaunchConfiguration('localization')),
|
|
('use_sim_time', 'true')
|
|
]
|
|
)
|
|
return [
|
|
# Nodes to launch
|
|
nav2,
|
|
rviz,
|
|
rtabmap,
|
|
gzserver_cmd,
|
|
gzclient_cmd,
|
|
robot_state_publisher_cmd,
|
|
spawn_turtlebot_cmd
|
|
]
|
|
|
|
def generate_launch_description():
|
|
return LaunchDescription([
|
|
|
|
# Launch arguments
|
|
DeclareLaunchArgument(
|
|
'localization', default_value='false',
|
|
description='Launch in localization mode.'),
|
|
|
|
DeclareLaunchArgument(
|
|
'world', default_value='world',
|
|
choices=['world', 'house', 'dqn_stage1', 'dqn_stage2', 'dqn_stage3', 'dqn_stage4'],
|
|
description='Turtlebot3 gazebo world.'),
|
|
|
|
DeclareLaunchArgument(
|
|
'icp_odometry', default_value='false',
|
|
description='Launch ICP odometry on top of wheel odometry.'),
|
|
|
|
DeclareLaunchArgument(
|
|
'x_pose', default_value='-2.0',
|
|
description='Initial position of the robot in the simulator.'),
|
|
|
|
DeclareLaunchArgument(
|
|
'y_pose', default_value='0.5',
|
|
description='Initial position of the robot in the simulator.'),
|
|
|
|
OpaqueFunction(function=launch_setup)
|
|
])
|