mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 15:53:56 -04:00
AP_TECS: use 64 bit micros
prevent possible wrap if TECS is not run for a long time
This commit is contained in:
parent
e006754cda
commit
e698d1f47e
@ -274,8 +274,8 @@ void AP_TECS::update_50hz(void)
|
||||
}
|
||||
|
||||
// Calculate time in seconds since last update
|
||||
uint32_t now = AP_HAL::micros();
|
||||
float DT = MAX((now - _update_50hz_last_usec), 0U) * 1.0e-6f;
|
||||
uint64_t now = AP_HAL::micros64();
|
||||
float DT = (now - _update_50hz_last_usec) * 1.0e-6f;
|
||||
if (DT > 1.0f) {
|
||||
_climb_rate = 0.0f;
|
||||
_height_filter.dd_height = 0.0f;
|
||||
@ -332,8 +332,8 @@ void AP_TECS::update_50hz(void)
|
||||
void AP_TECS::_update_speed(float load_factor)
|
||||
{
|
||||
// Calculate time in seconds since last update
|
||||
uint32_t now = AP_HAL::micros();
|
||||
float DT = MAX((now - _update_speed_last_usec), 0U) * 1.0e-6f;
|
||||
uint64_t now = AP_HAL::micros64();
|
||||
float DT = (now - _update_speed_last_usec) * 1.0e-6f;
|
||||
_update_speed_last_usec = now;
|
||||
|
||||
// Convert equivalent airspeeds to true airspeeds
|
||||
@ -900,8 +900,8 @@ void AP_TECS::update_pitch_throttle(int32_t hgt_dem_cm,
|
||||
float load_factor)
|
||||
{
|
||||
// Calculate time in seconds since last update
|
||||
uint32_t now = AP_HAL::micros();
|
||||
_DT = MAX((now - _update_pitch_throttle_last_usec), 0U) * 1.0e-6f;
|
||||
uint64_t now = AP_HAL::micros64();
|
||||
_DT = (now - _update_pitch_throttle_last_usec) * 1.0e-6f;
|
||||
_update_pitch_throttle_last_usec = now;
|
||||
|
||||
_flags.is_doing_auto_land = is_doing_auto_land;
|
||||
|
@ -131,13 +131,13 @@ public:
|
||||
|
||||
private:
|
||||
// Last time update_50Hz was called
|
||||
uint32_t _update_50hz_last_usec;
|
||||
uint64_t _update_50hz_last_usec;
|
||||
|
||||
// Last time update_speed was called
|
||||
uint32_t _update_speed_last_usec;
|
||||
uint64_t _update_speed_last_usec;
|
||||
|
||||
// Last time update_pitch_throttle was called
|
||||
uint32_t _update_pitch_throttle_last_usec;
|
||||
uint64_t _update_pitch_throttle_last_usec;
|
||||
|
||||
// reference to the AHRS object
|
||||
AP_AHRS &_ahrs;
|
||||
|
Loading…
Reference in New Issue
Block a user