diff --git a/libraries/SITL/SIM_Aircraft.cpp b/libraries/SITL/SIM_Aircraft.cpp index d809d6a481..8f15f12e91 100644 --- a/libraries/SITL/SIM_Aircraft.cpp +++ b/libraries/SITL/SIM_Aircraft.cpp @@ -508,6 +508,19 @@ void Aircraft::update_dynamics(const Vector3f &rot_accel) use_smoothing = true; break; } + case GROUND_BEHAVIOR_TAILSITTER: { + // point straight up + float r, p, y; + dcm.to_euler(&r, &p, &y); + dcm.from_euler(0.0f, radians(90), y); + // no movement + if (accel_earth.z > -1.1*GRAVITY_MSS) { + velocity_ef.zero(); + } + gyro.zero(); + use_smoothing = true; + break; + } } } } diff --git a/libraries/SITL/SIM_Aircraft.h b/libraries/SITL/SIM_Aircraft.h index 2a70a865c2..7d14528d9b 100644 --- a/libraries/SITL/SIM_Aircraft.h +++ b/libraries/SITL/SIM_Aircraft.h @@ -163,6 +163,7 @@ protected: GROUND_BEHAVIOR_NONE = 0, GROUND_BEHAVIOR_NO_MOVEMENT, GROUND_BEHAVIOR_FWD_ONLY, + GROUND_BEHAVIOR_TAILSITTER, } ground_behavior; bool use_smoothing; diff --git a/libraries/SITL/SIM_Plane.cpp b/libraries/SITL/SIM_Plane.cpp index ca516ee54f..b977cd588c 100644 --- a/libraries/SITL/SIM_Plane.cpp +++ b/libraries/SITL/SIM_Plane.cpp @@ -35,6 +35,8 @@ Plane::Plane(const char *home_str, const char *frame_str) : thrust_scale = (mass * GRAVITY_MSS) / hover_throttle; frame_height = 0.1f; + ground_behavior = GROUND_BEHAVIOR_FWD_ONLY; + if (strstr(frame_str, "-heavy")) { mass = 8; } @@ -49,8 +51,12 @@ Plane::Plane(const char *home_str, const char *frame_str) : if (strstr(frame_str, "-elevrev")) { reverse_elevator_rudder = true; } + if (strstr(frame_str, "-tailsitter")) { + tailsitter = true; + ground_behavior = GROUND_BEHAVIOR_TAILSITTER; + thrust_scale *= 1.5; + } - ground_behavior = GROUND_BEHAVIOR_FWD_ONLY; if (strstr(frame_str, "-ice")) { ice_engine = true; } @@ -266,7 +272,7 @@ void Plane::calculate_forces(const struct sitl_input &input, Vector3f &rot_accel add_noise(fabsf(thrust) / thrust_scale); } - if (on_ground()) { + if (on_ground() && !tailsitter) { // add some ground friction Vector3f vel_body = dcm.transposed() * velocity_ef; accel_body.x -= vel_body.x * 0.3f; diff --git a/libraries/SITL/SIM_Plane.h b/libraries/SITL/SIM_Plane.h index 4c86b8b4e0..d9b4cc7de6 100644 --- a/libraries/SITL/SIM_Plane.h +++ b/libraries/SITL/SIM_Plane.h @@ -97,6 +97,7 @@ protected: bool vtail; bool reverse_elevator_rudder; bool ice_engine; + bool tailsitter; ICEngine icengine{2, 14, 12, 13, 100};