准备工作
安装webots_ros2软件包
ROS2安装turtlebot3_cartographer包
sudo apt install ros-${ROS_DISTRO}-turtlebot3-cartographer
或者源码编译
source /opt/ros/${ROS_DISTRO}/local_setup.bash
# Retrieve the sources
cd /path/to/ros2_ws
git clone -b ${ROS_DISTRO}-devel https://github.com/ROBOTIS-GIT/turtlebot3.git src/turtlebot3
# Check dependencies
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO}
# Building packages
colcon build --packages-up-to turtlebot3_navigation2
source install/local_setup.bash
运行SLAM
打开一个终端
ros2 launch webots_ros2_turtlebot robot_launch.py
打开另一个终端
ros2 launch turtlebot3_cartographer cartographer.launch.py \
use_sim_time:=true
Git地址
https://github.com/cyberbotics/webots_ros2/wiki/SLAM-with-TurtleBot3