mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 09:45:33 +03:00
Initial build
This commit is contained in:
parent
2fcb1cb83d
commit
11bc2a4648
5 changed files with 27 additions and 16 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -2579,11 +2579,11 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, climbRateToAlti
|
|||
}
|
||||
else {
|
||||
|
||||
/*
|
||||
/*
|
||||
* If max altitude is set, reset climb rate if altitude is reached and climb rate is > 0
|
||||
* In other words, when altitude is reached, allow it only to shrink
|
||||
*/
|
||||
if (navConfig()->general.max_altitude > 0 &&
|
||||
if (navConfig()->general.max_altitude > 0 &&
|
||||
altitudeToUse >= navConfig()->general.max_altitude &&
|
||||
desiredClimbRate > 0
|
||||
) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue