Added Throw Launch feature

More details in the PR: https://github.com/PX4/PX4-Autopilot/pull/21170

Signed-off-by: Michał Barciś <mbarcis@mbarcis.net>
This commit is contained in:
Michał Barciś
2023-11-13 11:57:19 +01:00
committed by Matthias Grob
parent 84577ce2c2
commit c2b4f051f9
5 changed files with 110 additions and 10 deletions
@@ -39,6 +39,7 @@
#include <mathlib/mathlib.h>
#include <lib/geo/geo.h>
void TakeoffHandling::generateInitialRampValue(float velocity_p_gain)
{
velocity_p_gain = math::max(velocity_p_gain, 0.01f);
@@ -74,6 +75,9 @@ void TakeoffHandling::updateTakeoffState(const bool armed, const bool landed, co
_takeoff_state = TakeoffState::rampup;
_takeoff_ramp_progress = 0.f;
} else if (!landed) {
_takeoff_state = TakeoffState::flight;
} else {
break;
}
@@ -103,7 +107,6 @@ void TakeoffHandling::updateTakeoffState(const bool armed, const bool landed, co
_takeoff_state = TakeoffState::flight;
}
// TODO: need to consider free fall here
if (!armed) {
_takeoff_state = TakeoffState::disarmed;
}
@@ -53,15 +53,15 @@ TEST(TakeoffTest, RegularTakeoffRamp)
takeoff.updateTakeoffState(false, true, false, 1.f, false, 0);
EXPECT_EQ(takeoff.getTakeoffState(), TakeoffState::disarmed);
// armed, not landed anymore, don't want takeoff
takeoff.updateTakeoffState(true, false, false, 1.f, false, 500_ms);
// armed, landed, don't want takeoff
takeoff.updateTakeoffState(true, true, false, 1.f, false, 500_ms);
EXPECT_EQ(takeoff.getTakeoffState(), TakeoffState::spoolup);
// armed, not landed, don't want takeoff yet, spoolup time passed
takeoff.updateTakeoffState(true, false, false, 1.f, false, 2_s);
// armed, landed, don't want takeoff yet, spoolup time passed
takeoff.updateTakeoffState(true, true, false, 1.f, false, 2_s);
EXPECT_EQ(takeoff.getTakeoffState(), TakeoffState::ready_for_takeoff);
// armed, not landed, want takeoff
// armed, not landed anymore, want takeoff
takeoff.updateTakeoffState(true, false, true, 1.f, false, 3_s);
EXPECT_EQ(takeoff.getTakeoffState(), TakeoffState::rampup);