Skip to content

Commit

Permalink
mavutil: cope with enum entry rename
Browse files Browse the repository at this point in the history
two entries were renamed in the MAV_TYPE enumeration.  Since mavutil uses those enumeration entries without checking if they exist, using the entries which no longer exist goes poorly.

Rename was done here: https://github.com/mavlink/mavlink/pull/1818/files
  • Loading branch information
peterbarker authored and tridge committed Jan 3, 2024
1 parent 69485b0 commit f2286dc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mavutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2114,8 +2114,6 @@ def mode_string_v09(msg):
mavlink.MAV_TYPE_COAXIAL: mode_mapping_acm,
# plane
mavlink.MAV_TYPE_FIXED_WING: mode_mapping_apm,
mavlink.MAV_TYPE_VTOL_DUOROTOR: mode_mapping_apm,
mavlink.MAV_TYPE_VTOL_QUADROTOR: mode_mapping_apm,
mavlink.MAV_TYPE_VTOL_TILTROTOR: mode_mapping_apm,
# rover
mavlink.MAV_TYPE_GROUND_ROVER: mode_mapping_rover,
Expand All @@ -2129,6 +2127,18 @@ def mode_string_v09(msg):
mavlink.MAV_TYPE_AIRSHIP: mode_mapping_blimp,
}

# cope with enumeration renaming:
for (name, some_map) in ([
# plane, see https://github.com/ArduPilot/pymavlink/issues/571
("MAV_TYPE_VTOL_DUOROTOR", mode_mapping_apm),
("MAV_TYPE_VTOL_TAILSITTER_DUOROTOR", mode_mapping_apm),
("MAV_TYPE_VTOL_QUADROTOR", mode_mapping_apm),
("MAV_TYPE_VTOL_TAILSITTER_QUADROTOR", mode_mapping_apm),
]):
try:
AP_MAV_TYPE_MODE_MAP_DEFAULT[getattr(mavlink, name)] = some_map
except AttributeError:
pass

try:
# Allow for using custom mode maps by importing a JSON dict from
Expand Down

0 comments on commit f2286dc

Please sign in to comment.