You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 04:57:10