Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

dronekit.APIException: mode (0, 4) not available on mavlink definition #1024

Open

Description

@bduva002

Hello all,
I am running arduplane 4.1.X with dronekit 2.9.2 and pymavlink 2.4.4. When I run the SITL sim_vehicle.py and connect the vehicle_state.py example code every thing works as it should.

Now when I run the vehicle_state.py on an RPI connected to a cube orange I get the following error message:

ERROR:dronekit:Exception in message handler for HEARTBEAT
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/dronekit/init.py", line 1531, in notify_message_listeners
fn(self, name, msg)
File "/usr/local/lib/python3.5/dist-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

From this error I see that from the real pixhawk m.custom_mode =0 and m.base_mode=4
Since the SITL is working I went into the dronekit init.py file and added some print statements to tell me what m.custom_mode and m.base_mode is when running with the SITL.
When running dronekit connected to SITL:
m.custom_mode = 2
m.base_mode = 81

I am not sure why custom and base mode values are different when I run connected to a pixhawk cube orange.

I have tried building dronekit from source based on similar issues that are already on github but this did not make a difference. I know @peterbarker mentioned this might be a problem with multiple connections in this link #677 but I think this error is something different.

Any help would be greatly appreciated

Activity

  1. bduva002 commented on Apr 27, 2020

    @bduva002
    Author

    Well I have an update, Thanks to the help of my good friend Tarik in this post:
    https://discuss.cubepilot.org/t/using-dronekit-with-cubepilot-orange-ads-b-carrier-board-exception-message-handler-error/3367
    We are both using the new ADSB carrier boards with the pixhawk cube orange and ardupilot4.0.4. It turns out there must be cross talk because when we allow the ADSB receiver to be connected through serial5 to the pixhawk I get the following error message:
    dronekit.APIException: mode (0, 4) not available on mavlink definition

    If I disable SERIAL5_PROTOCAL=None the error goes away.

    It sounds like these additional modes need to just be added to dronekit. Dose anyone out there have any ideas?

    Thanks

  2. munsterlander commented on Nov 23, 2021

    @munsterlander

    Any progress on this? I can't get anything going due to this error. The Cube Orange can establish a connection, but I can't get passed is_armable as its always false and trying to set anything results in errors because the vehicle is never initialized.

      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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, 0) not available on mavlink definition
    
    Get all vehicle attribute values:
     Autopilot Firmware version: UnknownAutoPilotUnknownVehicleType18-4.1.0
       Major version number: 4
       Minor version number: 1
       Patch version number: 0
       Release type: rc
       Release version: 0
       Stable release?: True
     Autopilot capabilities
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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   Supports MISSION_FLOAT message type: True
    
       Supports PARAM_FLOAT message type: True
       Supports MISSION_INT message type: True
       Supports COMMAND_INT message type: True
       Supports PARAM_UNION message type: False
       Supports ftp for file transfers: True
       Supports commanding attitude offboard: True
       Supports commanding position and velocity targets in local NED frame: True
       Supports set position + velocity targets in global scaled integers: True
       Supports terrain protocol / data handling: True
       Supports direct actuator control: False
       Supports the flight termination command: True
       Supports mission_float message type: True
       Supports onboard compass calibration: True
     Global Location: LocationGlobal:lat=0.0,lon=0.0,alt=None
     Global Location (relative altitude): LocationGlobalRelative:lat=0.0,lon=0.0,alt=-0.259
     Local Location: LocationLocal:north=None,east=None,down=None
     Attitude: Attitude:pitch=-0.01201585866510868,yaw=0.07953730970621109,roll=0.026009727269411087
     Velocity: [0.0, 0.0, 0.0]
     GPS: GPSInfo:fix=1,num_sat=0
     Gimbal status: Gimbal: pitch=None, roll=None, yaw=None
     Battery: Battery:voltage=14.991,current=0.0,level=99
     EKF OK?: False
     Last Heartbeat: 0.0
     Rangefinder: Rangefinder: distance=None, voltage=None
     Rangefinder distance: None
     Rangefinder voltage: None
     Heading: 4
     Is Armable?: False
     System status: STANDBY
     Groundspeed: 0.005084705539047718
     Airspeed: 0.0
     Mode: STABILIZE
     Armed: False
    Basic pre-arm checks
     Waiting for vehicle to initialise...
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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 (33554831, 0) not available on mavlink definition
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
    
  3. bduva002 commented on Nov 24, 2021

    @bduva002
    Author

    Are you using a cube orange?
    Did you disable Serial5?
    Have you gone through the calibrations such as accelerometer and compass cal

  4. munsterlander commented on Nov 24, 2021

    @munsterlander

    Yes - cube orange and blue. I set serial 5 protocol to -1. Reboot the board. Everything had been calibrated and tuned and flies fine. I have tried mav1 and mav2 as well. No change in the error. Running 4.1.1. I am using rfd-900x on telemetry 2.

    Edit: My pixhawk 2.4.8 doesn't have this issue. I just bought a mini cube carrier board and it should get here in a few days. I am about ready to chuck this ADS-B board as far as I can throw it. Hopefully, with a more standard board, I will avoid this ADS-B issue altogether. If we need it (we are doing indoor research so not needed for now), we can prob just do a can port add on or something later.

  5. bduva002 commented on Nov 25, 2021

    @bduva002
    Author

    Lol before you throw it, I think the problem is the EKF is not happy. When you run this code are you outside and have a good gps fix. Also check mission planner. The hud will tell you if the EKF is not happy.

    Also have you tried commenting out the part that checks to see if the vehicle is armable?

    When I started this post I could not get it to connect until I turned of the serial 5. The carrier does not seem to be the problem in your case.

  6. munsterlander commented on Nov 25, 2021

    @munsterlander

    I should clarify, I can connect and I saw the EKF issue (battery as well). It's the constant heartbeat of the error above that ultimately is causing issues. I overrode the pre-arm checks to make sure I could move on and the script is fine. I need to do some more tests and dump the logs here. Hopefully I will have some time later. Thank you for any pointers and help you have already provided. Your are like the only person responding so it's very much appreciated!

    Edit: sorry I'm not good with words. But I was basically reporting that setting it to none no longer removes the error and because it throws so many errors, I'm getting timeouts.

  7. munsterlander commented on Nov 25, 2021

    @munsterlander

    Ok, I just ran it so you can see the script executes - regardless of the status - and the vehicle armed and did what I expected it to do. What has been problematic, is sometimes you have to execute the script a few times as you get the timeout that is in the start of below which I attribute to the ADS-B issue that we can't seem to turn off. In this current config for below, SERIAL5_PROTOCOL = None (-1), SERIAL2_PROTOCOL: Mavlink2, ADSB_ENABLE: Off:

    Edit: I also want to add, I don't know why it says GPS is none. I am running Mission Planner right along side this as well as QGC in the HereLink controller. For the scripts below, I had 6 satellites locked and it showed perfectly on the map. The MP HUD showed EKF OK and battery 100%. It seems very much that the mavlink messages are incomplete or malformed or something. Is it possible that Dronekit only supports Mav1? I reference this: #935 but I have not tried it.

    dronekit.APIException: mode (33554837, 0) not available on mavlink definition
    Traceback (most recent call last):
      File "TestTelemetry.py", line 18, in <module>
        vehicle.wait_ready('autopilot_version')
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 2375, in wait_ready
        timeout)
    dronekit.TimeoutError: wait_ready experienced a timeout after 30 seconds.
    
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
    C:\Users\munsterlander\PythonProjects\Drone>python TestTelemetry.py
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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, 0) not available on mavlink definition
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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 (33554837, 0) not available on mavlink definition
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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, 0) not available on mavlink definition
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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 (33554837, 0) not available on mavlink definition
    
    Get all vehicle attribute values:
     Autopilot Firmware version: UnknownAutoPilotUnknownVehicleType0-4.1.1
       Major version number: 4
       Minor version number: 1
       Patch version number: 1
       Release type: rc
       Release version: 0
       Stable release?: True
     Autopilot capabilities
       Supports MISSION_FLOAT message type: True
       Supports PARAM_FLOAT message type: True
       Supports MISSION_INT message type: True
       Supports COMMAND_INT message type: True
       Supports PARAM_UNION message type: False
       Supports ftp for file transfers: True
       Supports commanding attitude offboard: True
       Supports commanding position and velocity targets in local NED frame: True
       Supports set position + velocity targets in global scaled integers: True
       Supports terrain protocol / data handling: True
       Supports direct actuator control: False
       Supports the flight termination command: True
       Supports mission_float message type: True
       Supports onboard compass calibration: True
     Global Location: LocationGlobal:lat=None,lon=None,alt=None
     Global Location (relative altitude): LocationGlobalRelative:lat=None,lon=None,alt=None
     Local Location: LocationLocal:north=None,east=None,down=None
     Attitude: Attitude:pitch=None,yaw=None,roll=None
     Velocity: [None, None, None]
     GPS: GPSInfo:fix=None,num_sat=None
     Gimbal status: Gimbal: pitch=None, roll=None, yaw=None
     Battery: None
     EKF OK?: False
     Last Heartbeat: 0.06300000000192085
     Rangefinder: Rangefinder: distance=None, voltage=None
     Rangefinder distance: None
     Rangefinder voltage: None
     Heading: None
     Is Armable?: False
     System status: STANDBY
     Groundspeed: None
     Airspeed: None
     Mode: STABILIZE
     Armed: False
    Basic pre-arm checks
     Waiting for vehicle to initialise...
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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, 0) not available on mavlink definition
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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 (33554837, 0) not available on mavlink definition
     Waiting for vehicle to initialise...
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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, 0) not available on mavlink definition
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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 (33554837, 0) not available on mavlink definition
    Arming motors
     Waiting for arming...
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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, 0) not available on mavlink definition
     Waiting for arming...
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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 (33554837, 0) not available on mavlink definition
    ERROR:dronekit:Exception in message handler for HEARTBEAT
    Traceback (most recent call last):
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dronekit\__init__.py", line 1531, in notify_message_listeners
        fn(self, name, msg)
      File "C:\Users\munsterlander\AppData\Local\Programs\Python\Python36-32\lib\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, 0) not available on mavlink definition
    Taking off!
    Close vehicle
    
  8. bduva002 commented on Nov 25, 2021

    @bduva002
    Author

    I have been using mavlink1 for my serial protocol. You might check serial6 and turn it off too. The developers could have moved the ADSB port to another serial port.

    So if I am following you, your code will run with no error but when you run it again you get this error?

  9. munsterlander commented on Nov 25, 2021

    @munsterlander

    I believe I have all the other ports set to off but I will check again.

    No on the second part. Basically, you have to run the script a few times before it fully runs. You get random timeouts. Like I can run it immediately after a good run and it will timeout. It's weird. As you can see, it does print out debug statements, it did arm the drone and did launch it, but it's too unreliable for us to even demo this and because of that unpredictability, is just not safe to fly. That's what I'm trying to solve by eliminating the error so we can hunt down other bugs or issues.

    Edit: to clarify, every run throws the errors. Some runs timeout on vehicle connect but with the string of heartbeat errors and so our code doesn't run.

  10. munsterlander commented on Nov 25, 2021

    @munsterlander

    So definitely not the right way of doing this, but this stopped all the errors, lol, and it stopped it from timing out as well.

    Comment out lines 1250 and 1251 of https://github.com/dronekit/dronekit-python/blob/master/dronekit/__init__.py#L1250

    This suppressed all the errors (big no no - I know) but our drone flew from the script and then proceeded to run itself into a wall due to me forgetting to turn on RTK and obstacle avoidance - oops.

  11. bduva002 commented on Nov 26, 2021

    @bduva002
    Author

    Well there is more than one way to solve a problem. At least it's flying. Look out for those walls haha. You could add a check that looks at the rtk and obstacle avoidance Paramus in your dK script.

  12. munsterlander commented on Nov 26, 2021

    @munsterlander

    So Alvin figured out part of the issue here as well:
    https://discuss.cubepilot.org/t/connect-to-drone-via-herelink-and-drone-kit-python/7887/9?u=munsterlander

    In short, it's time to move on from Dronekit.

  13. bduva002 commented on Nov 26, 2021

    @bduva002
    Author

    Yeah, I wrote a whole data recorder with dK. It can be fical at times. I have started on the new lua script method. You might look into that. Lua scripts seem to work well so far.

  14. munsterlander commented on Nov 26, 2021

    @munsterlander

    Definitely will look at the options out there. I am using Python because our ground-based video system is running Python and so when it calculates lat/longs, it's easiest to just call another Python file and pass the values to the drone. Either way, we will need to address the tech stack for the future, but I am going to do a Pymavlink test right now. Thanks again for all your help and insight! It was very much appreciated.

  15. Captain299792458 commented on Jul 2, 2022

    @Captain299792458

    did anyone get a solve for this yet ??

  16. angela804 commented on Aug 9, 2022

    @angela804

    @munsterlander hello. Curious if you got past this.
    I'm using HereLink controller, Cube Orange and connected my cube Orange to Raspberry Pi's Rx and Tx

  17. pranav8112 commented on Nov 1, 2024

    @pranav8112

    @munsterlander hello. Curious if you got past this. I'm using HereLink controller, Cube Orange and connected my cube Orange to Raspberry Pi's Rx and Tx
    hi there , did you solved that error ...? i am using pixhawk cube plus orange

  18. munsterlander commented on Nov 2, 2024

    @munsterlander

    Sorry for missing the earlier posts. Yes, we did get passed it by commenting out those lines of code. Was it ideal, no, but it did work. We moved into a different platform, so I don't have much more than what was originally posted.

  19. angela804 commented on Nov 5, 2024

    @angela804

    @munsterlander hello. Curious if you got past this. I'm using HereLink controller, Cube Orange and connected my cube Orange to Raspberry Pi's Rx and Tx
    hi there , did you solved that error ...? i am using pixhawk cube plus orange

    don't know what's up with that warning. It's weird but disregarding the warning, I was still able to connect to the pixhawk and control the robot using the connected raspberry pi.
    you can find the source code for that and comment it so that it won't always appear.
    Moving to a different platform that what I previously used, that did not appear

  20. xianglic commented on Jan 15, 2025

    @xianglic

    I ran into the same issue. The difference is that I got the error on mode(0, 1) instead of the mode (0, 4). What does this mode(x, x) represent exactly?

  21. hamishwillee commented on Jan 19, 2025

    @hamishwillee
    Contributor

    This will map to https://mavlink.io/en/messages/common.html#SET_MODE or possibly https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_MODE "under the hood". The base mode is I believe largely ignored and the custom mode is flight stack specific.

    You can look at the source code in Pymavlink mavutil to determine the mode mappings for both ArduPilot and PX4. For recent PX4 you could dynamically determine the mapping using the standard modes API (But not through dronekit, since it is too out of date).

  22. Jaydenhep commented on Apr 16, 2025

    @Jaydenhep

    Disabling serial 5 from Mavlink 1 worked for me, running external scripts. I communicated over UART via telem 2 on Cube Orange with PixHawk on Mavlink2.

  23. ryochiji commented on Apr 3, 2026

    @ryochiji

    In case any other stubborn old souls trying to keep their DroneKit-based code alive stumbles on this, this issue is likely a duplicate of issue #1187 which was fixed in #1188.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions