所有内容请看:
项目场景:
人脸识别的过程中,在launch中添加python文件,以便直接能够启动识别程序
问题 1 描述
如何添加python文件到launch中
原因分析&解决方案:
在launch文件中添加以下语句:
<node pkg="face_recognizer" type="FaceRecognition.py" name="FaceRecognition" />
pkg:功能包名
type:python文件名
name:自定义名字
问题 2 描述
RLException: Unable to launch [face_detect-3].
If it is a script, you may be missing a '#!' declaration at the top.
原因分析&解决方案:
1.没有source一下环境
cd到工作空间中,终端中输入source devel/setup.bash
2.python文件没有写声明
python文件中添加#!/usr/bin/python3
问题 3 描述
RLException: Roslaunch got a 'No such file or directory' error while attempting to run:
/home/spark/spark_noetic/src/spark_app/face_recognizer/script/FaceRecognition.py __name:=FaceRecognition __log:=/home/spark/.ros/log/fbf2d3a2-b646-11ec-aee2-9373a792b0e2/FaceRecognition-3.log
Please make sure that all the executables in this command exist and have
executable permission. This is often caused by a bad launch-prefix.
The traceback for the exception was written to the log file
原因分析&解决方案:
1.python文件没有修改可执行权限
修改python文件的属性,勾选excute如图
2.没有source一下的原因
cd到工作空间中,终端中输入source devel/setup.bash
3.我尝试了以上的办法,均没有效果,之后新建了个python文件,将代码复制进去,修改执行权限,再次执行就可以了,有知道为什么的小伙伴可以在留言区告诉我,十分感谢