ROS_安装一个第三方仿真软件包——机器人模拟世界

本文详细介绍了在Ubuntu16.04和ROS环境下安装并运行一个第三方ROS仿真软件包的全过程,包括环境搭建、依赖安装、编译及运行,解决了常见错误并提供了实用的命令行操作技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文记录安装一个第三方仿真软件包的实战,从下载到成功运行!
环境:ubuntu16.04 & ROS-Ubuntu2

下载源码包

在Ubuntu系统上,确保git已经安装
sudo apt-get install git

然后再创建一个名为tutorial_ws的工作空间,在它的src路径下克隆ROS-Academy-for-Beginners软件包
cd
mkdir -p tutorial_ws/src           创建catkin工作空间
cd tutorial_ws/src                 进入src路径,克隆教学软件包
git clone https://github.com/DroidAITech/ROS-Academy-for-Beginners.git

安装依赖

安装依赖:

cd ~/tutorial_ws
rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y

过程图:

9125154-3bcfd5cf9a52cc75.png

9125154-e7cc41df6841025a.png

9125154-512e58528c2ee62a.png

注意:以上命令非常重要,缺少依赖将导致软件包无法正常编译和运行。
在开始编译之前,需要确保Gazebo在7.0版本以上

gazebo -V
9125154-462195736c51afe0.png

编译

接着回到catkin_ws下编译:

cd ~/tutorial_ws
catkin_make

过程图:

9125154-f8a2cec0c561f248.png

9125154-074b6f3278a41079.png

9125154-a5ebb9c82d1d355b.png

9125154-815033b62a85f243.png

下面是刷新环境的两种方法:

source ~/tutorial_ws/devel/setup.bash
rospack profile

过程图:

9125154-a7e6b0587303f63f.png

9125154-d826d016cf527096.png

运行仿真程序

首先需要解决一个问题,不然待会儿运行时会闪退:

roslaunch robot_sim_demo robot_spawn.launch

