ubuntu 20.04源码编译安装ros2 gazebo及turtlebot3

发布时间 2023-09-11 09:57:52作者: 泡泡吐泡泡啊

ros2 gazebo

安装gazebo11

sudo apt-get install gazebo11
gazebo -version // 验证gazebo

安装gazebo_ros_pkgs

mkdir -p ~/ros2_gazebo_ws/src
cd ~/ros2_gazebo_ws
wget https://raw.githubusercontent.com/ros-simulation/gazebo_ros_pkgs/ros2/gazebo_ros_pkgs.repos
// 显示全是 . 代表成功,E为失败
vcs import src < gazebo_ros_pkgs.repos
// gazebo_ros_pkgs只有ros2分支,vision_opencv有humble分支
vcs custom --args checkout humble 
// 安装依赖
rosdep install --from-paths src --ignore-src -r -y
// 编译源码
colcon build --symlink-install
// ros2 gazebo环境
echo " source ~/ros2_gazebo_ws/install/setup.bash" >> ~/.bashrc

ros2 turtlebot3

安装turtlebot3

mkdir -p ~/ros2_turtlebot3_ws/src
cd ~/ros2_turtlebot3_ws
wget https://raw.githubusercontent.com/ROBOTIS-GIT/turtlebot3/ros2/turtlebot3.repos
// 显示全是 . 代表成功,E为失败
vcs import src < turtlebot3.repos
sudo apt-get install libudev-dev // 编译错误,根据需要安装
colcon build --symlink-install
echo " source ~/ros2_turtlebot3_ws/install/setup.bash" >> ~/.bashrc
// 设置GAZEBO_MODEL_PATH变量
echo 'export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/ros2_turtlebot3_ws/src/turtlebot3/turtlebot3_simulations/turtlebot3_gazebo/models' >> ~/.bashrc
// 将TURTLEBOT3_MODEL设置为waffle_pi
echo 'export TURTLEBOT3_MODEL=waffle_pi' >> ~/.bashrc
source ~/.bashrc
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
ros2 run  turtlebot3_teleop teleop_keyboard // 另起终端