Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mavutil: cope with enum entry rename #898

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading