Browse Source

SITL: add reverse thrust to Plane Sim

mission-4.1.18
Tom Pittenger 9 years ago committed by Andrew Tridgell
parent
commit
f20841f491
  1. 14
      libraries/SITL/SIM_Plane.cpp
  2. 1
      libraries/SITL/SIM_Plane.h

14
libraries/SITL/SIM_Plane.cpp

@ -35,6 +35,10 @@ Plane::Plane(const char *home_str, const char *frame_str) : @@ -35,6 +35,10 @@ Plane::Plane(const char *home_str, const char *frame_str) :
*/
thrust_scale = (mass * GRAVITY_MSS) / hover_throttle;
frame_height = 0.1f;
if (strstr(frame_str, "-revthrust")) {
reverse_thrust = true;
}
}
/*
@ -190,7 +194,13 @@ void Plane::calculate_forces(const struct sitl_input &input, Vector3f &rot_accel @@ -190,7 +194,13 @@ void Plane::calculate_forces(const struct sitl_input &input, Vector3f &rot_accel
float aileron = (input.servos[0]-1500)/500.0f;
float elevator = (input.servos[1]-1500)/500.0f;
float rudder = (input.servos[3]-1500)/500.0f;
float throttle = constrain_float((input.servos[2]-1000)/1000.0f, 0, 1);
float throttle;
if (reverse_thrust) {
throttle = constrain_float((input.servos[2]-1500)/500.0f, -1, 1);
} else {
throttle = constrain_float((input.servos[2]-1000)/1000.0f, 0, 1);
}
float thrust = throttle;
@ -211,7 +221,7 @@ void Plane::calculate_forces(const struct sitl_input &input, Vector3f &rot_accel @@ -211,7 +221,7 @@ void Plane::calculate_forces(const struct sitl_input &input, Vector3f &rot_accel
accel_body += force;
// add some noise
add_noise(thrust / thrust_scale);
add_noise(fabsf(thrust) / thrust_scale);
}
/*

1
libraries/SITL/SIM_Plane.h

@ -92,6 +92,7 @@ protected: @@ -92,6 +92,7 @@ protected:
} coefficient;
float thrust_scale;
bool reverse_thrust;
float liftCoeff(float alpha) const;
float dragCoeff(float alpha) const;

Loading…
Cancel
Save