From f1c23dc9be3c3a48e576d029c1b7abb8479d3d9a Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 23 Nov 2016 11:15:58 +1100 Subject: [PATCH] SITL: remove argument to on_ground This was always the current position --- libraries/SITL/SIM_Aircraft.cpp | 12 ++++++------ libraries/SITL/SIM_Aircraft.h | 2 +- libraries/SITL/SIM_Plane.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/SITL/SIM_Aircraft.cpp b/libraries/SITL/SIM_Aircraft.cpp index 2c7b1e6c15..eb6f327eb0 100644 --- a/libraries/SITL/SIM_Aircraft.cpp +++ b/libraries/SITL/SIM_Aircraft.cpp @@ -135,9 +135,9 @@ float Aircraft::ground_height_difference() const /* return true if we are on the ground */ -bool Aircraft::on_ground(const Vector3f &pos) const +bool Aircraft::on_ground() const { - return (-pos.z) + home.alt*0.01f <= ground_level + frame_height + ground_height_difference(); + return (-position.z) + home.alt*0.01f <= ground_level + frame_height + ground_height_difference(); } /* @@ -435,7 +435,7 @@ void Aircraft::update_dynamics(const Vector3f &rot_accel) // if we're on the ground, then our vertical acceleration is limited // to zero. This effectively adds the force of the ground on the aircraft - if (on_ground(position) && accel_earth.z > 0) { + if (on_ground() && accel_earth.z > 0) { accel_earth.z = 0; } @@ -446,7 +446,7 @@ void Aircraft::update_dynamics(const Vector3f &rot_accel) // new velocity vector velocity_ef += accel_earth * delta_time; - const bool was_on_ground = on_ground(position); + const bool was_on_ground = on_ground(); // new position vector position += velocity_ef * delta_time; @@ -463,7 +463,7 @@ void Aircraft::update_dynamics(const Vector3f &rot_accel) airspeed_pitot = constrain_float(velocity_air_bf * Vector3f(1, 0, 0), 0, 120); // constrain height to the ground - if (on_ground(position)) { + if (on_ground()) { if (!was_on_ground && 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(); @@ -522,7 +522,7 @@ void Aircraft::update_wind(const struct sitl_input &input) const float wind_turb = input.wind.turbulence * 10.0; // scale input.wind.turbulence to match standard deviation when using iir_coef=0.98 const float iir_coef = 0.98; // filtering high frequencies from turbulence - if (wind_turb > 0 && !on_ground(position)) { + if (wind_turb > 0 && !on_ground()) { turbulence_azimuth = turbulence_azimuth + (2 * rand()); diff --git a/libraries/SITL/SIM_Aircraft.h b/libraries/SITL/SIM_Aircraft.h index 660e51a052..24436387fc 100644 --- a/libraries/SITL/SIM_Aircraft.h +++ b/libraries/SITL/SIM_Aircraft.h @@ -171,7 +171,7 @@ protected: const float FEET_TO_METERS = 0.3048f; const float KNOTS_TO_METERS_PER_SECOND = 0.51444f; - bool on_ground(const Vector3f &pos) const; + bool on_ground() const; /* update location from position */ void update_position(void); diff --git a/libraries/SITL/SIM_Plane.cpp b/libraries/SITL/SIM_Plane.cpp index 9fab2c6731..f9015a63c3 100644 --- a/libraries/SITL/SIM_Plane.cpp +++ b/libraries/SITL/SIM_Plane.cpp @@ -263,7 +263,7 @@ void Plane::calculate_forces(const struct sitl_input &input, Vector3f &rot_accel add_noise(fabsf(thrust) / thrust_scale); } - if (on_ground(position)) { + if (on_ground()) { // add some ground friction Vector3f vel_body = dcm.transposed() * velocity_ef; accel_body.x -= vel_body.x * 0.3f;