ROS入门——解决RLException: Unable to launch [xxx-2]

出现问题的源博客: ROS入门(十)——两只小乌龟(乌龟跟随C++实现)

在运行 launch 文件的过程中,出现了这个报错。无法启动launch文件。

RLException: Unable to launch [turtle2-2]. 
If it is a script, you may be missing a '#!' declaration at the top.
The traceback for the exception was written to the log file

# 匹配异常,无法运行 launch
# 如果是一个脚本,您可能缺少一个'#!'的声明。

 一、我的问题

我出现这个原因其实是因为粗心,在 launch 文件中,启动小乌龟的 type 应设置为 t1_turtle2,但我却写成了 t1_turtle2.cpp ,导致无法正常找到这个文件

# 正确启动方式
<launch>
    <!-- 启动乌龟GUI节点 -->
    <node pkg="turtlesim" type="turtlesim_node" name="turtle1" output="screen"/>
    <!-- 生成新乌龟的节点 -->
    <node pkg="tf1_turtle" type="t1_turtle2" name="turtle2" output="screen"/>
</launch>

# 错误写法,除非对应c文件的名称为 t1_turtle2.cpp.cpp
# <node pkg="tf1_turtle" type="t1_turtle2.cpp" name="turtle2" output="screen"/>

重新编译并运行。发现不再报错

二、其他方案

(1)未进行source

  • 方法一:终端运行 
source ./devel/setup.bash
  • 方法二:永久配置

参考链接Ubuntu、VSCODE小技巧的二、2.一次性 source

(2)检查 cpp 的脚本头

看是否少写了 " # " 或导入的包有问题

(3)检查文件名

检查是否正确调用文件或运行文件【例如我的错误】。

文件名是否统一

参考博客

ROS错误之RLException: Ubable to launch [xx-1]].

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值