dronekit / dronekit-python

DroneKit-Python library for communicating with Drones via MAVLink.
https://readthedocs.org/projects/dronekit-python/
Apache License 2.0
1.5k stars 1.42k forks source link

ERROR:dronekit:Exception in message handler for HEARTBEAT #1174

Closed jeromeroy closed 1 year ago

jeromeroy commented 1 year ago

Hi there,

I connected my PixHawk Cube orange to a Jetson Xavier NX. The connection works, I recevie messages about the battery voltage, ecc ecc.

In the terminal the following error appears:

ERROR:dronekit:Exception in message handler for HEARTBEAT
Traceback (most recent call last):
  File "/home/cecilia/ceciliaEnv/lib/python3.8/site-packages/dronekit/__init__.py", line 1531, in notify_message_listeners
    fn(self, name, msg)
  File "/home/cecilia/ceciliaEnv/lib/python3.8/site-packages/dronekit/__init__.py", line 1223, in listener
    raise APIException("mode (%s, %s) not available on mavlink definition" % (m.custom_mode, m.base_mode))
dronekit.APIException: mode (0, 4) not available on mavlink definition
Connection to Cecilia Succesful!
Mode: GUIDED
ERROR:dronekit:Exception in message handler for HEARTBEAT
Traceback (most recent call last):
  File "/home/cecilia/ceciliaEnv/lib/python3.8/site-packages/dronekit/__init__.py", line 1531, in notify_message_listeners
    fn(self, name, msg)
  File "/home/cecilia/ceciliaEnv/lib/python3.8/site-packages/dronekit/__init__.py", line 1223, in listener
    raise APIException("mode (%s, %s) not available on mavlink definition" % (m.custom_mode, m.base_mode))
dronekit.APIException: mode (0, 4) not available on mavlink definition
ERROR:dronekit:Exception in message handler for HEARTBEAT
Traceback (most recent call last):
  File "/home/cecilia/ceciliaEnv/lib/python3.8/site-packages/dronekit/__init__.py", line 1531, in notify_message_listeners
    fn(self, name, msg)
  File "/home/cecilia/ceciliaEnv/lib/python3.8/site-packages/dronekit/__init__.py", line 1223, in listener
    raise APIException("mode (%s, %s) not available on mavlink definition" % (m.custom_mode, m.base_mode))
dronekit.AP

My code:

# cecilia connect

# Import DroneKit-Python
from dronekit import connect
import time

# Connect to the Vehicle (in this case a UDP endpoint)

vehicle = connect('/dev/serial/by-id/usb-Hex_ProfiCNC_CubeOrange_220040000F51303438373832-if00')

#vehicle = connect('/dev/ttyAMA0', wait_ready=True, baud=57600)
print("Connection to Cecilia Succesful!")
print("Mode: %s" % vehicle.mode.name)
time.sleep(2)
# Close vehicle object before exiting script
vehicle.close()

print("Completed")
jeromeroy commented 1 year ago

After different trys i found a working solution (with the help of this issue)

I changed the "Serial Protocol 5" setting value to -1 (aka None). To make this change I connected the Cube Orange via USB to Mission Planner, searched for SERIAL5_PROTOCOL and changed the value. (Remember to write your parameters!!!)

:)