赞
踩
# 环境
Ubuntu 20.04
ROS2 Foxy
# 查看本机是否已经安装 turtlrbot3 ros2 pkg list | grep turtlebot3 # You will get # turtlebot3 # turtlebot3_bringup # turtlebot3_cartographer # turtlebot3_description # turtlebot3_example # turtlebot3_gazebo # turtlebot3_msgs # turtlebot3_navigation2 # turtlebot3_node # turtlebot3_teleop # 安装 turtlrbot3 sudo apt install ros-foxy-turtlebot3 -y sudo apt install ros-foxy-gazebo-dev -y
# 查看本机是否已经安装 cartographer
ros2 pkg list |grep cartographer
# You will get
# cartographer_ros
# cartographer_ros_msgs
# 安装 cartographer
sudo apt install ros-foxy-cartographer -y
打开新终端
source /opt/ros/foxy/setup.zsh
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_cartographer cartographer.launch.py use_sim_time:=True
打开新终端
source /opt/ros/foxy/setup.zsh
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:`ros2 pkg prefix turtlebot3_gazebo`/share/turtlebot3_gazebo/models/
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
打开新终端
source /opt/ros/foxy/setup.zsh
export TURTLEBOT3_MODEL=burger
ros2 run turtlebot3_teleop teleop_keyboard
使用键盘控制小车运动, 扫描地图数据
打开新终端
source /opt/ros/foxy/setup.zsh
mkdir ~/cartographer
ros2 run nav2_map_server map_saver_cli -f ~/cartographer/map
生成地图文件:
~/cartographer/map.pgm
~/cartographer/map.yaml
image: ~/cartographer/map.pgm
mode: trinary
resolution: 0.05
origin: [-1.31, -2.48, 0]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.25%
根据已有的地图进行导航
关闭上面的窗口
打开新终端
source /opt/ros/foxy/setup.zsh
export TURTLEBOT3_MODEL=burger
// 注意 #2.4 生成的地图文件路径
cd ~/cartographer
ros2 launch turtlebot3_navigation2 navigation2.launch.py map:=map.yaml
打开新终端
source /opt/ros/foxy/setup.zsh
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:`ros2 pkg prefix turtlebot3_gazebo`/share/turtlebot3_gazebo/models/
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
紫红色的线就是规划路径
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。