持续创作,加速成长!这是我参与「掘金日新计划 · 6 月更文挑战」的第26天,点击查看活动详情
使用nav2控制turltebot3建图,导航。
1.1安装turtlebot3
sudo apt install ros-foxy-turtlebot3*
sudo apt install ros-foxy-cartographer
1.2建图
1.2.1 配置
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:`ros2 pkg \
prefix turtlebot3_gazebo \
`/share/turtlebot3_gazebo/models/
1.2.2 启动建图
分别打开三个终端 终端1启动gazebo仿真
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
终端2启动建图
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_cartographer cartographer.launch.py use_sim_time:=True
终端3启动键盘控制节点
export TURTLEBOT3_MODEL=burger
ros2 run turtlebot3_teleop teleop_keyboard
1.2.3.保存地图
ros2 run nav2_map_server map_saver_cli -f my_map
1.3 导航
关闭或者退出上面三个窗口
1.3.1 重新启动gazebo仿真
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
1.3.2 启动导航launch文件
这里注意要指向刚刚的map地图位置才行
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_navigation2 navigation2.launch.py \
use_sim_time:=true map:="you map address".yaml
1.3.3初始化机器人的位置
1.3.4 给定目标点动起来
2 结果(Result) 控制turtlebot完成建图,turtlebot导航时还不能到达目标点。
Gazebo仿真环境使用Cartographer算法建图
1.cartographer环境配置,并运行demo
2.下载turtlebot3,并编译
cd ~/catkin_make/src
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ..
catkin_make
3.设置环境变量
echo "export TURTLEBOT3_MODEL=burger" >> ~/.bashrc
source ~/.bashrc
4.修改launch文件
catkin_ws/src/turtlebot3/turtlebot3_slam/launch/turtlebot3_cartographer.launch文件
把$(arg configuration_basename)更改为turtlebot3_lds_2d_gazebo.lua
5.打开Gazebo仿真环境
roslaunch turtlebot3_gazebo turtlebot3_world.launch
6.使用cartographer算法建图
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer
7.使用键盘控制Turtlebot3运动
8.保存地图
rosrun map_server map_saver -f ~/map