ROS2 turtlebot3 使用 gazebo 建图并在 rviz 中显示
·
更多细节请查看
https://emanual.robotis.com/docs/en/platform/turtlebot3/quick-start/#pc-setup
0、先拉取代码和配置环境变量
sudo apt install ros-humble-gazebo-*
sudo apt install ros-humble-cartographer
sudo apt install ros-humble-cartographer-ros
sudo apt install ros-humble-navigation2
sudo apt install ros-humble-nav2-bringup
mkdir turtlebot3_ws/src
cd ~/turtlebot3_ws/src/
$ git clone -b humble https://github.com/ROBOTIS-GIT/DynamixelSDK.git
$ git clone -b humble https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
$ git clone -b humble https://github.com/ROBOTIS-GIT/turtlebot3.git
sudo apt install python3-colcon-common-extensions
cd ~/turtlebot3_ws
$ colcon build --symlink-install
echo 'source ~/turtlebot3_ws/install/setup.bash' >> ~/.bashrc
echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc
echo 'source /usr/share/gazebo/setup.sh' >> ~/.bashrc
echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc
source ~/.bashrc
1、启动 gazebo 加载机器人模型和地图
ros2 launch turtlebot3_gazebo turtlebot3_house.launch.py
# 或者下面这个
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
2、启动 rviz
# 开启 cartographer 建图并打开 rviz
ros2 launch turtlebot3_cartographer cartographer.launch.py use_sim_time:=True
# 或者只打开 rviz,自行启动建图算法
ros2 launch turtlebot3_bringup rviz2.launch.py
3、使用键盘控制 gazebo 中的机器人到处走,完成建图
ros2 run turtlebot3_teleop teleop_keyboard
#如果懒的话也可以使用下面的命令,小车会自己乱走
ros2 run turtlebot3_gazebo turtlebot3_drive
4、在 rviz 中保存配置,并且在命令行中保存地图
ros2 run nav2_map_server map_saver_cli -f ~/map
更多推荐


所有评论(0)