Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Tools/scripts/build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ def config_option(self):
Feature('GPS Drivers', 'GSOF', 'AP_GPS_GSOF_ENABLED', 'Enable GSOF GPS', 0, None),
Feature('GPS Drivers', 'NMEA_GPS', 'AP_GPS_NMEA_ENABLED', 'Enable NMEA GPS', 0, None),
Feature('GPS Drivers', 'NMEA_UNICORE', 'AP_GPS_NMEA_UNICORE_ENABLED', 'Enable NMEA Unicore GPS', 0, "NMEA_GPS"),
Feature('GPS Drivers', 'NMEA_QUECTEL', 'AP_GPS_NMEA_QUECTEL_ENABLED', 'Enable NMEA Quectel GPS', 0, "NMEA_GPS"),
Feature('GPS Drivers', 'MAV', 'AP_GPS_MAV_ENABLED', 'Enable MAVLink GPS', 0, None),
Feature('GPS Drivers', 'NOVA', 'AP_GPS_NOVA_ENABLED', 'Enable NOVA GPS', 0, None),
Feature('GPS Drivers', 'SBF', 'AP_GPS_SBF_ENABLED', 'Enable SBF GPS', 0, None),
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/decode_devid.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def num(s):
0x3B : "DEVTYPE_INS_ICM45686",
0x3C : "DEVTYPE_INS_SCHA63T",
0x3D : "DEVTYPE_INS_IIM42653",
0x3E : "DEVTYPE_INS_SCH16T",
}

baro_types = {
Expand Down
6 changes: 6 additions & 0 deletions Tools/scripts/extract_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def __init__(self, filename, nm="arm-none-eabi-nm", strings="strings"):
('AP_RANGEFINDER_LIGHTWARE_GRF_ENABLED', 'AP_RangeFinder_LightWareGRF::get_reading'),

('AP_GPS_NMEA_UNICORE_ENABLED', r'AP_GPS_NMEA::parse_agrica_field',),
('AP_GPS_NMEA_QUECTEL_ENABLED', r'AP_GPS_NMEA::parse_pqtmver_field',),
('AP_GPS_NMEA_QUECTEL_ENABLED', r'AP_GPS_NMEA::parse_pqtmepe_field',),
('AP_GPS_NMEA_QUECTEL_ENABLED', r'AP_GPS_NMEA::parse_pqtmvel_field',),
('AP_GPS_NMEA_QUECTEL_ENABLED', r'AP_GPS_NMEA::parse_pqtmpvt_field',),
('AP_GPS_NMEA_QUECTEL_ENABLED', r'AP_GPS_NMEA::parse_pqtmtar_field',),

('AP_GPS_{type}_ENABLED', r'AP_GPS_(?P<type>.*)::read\b',),

('AP_OPTICALFLOW_ENABLED', 'AP_OpticalFlow::AP_OpticalFlow',),
Expand Down
5 changes: 5 additions & 0 deletions config_and_rebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# git clone --recurse-submodules git@github.com:vidma/ardupilot.git
#./waf configure --board=MambaF405-2022 && ./waf clean && ./waf plane

# ./waf configure --board=Pixhawk6X && ./waf clean && ./waf plane
./waf configure --board=MicoAir743-Lite && ./waf clean && ./waf plane
45 changes: 45 additions & 0 deletions libraries/AP_GPS/AP_GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,9 @@ AP_GPS_Backend *AP_GPS::_detect_instance(const uint8_t instance)
#if AP_GPS_NMEA_UNICORE_ENABLED
type == GPS_TYPE_UNICORE_NMEA ||
type == GPS_TYPE_UNICORE_MOVINGBASE_NMEA ||
#endif
#if AP_GPS_NMEA_QUECTEL_ENABLED
type == GPS_TYPE_QUECTEL_NMEA ||
#endif
type == GPS_TYPE_ALLYSTAR) &&
AP_GPS_NMEA::_detect(dstate->nmea_detect_state, data)) {
Expand Down Expand Up @@ -1950,6 +1953,48 @@ void AP_GPS::Write_GPS(uint8_t i)
};
AP::logger().WriteBlock(&pkt2, sizeof(pkt2));
}

void AP_GPS::Write_PPS(uint64_t interrupt_time_us, uint64_t earlier_interrupt_time_us)
{

const uint64_t USEC_PER_SEC = 1000000ULL;
const float clock_drift_percent = (((float)interrupt_time_us - (float)earlier_interrupt_time_us) - (float)USEC_PER_SEC) * 100.0f / ((float)USEC_PER_SEC);

// FIXME: should it be dependent on GPS instance? but makes little sense
uint8_t instance = 0; // FIXME?

const GPS_State &istate = state[instance];

// it makes no sense to report PPS if there's no GPS FIX
if ((istate.last_gps_time_ms == 0 && istate.last_corrected_gps_time_us == 0) || istate.time_week == 0) {
return;
}
uint64_t _last_gps_systime_us = istate.last_gps_time_ms * 1000ULL; ///< the system time we got the last GPS timestamp, microseconds

// FIXME: check if fix still exists!?
uint64_t last_gps_fix_time_us = istate_time_to_epoch_ms(istate.time_week, istate.time_week_ms) * 1000ULL; // last GPS time

// GPS UTC time when the GPIO interrupt was triggered
// Last UTC time received from the GPS + elapsed time to the PPS interrupt

// FIXME: I possibly don't understand what this correction is used for? (based on PX4 PPSCpature driver)
// oh it's probably needed in case the GPS time was not received but PPS still fired?
uint64_t gps_utc_time_us = last_gps_fix_time_us + (interrupt_time_us - _last_gps_systime_us);

// (For ubx F9P and NMEA Quectel LG580P) The rising edge of the PPS pulse is aligned to the top of second GPS time base.
// So, remove the fraction of second and shift to the next second. The interrupt is triggered
// before the matching timestamp is received via a UART message, which means the last received GPS time is always
// behind.
const uint64_t corrected_utc_time_us = gps_utc_time_us - (gps_utc_time_us % USEC_PER_SEC) + USEC_PER_SEC;

struct log_PPS pkt {
LOG_PACKET_HEADER_INIT(LOG_PPS_MSG),
time_us : interrupt_time_us,
utc_time_ms : corrected_utc_time_us / 1000ULL,
clock_drift_percent : clock_drift_percent
};
AP::logger().WriteBlock(&pkt, sizeof(pkt));
}
#endif

bool AP_GPS::is_rtk_base(uint8_t instance) const
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_GPS/AP_GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class AP_GPS
GPS_TYPE_UNICORE_NMEA = 24,
GPS_TYPE_UNICORE_MOVINGBASE_NMEA = 25,
GPS_TYPE_SBF_DUAL_ANTENNA = 26,
GPS_TYPE_QUECTEL_NMEA = 27,
#if AP_SIM_GPS_ENABLED
GPS_TYPE_SITL = 100,
#endif
Expand Down Expand Up @@ -791,6 +792,8 @@ class AP_GPS
// logging support
void Write_GPS(uint8_t instance);

void Write_PPS(uint64_t interrupt_time_us, uint64_t earlier_interrupt_time_us);

#if AP_GPS_RTCM_DECODE_ENABLED
/*
per mavlink channel RTCM decoder, enabled with RTCM decode
Expand Down
Loading
Loading