Skip to content

Commit

Permalink
AP_GPS: confine inter-instance DroneCAN state checks to DroneCAN GPSs
Browse files Browse the repository at this point in the history
stop these looking at parameters/state for all GPSs, focus on DroneCAN GPSs
  • Loading branch information
peterbarker authored and tridge committed Jul 1, 2024
1 parent ebfbcac commit 42805aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
23 changes: 8 additions & 15 deletions libraries/AP_GPS/AP_GPS_DroneCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,13 @@ AP_GPS_Backend* AP_GPS_DroneCAN::probe(AP_GPS &_gps, AP_GPS::GPS_State &_state)

bool AP_GPS_DroneCAN::inter_instance_pre_arm_checks(char failure_msg[], uint16_t failure_msg_len)
{
// only do these checks if there is at least one DroneCAN GPS:
bool found_uavan_type = false;
for (uint8_t i = 0; i < GPS_MAX_RECEIVERS; i++) {
const auto type = AP::gps().params[i].type;
if (type != AP_GPS::GPS_TYPE_UAVCAN &&
type != AP_GPS::GPS_TYPE_UAVCAN_RTK_BASE &&
type != AP_GPS::GPS_TYPE_UAVCAN_RTK_ROVER) {
continue;
}
found_uavan_type = true;
}
if (!found_uavan_type) {
return true;
}

// lint parameters and detected node IDs:
for (uint8_t i = 0; i < GPS_MAX_RECEIVERS; i++) {
const auto &params_i = AP::gps().params[i];
// we are only interested in parameters for DroneCAN GPSs:
if (!is_dronecan_gps_type(params_i.type)) {
continue;
}
bool overriden_node_found = false;
bool bad_override_config = false;
if (params_i.override_node_id == 0) {
Expand All @@ -253,6 +242,10 @@ bool AP_GPS_DroneCAN::inter_instance_pre_arm_checks(char failure_msg[], uint16_t
}
for (uint8_t j = 0; j < GPS_MAX_RECEIVERS; j++) {
const auto &params_j = AP::gps().params[j];
// we are only interested in parameters for DroneCAN GPSs:
if (!is_dronecan_gps_type(params_j.type)) {
continue;
}
if (params_i.override_node_id == params_j.override_node_id && (i != j)) {
bad_override_config = true;
break;
Expand Down
9 changes: 9 additions & 0 deletions libraries/AP_GPS/AP_GPS_DroneCAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ class AP_GPS_DroneCAN : public AP_GPS_Backend {
uint32_t last_send_ms;
ByteBuffer *buf;
} _rtcm_stream;

// returns true if the supplied GPS_Type is a DroneCAN GPS type
static bool is_dronecan_gps_type(AP_GPS::GPS_Type type) {
return (
type == AP_GPS::GPS_TYPE_UAVCAN ||
type == AP_GPS::GPS_TYPE_UAVCAN_RTK_BASE ||
type == AP_GPS::GPS_TYPE_UAVCAN_RTK_ROVER
);
}
};

#endif // AP_GPS_DRONECAN_ENABLED

0 comments on commit 42805aa

Please sign in to comment.