1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 09:45:33 +03:00

Initial build

This commit is contained in:
breadoven 2021-06-03 17:28:04 +01:00
parent 2fcb1cb83d
commit 11bc2a4648
5 changed files with 27 additions and 16 deletions

View file

@ -845,7 +845,7 @@ void taskMainPidLoop(timeUs_t currentTimeUs)
cycleTime = getTaskDeltaTime(TASK_SELF);
dT = (float)cycleTime * 0.000001f;
if (ARMING_FLAG(ARMED) && (!STATE(FIXED_WING_LEGACY) || !isNavLaunchEnabled() || (isNavLaunchEnabled() && (isFixedWingLaunchDetected() || isFixedWingLaunchFinishedOrAborted())))) {
if (ARMING_FLAG(ARMED) && (!STATE(FIXED_WING_LEGACY) || !isNavLaunchEnabled() || (isNavLaunchEnabled() && fixedWingLaunchStatus() > FW_LAUNCH_START))) {
flightTime += cycleTime;
armTime += cycleTime;
updateAccExtremes();

View file

@ -1719,7 +1719,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_LAUNCH_WAIT(navigationF
const timeUs_t currentTimeUs = micros();
UNUSED(previousState);
if (isFixedWingLaunchDetected()) {
if (fixedWingLaunchStatus() == FW_LAUNCH_DETECTED) {
enableFixedWingLaunchController(currentTimeUs);
return NAV_FSM_EVENT_SUCCESS; // NAV_STATE_LAUNCH_IN_PROGRESS
}
@ -1740,7 +1740,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_LAUNCH_IN_PROGRESS(navi
{
UNUSED(previousState);
if (isFixedWingLaunchFinishedOrAborted()) {
if (fixedWingLaunchStatus() >= FW_LAUNCH_END_ABORT) {
return NAV_FSM_EVENT_SUCCESS;
}

View file

@ -145,6 +145,14 @@ typedef enum {
ON_FW_SPIRAL,
} navRTHClimbFirst_e;
typedef enum {
FW_LAUNCH_START,
FW_LAUNCH_DETECTED,
FW_LAUNCH_FLYING,
FW_LAUNCH_END_ABORT,
FW_LAUNCH_END_SUCCESS,
} navFwLaunchStatus_e;
typedef struct positionEstimationConfig_s {
uint8_t automatic_mag_declination;
uint8_t reset_altitude_type; // from nav_reset_type_e
@ -533,8 +541,7 @@ bool navigationRTHAllowsLanding(void);
bool isWaypointMissionRTHActive(void);
bool isNavLaunchEnabled(void);
bool isFixedWingLaunchDetected(void);
bool isFixedWingLaunchFinishedOrAborted(void);
uint8_t fixedWingLaunchStatus(void);
const char * fixedWingLaunchStateMessage(void);
float calculateAverageSpeed(void);

View file

@ -111,6 +111,7 @@ typedef struct fixedWingLaunchData_s {
} fixedWingLaunchData_t;
static EXTENDED_FASTRAM fixedWingLaunchData_t fwLaunch;
static uint8_t launchStatus;
static const fixedWingLaunchStateDescriptor_t launchStateMachine[FW_LAUNCH_STATE_COUNT] = {
@ -262,6 +263,8 @@ static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_IDLE(timeUs_t curren
{
UNUSED(currentTimeUs);
launchStatus = launchStatus == FW_LAUNCH_FLYING ? FW_LAUNCH_END_SUCCESS : FW_LAUNCH_END_ABORT;
return FW_LAUNCH_EVENT_NONE;
}
@ -269,6 +272,8 @@ static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_WAIT_THROTTLE(timeUs
{
UNUSED(currentTimeUs);
launchStatus = FW_LAUNCH_START;
if (!isThrottleLow()) {
if (isThrottleIdleEnabled()) {
return FW_LAUNCH_EVENT_SUCCESS;
@ -336,6 +341,9 @@ static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_WAIT_DETECTION(timeU
static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_DETECTED(timeUs_t currentTimeUs)
{
UNUSED(currentTimeUs);
launchStatus = FW_LAUNCH_DETECTED;
// waiting for the navigation to move it to next step FW_LAUNCH_STATE_MOTOR_DELAY
applyThrottleIdleLogic(false);
@ -403,6 +411,8 @@ static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_FINISH(timeUs_t curr
const timeMs_t elapsedTimeMs = currentStateElapsedMs(currentTimeUs);
const timeMs_t endTimeMs = navConfig()->fw.launch_end_time;
launchStatus = FW_LAUNCH_FLYING; // considered a success if this far in launch sequence
if (areSticksDeflectedMoreThanPosHoldDeadband()) {
return FW_LAUNCH_EVENT_ABORT; // cancel the launch and do the FW_LAUNCH_STATE_IDLE state
}
@ -450,19 +460,14 @@ void resetFixedWingLaunchController(timeUs_t currentTimeUs)
setCurrentState(FW_LAUNCH_STATE_WAIT_THROTTLE, currentTimeUs);
}
bool isFixedWingLaunchDetected(void)
{
return fwLaunch.currentState >= FW_LAUNCH_STATE_DETECTED;
}
void enableFixedWingLaunchController(timeUs_t currentTimeUs)
{
setCurrentState(FW_LAUNCH_STATE_MOTOR_DELAY, currentTimeUs);
}
bool isFixedWingLaunchFinishedOrAborted(void)
uint8_t fixedWingLaunchStatus(void)
{
return fwLaunch.currentState == FW_LAUNCH_STATE_IDLE;
return launchStatus;
}
void abortFixedWingLaunch(void)

View file

@ -455,9 +455,8 @@ void calculateFixedWingInitialHoldPosition(fpVector3_t * pos);
/* Fixed-wing launch controller */
void resetFixedWingLaunchController(timeUs_t currentTimeUs);
bool isFixedWingLaunchDetected(void);
void enableFixedWingLaunchController(timeUs_t currentTimeUs);
bool isFixedWingLaunchFinishedOrAborted(void);
uint8_t fixedWingLaunchStatus(void);
void abortFixedWingLaunch(void);
void applyFixedWingLaunchController(timeUs_t currentTimeUs);