在Linux上使用遥测连接到车辆

时间:2018-01-09 13:10:41

标签: linux dronekit-python

我遇到车辆连接问题。首先,即使使用USB也无法连接到车辆(我使用“/ dev / ttyUSB0”连接字符串并出错)。后来我使用连接字符串'/dev/serial/by-id/usb-3D_Robotics_PX4_FMU_v2.x_0-if00',并能够发送命令并接收响应。现在我想用连接到笔记本电脑USB的遥测模块进行测试。我尝试了相同的方法 - 使用连接字符串"/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0",但它提供了超时消息。

USB连接测试输出:

>>> PreArm: Check FS_THR_VALUE
>>> PreArm: Throttle below Failsafe
>>> APM:Copter V3.5.4 (284349c3)
>>> PX4: 0384802e NuttX: 1bcae90b
>>> Frame: QUAD
>>> PX4v3 0035003B 3136510A 34313630
 Mode: STABILIZE
Autopilot Firmware version: APM:Copter-3.5.4
Autopilot capabilities (supports ftp): False
Global Location: LocationGlobal:lat=40.3985757,lon=49.8104986,alt=38.7
Global Location (relative altitude): LocationGlobalRelative:lat=40.3985757,lon=49.8104986,alt=38.7
Local Location: LocationLocal:north=None,east=None,down=None
Attitude: Attitude:pitch=-0.013171303086,yaw=0.0626983344555,roll=-0.0145587390289
Velocity: [-0.01, -0.01, 0.03]
GPS: GPSInfo:fix=3,num_sat=5
Groundspeed: 0.0168827120215
Airspeed: 0.263999998569
Gimbal status: Gimbal: pitch=None, roll=None, yaw=None
Battery: Battery:voltage=0.0,current=None,level=None
EKF OK?: False
Last Heartbeat: 0.967473479002
Rangefinder: Rangefinder: distance=None, voltage=None
Rangefinder distance: None
Rangefinder voltage: None
Heading: 3
Is Armable?: False
System status: STANDBY
Mode: STABILIZE
Armed: False

我正在打开这样的连接:

vehicle = connect('/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0', wait_ready=True)

这导致以下追溯:

>>> Link timeout, no heartbeat in last 5 seconds
>>> No heartbeat in 30 seconds, aborting.
Traceback (most recent call last):
  File "x.py", line 6, in <module>
    vehicle = connect('/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0', wait_ready=True)
  File "/home/seyid/.local/lib/python2.7/site-packages/dronekit/__init__.py", line 2845, in connect
    vehicle.initialize(rate=rate, heartbeat_timeout=heartbeat_timeout)
  File "/home/seyid/.local/lib/python2.7/site-packages/dronekit/__init__.py", line 2117, in initialize
    raise APIException('Timeout in initializing connection.')
dronekit.APIException: Timeout in initializing connection.

使用MavProxy时遥测模块正在工作。

这是什么问题?谢谢

1 个答案:

答案 0 :(得分:1)

有几个问题可能导致dronekit因连接超时而失败:

  • 确保您已安装pyserial模块。

  • 明确指定连接的波特率,如:

    vehicle = connect('/dev/ttyUSB0',
                      wait_ready=True,
                      baud=57600,
                      )
    

如果与mavproxy的连接到同一串口可以在您的系统上运行,那么第二个可能就是罪魁祸首。