下面是运行过程图(是的,一开始可能会遇到一个报错[robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name The traceback for the exception was written to the log file,然而下面的过程图已经是从报错到解决报错成功运行的过程了):

9125154-176082a1db564bf7.png

liweipeng@liweipeng-virtual-machine:~$ rospack profile
Full tree crawl took 0.189714 seconds.
Directories marked with (*) contain no manifest.  You may
want to delete these directories.
To get just of list of directories without manifests,
re-run the profile with --zombie-only
-------------------------------------------------------------
0.141810   /opt/ros/kinetic/share
0.000770 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev
0.000257 * /opt/ros/kinetic/share/doc
0.000043 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/haarcascades
0.000019 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/lbpcascades
0.000008 * /opt/ros/kinetic/share/doc/liborocos-kdl
liweipeng@liweipeng-virtual-machine:~$ roslaunch robot_sim_demo robot_spawn.launch 
[robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
The traceback for the exception was written to the log file
liweipeng@liweipeng-virtual-machine:~$ roslaunch robot_sim_demo robot_spawn.launch 
[robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
The traceback for the exception was written to the log file
liweipeng@liweipeng-virtual-machine:~$ cd ~/tutorial_ws
liweipeng@liweipeng-virtual-machine:~/tutorial_ws$ roslaunch robot_sim_demo robot_spawn.launch 
[robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
The traceback for the exception was written to the log file
liweipeng@liweipeng-virtual-machine:~/tutorial_ws$ source ~/tutorial_ws/devel/setup.bash
liweipeng@liweipeng-virtual-machine:~/tutorial_ws$ rospack profile
Full tree crawl took 0.025369 seconds.
Directories marked with (*) contain no manifest.  You may
want to delete these directories.
To get just of list of directories without manifests,
re-run the profile with --zombie-only
-------------------------------------------------------------
0.016329   /opt/ros/kinetic/share
0.008478   /home/liweipeng/tutorial_ws/src
0.008405   /home/liweipeng/tutorial_ws/src/ROS-Academy-for-Beginners
0.000169 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev
0.000036 * /opt/ros/kinetic/share/doc
0.000035 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/haarcascades
0.000015 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/lbpcascades
0.000006 * /opt/ros/kinetic/share/doc/liborocos-kdl
liweipeng@liweipeng-virtual-machine:~/tutorial_ws$ roslaunch robot_sim_demo robot_spawn.launch 
... logging to /home/liweipeng/.ros/log/3bcd5ac4-be9d-11e8-a270-000c29f43d2c/roslaunch-liweipeng-virtual-machine-2603.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
xacro.py is deprecated; please use xacro instead
started roslaunch server http://liweipeng-virtual-machine:41819/

SUMMARY
========

PARAMETERS

9125154-3e2995762fbdd852.png

9125154-88d696568d681e73.png
9125154-07ccda2ec5d0e160.png
9125154-c61dbff42d98a7ff.png

再打开一个终端,输入以下命令,用键盘控制机器人移动,聚焦控制程序窗口,按下i、j、l等按键,控制机器人移动:

rosrun robot_sim_demo robot_keyboard_teleop.py

过程图如下,记得运行前要刷新环境,或者用上面的方法把刷新命令添加到脚本:

9125154-543c62da37910dc4.png

呐,对比上图,我把它移到了简介牌的右边:

9125154-ccabd78b5ebe8ca6.png

<think>好的,我现在需要帮助用户解决ROS中加载资源文件失败的问题,具体错误是“could not load resource package wpr_simulation meshes wpb_home_std.dae unable to open file”。首先,我得回忆一下ROS中资源文件加载的常见问题。通常这类错误可能是因为文件路径不正确、包未正确安装或编译,或者文件权限问题。 首先,用户提到的错误信息指出无法打开wpb_home_std.dae文件。这可能意味着ROS在指定的路径下找不到这个文件。我应该先检查文件是否存在。用户需要确认wpr_simulation包中的meshes目录下是否有这个文件,并且路径是否正确。可能需要使用`rospack find wpr_simulation`来确认包的安装路径是否正确。 接下来,如果文件存在但ROS找不到,可能是包没有正确安装或者环境变量没有设置好。例如,用户是否在正确的ROS工作空间中安装了wpr_simulation包,并且执行过`catkin_make`和`source devel/setup.bash`?有时候,尤其是当包是从源代码编译安装时,如果没有重新source环境脚本,系统可能无法识别新的包路径。 另外,文件权限也是一个常见问题。用户可能需要检查该dae文件是否有读取权限。如果没有,使用`chmod`命令修改权限应该能解决。 还有一个可能性是package.xml文件中没有正确声明资源文件。ROS包需要在其package.xml中列出资源文件,或者使用`<export>`标签来指定资源路径,否则在安装时可能不会包含这些文件。用户需要检查package.xml是否有相关配置,比如`<exec_depend>wpr_simulation</exec_depend>`或者资源导出设置。 另外,如果用户是通过apt安装的二进制包,可能需要确认该包是否包含meshes目录。有时候二进制包可能缺少某些资源文件,这时候可能需要从源码安装。 最后,如果以上步骤都确认无误,可能需要检查模型文件(如URDF或xacro)中引用该dae文件的路径是否正确。路径应该是相对于包的路径,例如`package://wpr_simulation/meshes/wpb_home_std.dae`,而不是绝对路径。 用户可能需要逐一排查这些可能性,从检查文件是否存在开始,逐步验证安装、权限、环境变量和配置文件是否正确。同时,建议用户查看ROS的官方文档或相关包的文档,确保遵循正确的安装和使用步骤。</think>针对ROS加载资源文件失败的问题"could not load resource package wpr_simulation meshes wpb_home_std.dae",以下是逐步解决方案: 1. **验证文件路径** - 执行命令定位资源包: ```bash rospack find wpr_simulation ``` - 进入meshes目录确认文件存在: ```bash cd $(rospack find wpr_simulation)/meshes && ls wpb_home_std.dae ``` - 若路径错误,需检查模型文件中的mesh引用路径是否为:`package://wpr_simulation/meshes/wpb_home_std.dae` 2. **检查包安装状态** - 确认包已正确安装: ```bash apt list | grep wpr-simulation ``` - 若通过源码安装,需在workspace执行: ```bash catkin_make && source devel/setup.bash ``` 3. **文件权限设置** ```bash chmod +r $(rospack find wpr_simulation)/meshes/wpb_home_std.dae ``` 4. **验证资源导出声明** 检查`wpr_simulation`包的package.xml文件是否包含: ```xml <export> <rosdoc config="rosdoc.yaml" /> </export> ``` 建议补充资源导出声明: ```xml <export> <architecture_independent/> <mesh resource="${prefix}/meshes/wpb_home_std.dae" /> </export> ``` 5. **重建资源索引** ```bash rospack profile ``` [^1]: 该解决方案参考ROS资源管理规范,详见ROS官方文档资源管理章节
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凌川江雪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值