查看 openinterface.py 源代码,您似乎收到“非法传感器 ID”错误,因为您在调用 stream_sensors() 时使用的给定 ID 值与具有已知传感器 ID 的字典不匹配。传感器 ID 字典在SensorPacketDecoderAPI类中指定:
class SensorPacketDecoderApi:
"""
Transform sensor data in the form of bytes (from a serial stream)
into a dictionary of sensor values.
"""
names = {'left-velocity' : 42,
'right-velocity' : 41,
'radius' : 40,
'velocity' : 39,
'n-stream-packets' : 38,
'song-playing' : 37,
'song-number' : 36,
'oi-mode' : 35,
'home-base?' : 34,
'internal-charger?' : 34,
'user-analog-in-0' : 33,
'baud-rate-change?' : 32,
'user-digital-in-3' : 32,
'user-digital-in-2' : 32,
'user-digital-in-1' : 32,
'user-digital-in-0' : 32,
'cliff-right-signal' : 31,
'cliff-right-front-signal' : 30,
'cliff-left-front-signal' : 29,
'cliff-left-signal' : 28,
'wall-signal' : 27,
'capacity' : 26,
'charge' : 25,
'temperature' : 24,
'current' : 23,
'voltage' : 22,
'charging-state' : 21,
'angle' : 20,
'distance' : 19,
'advance?' : 18,
'play?' : 18,
'infrared-byte' : 17,
'left-wheel-overcurrent?' : 14,
'right-wheel-overcurrent?' : 14,
'low-side-driver-2-overcurent?' : 14,
'low-side-driver-0-overcurent?' : 14,
'low-side-driver-1-overcurent?' : 14,
'virtual-wall?' : 13,
'cliff-right?' : 12,
'cliff-front-right?' : 11,
'cliff-front-left?' : 10,
'cliff-left?' : 9,
'wall?' : 8,
'wheel-drop-caster?' : 7,
'wheel-drop-left?' : 7,
'wheel-drop-right?' : 7,
'bump-left?' : 7,
'bump-right?' : 7,
'all' : 6}
至于您收到“流式线程错误!...”的原因,我不确定,我通过代码可以看出它源自CreateBot 类中名为_stream_sensors_worker的函数。还有一个名为_test_sensor_streaming的函数,您也可以尝试从_stream_sensors_worker获取一些调试信息。