系统ubuntu-22.04.4 ,ros2版本ros-humble-desktop
安装gazebo
安装gazebo
sudo apt install gazebo
安装ROS2的两轮差速功能包
sudo apt install ros-humble-gazebo-*
键盘控制工具
sudo apt install ros-humble-teleop-twist-keyboard
键盘控制工具启动
ros2 run teleop_twist_keyboard teleop_twist_keyboard
安装 Cartographer
sudo apt install ros-humble-cartographer
sudo apt install ros-humble-cartographer-ros
安装 Navigation2
sudo apt install ros-humble-navigation2
sudo apt install ros-humble-nav2-bringup
安装 TurtleBot3
source ~/.bashrc
sudo apt install ros-humble-dynamixel-sdk
sudo apt install ros-humble-turtlebot3-msgs
sudo apt install ros-humble-turtlebot3
sudo apt install ros-humble-turtlebot3-gazebo
环境配置
echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc
source ~/.bashrc
设置环境变量
source /opt/ros/humble/setup.bash
export TURTLEBOT3_MODEL=waffle
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/humble/share/turtlebot3_gazebo/models
一劳永逸 配置TurtleBot3仿真环境:打开终端
sudo gedit .bashrc
在最后一行部分加入下面两段代码
export TURTLEBOT3_MODEL=waffle
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/humble/share/turtlebot3_gazebo/models
保存退出
source .bashrc
在终端中输入以下ros2命令
ros2 launch nav2_bringup tb3_simulation_launch.py headless:=False
注意:多等一会儿,等待了四五分钟之后Gazebo确实成功打开了,等待过程中最好不要进行其他影响此进程的操作。
RVIZ和Gazebo都将成功打开后,需要我们手动确定机器人当前位置,点击RVIZ页面上方的“2D Pose Estimate”,然后用鼠标光标确定大致位置即可。