WSL2 Ubuntu20.04下ROS2 Foxy的turtlebot3_gazebo包缺失问题求助
问题描述
已完成ROS2 Foxy版本《TurtleBot3快速入门指南》所有步骤,运行环境为Windows 11上的WSL2 Ubuntu 20.04,环境信息如下:
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.5 LTS Release: 20.04 Codename: focal
$ printenv ROS_DISTRO foxy
$ gazebo -version Gazebo multi-robot simulator, version 11.11.0 Copyright (C) 2012 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org Gazebo multi-robot simulator, version 11.11.0 Copyright (C) 2012 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org
执行以下命令启动TurtleBot3 Gazebo仿真时:
$ export TURTLEBOT3_MODEL=burger $ ros2 launch turtlebot3_gazebo empty_world.launch.py
出现报错:
Package 'turtlebot3_gazebo' not found: "package 'turtlebot3_gazebo' not found, searching: ['/opt/ros/foxy']"
解决方案
1. 确认turtlebot3_gazebo包是否安装
执行以下命令检查是否已安装该包:
sudo apt list --installed | grep turtlebot3_gazebo
若没有输出,说明未安装,执行安装命令:
sudo apt update && sudo apt install ros-foxy-turtlebot3-gazebo
2. 检查工作空间环境变量加载
如果是从源码编译TurtleBot3相关包,需确保工作空间的setup.bash被正确加载。假设你的工作空间路径为~/colcon_ws,执行:
source ~/colcon_ws/install/setup.bash
为避免每次启动终端手动加载,可将该命令添加到~/.bashrc:
echo "source ~/colcon_ws/install/setup.bash" >> ~/.bashrc
执行source ~/.bashrc使设置立即生效。
3. 验证ROS_PACKAGE_PATH路径
执行以下命令查看环境变量:
echo $ROS_PACKAGE_PATH
输出需包含你的工作空间install/share目录(如~/colcon_ws/install/share:/opt/ros/foxy/share)。若未包含,重新执行步骤2的source命令即可。
4. 全局设置TURTLEBOT3_MODEL
将模型设置命令添加到~/.bashrc,避免每次手动输入:
echo "export TURTLEBOT3_MODEL=burger" >> ~/.bashrc
执行source ~/.bashrc生效。
内容的提问来源于stack exchange,提问作者iqfareez
相关产品推荐
相关产品推荐

