4.3 ROS工作空间覆盖:不同工作空间中,存在重名的功能包的BUG

项目场景:

程序如下:

<!-- 需要启动多个乌龟GUI节点 -->
<launch>
    <node pkg="turtlesim" type="turtlesim_node" name="turtlesim" />
    <!-- 名称重映射 -->
    <node pkg="turtlesim" type="turtlesim_node" name="t1" />
    <!-- 命名空间 -->
    <node pkg="turtlesim" type="turtlesim_node" name="turtlesim" ns="ergouzi" />
    <!-- 命名空间+名称重映射 -->
    <node pkg="turtlesim" type="turtlesim_node" name="t2" ns="maolvzi" />

</launch>

在学习【奥特学园】ROS机器人入门课程《ROS理论与实践》零基础教程P162 节点名称重名_方式2 _launch文件时运行出错


问题描述:运行roslaunch rename01_node start_turtle.launch报错

ERROR: cannot launch node of type [turtlesim/turtlesim_node]: Cannot locate node of type [turtlesim_node] in package [turtlesim]. Make sure file exists in package path and permission is set to executable (chmod +x)

ERROR: cannot launch node of type [turtlesim/turtlesim_node]: Cannot locate node of type [turtlesim_node] in package [turtlesim]. Make sure file exists in package path and permission is set to executable (chmod +x)

ERROR: cannot launch node of type [turtlesim/turtlesim_node]: Cannot locate node of type [turtlesim_node] in package [turtlesim]. Make sure file exists in package path and permission is set to executable (chmod +x)

ERROR: cannot launch node of type [turtlesim/turtlesim_node]: Cannot locate node of type [turtlesim_node] in package [turtlesim]. Make sure file exists in package path and permission is set to executable (chmod +x)

 

我又运行了之前的roslaunch plumbing_test start_turtle.launch文件,还是报错!

ERROR: cannot launch node of type [turtlesim/turtlesim_node]: Cannot locate node of type [turtlesim_node] in package [turtlesim]. Make sure file exists in package path and permission is set to executable (chmod +x)

ERROR: cannot launch node of type [turtlesim/turtle_teleop_key]: Cannot locate node of type [turtle_teleop_key] in package [turtlesim]. Make sure file exists in package path and permission is set to executable (chmod +x)

我退出,重启电脑等,又启动roscore, rosrun turtlesim turtlesim_node,还是报错

[rosrun] Couldn't find executable named turtlesim_node below /opt/ros/noetic/share/turtlesim


原因分析:

1.我检查了代码没问题,配置环境没问题;

2.运行之前的roslaunch plumbing_test start_turtle.launch出问题了;

3.关机重启单独运行乌龟控制节点rosrun turtlesim turtlesim_node也报错

4.运行键盘控制节点rosrun turtlesim 用tab只能自动补齐hello_ws2,明显是上一节课的重名的功能包turtlesim造成的

5.最后,查看ROS环境环境变量echo $ROS_PACKAGE_PATH,发现在 ROS PACKAGE PATH 中只包含两个工作空间(应该又3个,原本4个我注释掉了一个)


 

 

解决方案:删除自定义工作空间的 build 与 devel 目录

分析到这里,我想到了上一节课提到的BUG:

BUG 说明:

当在 .bashrc 文件中 source 多个工作空间后,可能出现的情况,在 ROS PACKAGE PATH 中只包含两个工作空间,可以删除自定义工作空间的 build 与 devel 目录,重新 catkin_make,然后重新载入 .bashrc 文件,问题解决。

然后删掉了工作空间的 build 与 devel 文件夹,重新编译后就正常了。(我把上节课demo03_ws下的turtlesim功能包也删掉了,demo01也打包成压缩包了,然后删掉了demo01_ws,以免又其他影响)

运行 roslaunch plumbing_test start_turtle.launch正常

运行roslaunch rename01_node start_turtle.launch正常

 

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

楚歌again

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

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

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

打赏作者

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

抵扣说明:

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

余额充值