出现问题的源博客: 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"/>
重新编译并运行。发现不再报错

本文解决了一个关于ROS乌龟模拟器中启动launch文件时出现的RLException错误。错误原因是由于launch文件中节点类型的错误书写导致无法启动。文章提供了正确的launch文件配置示例,并给出了排查此类问题的几种常见方法。
最低0.47元/天 解锁文章
119

被折叠的 条评论
为什么被折叠?



