Browse Source

SITL: only report ground contact at most once per second

master
Andrew Tridgell 9 years ago
parent
commit
62b2a2117d
  1. 3
      libraries/SITL/SIM_Aircraft.cpp
  2. 1
      libraries/SITL/SIM_Aircraft.h

3
libraries/SITL/SIM_Aircraft.cpp

@ -359,8 +359,9 @@ void Aircraft::update_dynamics(const Vector3f &rot_accel) @@ -359,8 +359,9 @@ void Aircraft::update_dynamics(const Vector3f &rot_accel)
// constrain height to the ground
if (on_ground(position)) {
if (!on_ground(old_position)) {
if (!on_ground(old_position) && AP_HAL::millis() - last_ground_contact_ms > 1000) {
printf("Hit ground at %f m/s\n", velocity_ef.z);
last_ground_contact_ms = AP_HAL::millis();
}
position.z = -(ground_level + frame_height - home.alt*0.01f);
}

1
libraries/SITL/SIM_Aircraft.h

@ -159,6 +159,7 @@ protected: @@ -159,6 +159,7 @@ protected:
private:
uint64_t last_time_us = 0;
uint32_t frame_counter = 0;
uint32_t last_ground_contact_ms;
const uint32_t min_sleep_time;
};

Loading…
Cancel
Save