运行rosrun rosserial_python serial_node.py /dev/ttyUSB0时触发递归深度超限错误
使用rosserial与ESP32通信时的递归错误解决办法
我尝试通过rosserial与ESP32建立通信,执行命令rosrun rosserial_python serial_node.py /dev/ttyUSB0时,持续触发递归错误,具体报错信息如下:
File "/home/tilak/catkin_ws/devel/lib/rosserial_python/serial_node.py", line 15, in <module> exec(compile(fh.read(), python_script, 'exec'), context) File "/home/tilak/catkin_ws/devel/lib/rosserial_python/serial_node.py", line 15, in <module> exec(compile(fh.read(), python_script, 'exec'), context) File "/home/tilak/catkin_ws/devel/lib/rosserial_python/serial_node.py", line 15, in <module> exec(compile(fh.read(), python_script, 'exec'), context) File "/home/tilak/catkin_ws/devel/lib/rosserial_python/serial_node.py", line 15, in <module> exec(compile(fh.read(), python_script, 'exec'), context) File "/home/tilak/catkin_ws/devel/lib/rosserial_python/serial_node.py", line 7, in <module> with open(python_script, 'r') as fh: RecursionError: maximum recursion depth exceeded while calling a Python object tilak@tilak-Lenovo-ideapad-330S-14IKB:~$ rosrun rosserial_python serial_node.py /dev/ttyUSB0
解决步骤
- 重新编译工作空间,清除编译缓存问题:
cd ~/catkin_ws rm -rf devel build catkin_make source devel/setup.bash - 重新安装rosserial_python包,修复可能损坏的文件:
sudo apt-get install --reinstall ros-noetic-rosserial-python - 直接调用系统安装的源文件,避开devel目录下出错的生成脚本:
rosrun rosserial_python /opt/ros/noetic/lib/rosserial_python/serial_node.py /dev/ttyUSB0 - 配置串口访问权限,将当前用户加入dialout组:
执行后注销并重新登录,权限才可生效。sudo usermod -aG dialout $USER
内容的提问来源于stack exchange,提问作者Tilak Kuntalkumar Kamani
相关产品推荐
相关产品推荐

