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);
|
cycleTime = getTaskDeltaTime(TASK_SELF);
|
||||||
dT = (float)cycleTime * 0.000001f;
|
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;
|
flightTime += cycleTime;
|
||||||
armTime += cycleTime;
|
armTime += cycleTime;
|
||||||
updateAccExtremes();
|
updateAccExtremes();
|
||||||
|
|
|
@ -1719,7 +1719,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_LAUNCH_WAIT(navigationF
|
||||||
const timeUs_t currentTimeUs = micros();
|
const timeUs_t currentTimeUs = micros();
|
||||||
UNUSED(previousState);
|
UNUSED(previousState);
|
||||||
|
|
||||||
if (isFixedWingLaunchDetected()) {
|
if (fixedWingLaunchStatus() == FW_LAUNCH_DETECTED) {
|
||||||
enableFixedWingLaunchController(currentTimeUs);
|
enableFixedWingLaunchController(currentTimeUs);
|
||||||
return NAV_FSM_EVENT_SUCCESS; // NAV_STATE_LAUNCH_IN_PROGRESS
|
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);
|
UNUSED(previousState);
|
||||||
|
|
||||||
if (isFixedWingLaunchFinishedOrAborted()) {
|
if (fixedWingLaunchStatus() >= FW_LAUNCH_END_ABORT) {
|
||||||
return NAV_FSM_EVENT_SUCCESS;
|
return NAV_FSM_EVENT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2579,11 +2579,11 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, climbRateToAlti
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If max altitude is set, reset climb rate if altitude is reached and climb rate is > 0
|
* 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
|
* 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 &&
|
altitudeToUse >= navConfig()->general.max_altitude &&
|
||||||
desiredClimbRate > 0
|
desiredClimbRate > 0
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -145,6 +145,14 @@ typedef enum {
|
||||||
ON_FW_SPIRAL,
|
ON_FW_SPIRAL,
|
||||||
} navRTHClimbFirst_e;
|
} 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 {
|
typedef struct positionEstimationConfig_s {
|
||||||
uint8_t automatic_mag_declination;
|
uint8_t automatic_mag_declination;
|
||||||
uint8_t reset_altitude_type; // from nav_reset_type_e
|
uint8_t reset_altitude_type; // from nav_reset_type_e
|
||||||
|
@ -533,8 +541,7 @@ bool navigationRTHAllowsLanding(void);
|
||||||
bool isWaypointMissionRTHActive(void);
|
bool isWaypointMissionRTHActive(void);
|
||||||
|
|
||||||
bool isNavLaunchEnabled(void);
|
bool isNavLaunchEnabled(void);
|
||||||
bool isFixedWingLaunchDetected(void);
|
uint8_t fixedWingLaunchStatus(void);
|
||||||
bool isFixedWingLaunchFinishedOrAborted(void);
|
|
||||||
const char * fixedWingLaunchStateMessage(void);
|
const char * fixedWingLaunchStateMessage(void);
|
||||||
|
|
||||||
float calculateAverageSpeed(void);
|
float calculateAverageSpeed(void);
|
||||||
|
|
|
@ -111,6 +111,7 @@ typedef struct fixedWingLaunchData_s {
|
||||||
} fixedWingLaunchData_t;
|
} fixedWingLaunchData_t;
|
||||||
|
|
||||||
static EXTENDED_FASTRAM fixedWingLaunchData_t fwLaunch;
|
static EXTENDED_FASTRAM fixedWingLaunchData_t fwLaunch;
|
||||||
|
static uint8_t launchStatus;
|
||||||
|
|
||||||
static const fixedWingLaunchStateDescriptor_t launchStateMachine[FW_LAUNCH_STATE_COUNT] = {
|
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);
|
UNUSED(currentTimeUs);
|
||||||
|
|
||||||
|
launchStatus = launchStatus == FW_LAUNCH_FLYING ? FW_LAUNCH_END_SUCCESS : FW_LAUNCH_END_ABORT;
|
||||||
|
|
||||||
return FW_LAUNCH_EVENT_NONE;
|
return FW_LAUNCH_EVENT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +272,8 @@ static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_WAIT_THROTTLE(timeUs
|
||||||
{
|
{
|
||||||
UNUSED(currentTimeUs);
|
UNUSED(currentTimeUs);
|
||||||
|
|
||||||
|
launchStatus = FW_LAUNCH_START;
|
||||||
|
|
||||||
if (!isThrottleLow()) {
|
if (!isThrottleLow()) {
|
||||||
if (isThrottleIdleEnabled()) {
|
if (isThrottleIdleEnabled()) {
|
||||||
return FW_LAUNCH_EVENT_SUCCESS;
|
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)
|
static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_DETECTED(timeUs_t currentTimeUs)
|
||||||
{
|
{
|
||||||
UNUSED(currentTimeUs);
|
UNUSED(currentTimeUs);
|
||||||
|
|
||||||
|
launchStatus = FW_LAUNCH_DETECTED;
|
||||||
|
|
||||||
// waiting for the navigation to move it to next step FW_LAUNCH_STATE_MOTOR_DELAY
|
// waiting for the navigation to move it to next step FW_LAUNCH_STATE_MOTOR_DELAY
|
||||||
applyThrottleIdleLogic(false);
|
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 elapsedTimeMs = currentStateElapsedMs(currentTimeUs);
|
||||||
const timeMs_t endTimeMs = navConfig()->fw.launch_end_time;
|
const timeMs_t endTimeMs = navConfig()->fw.launch_end_time;
|
||||||
|
|
||||||
|
launchStatus = FW_LAUNCH_FLYING; // considered a success if this far in launch sequence
|
||||||
|
|
||||||
if (areSticksDeflectedMoreThanPosHoldDeadband()) {
|
if (areSticksDeflectedMoreThanPosHoldDeadband()) {
|
||||||
return FW_LAUNCH_EVENT_ABORT; // cancel the launch and do the FW_LAUNCH_STATE_IDLE state
|
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);
|
setCurrentState(FW_LAUNCH_STATE_WAIT_THROTTLE, currentTimeUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFixedWingLaunchDetected(void)
|
|
||||||
{
|
|
||||||
return fwLaunch.currentState >= FW_LAUNCH_STATE_DETECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void enableFixedWingLaunchController(timeUs_t currentTimeUs)
|
void enableFixedWingLaunchController(timeUs_t currentTimeUs)
|
||||||
{
|
{
|
||||||
setCurrentState(FW_LAUNCH_STATE_MOTOR_DELAY, 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)
|
void abortFixedWingLaunch(void)
|
||||||
|
|
|
@ -455,9 +455,8 @@ void calculateFixedWingInitialHoldPosition(fpVector3_t * pos);
|
||||||
|
|
||||||
/* Fixed-wing launch controller */
|
/* Fixed-wing launch controller */
|
||||||
void resetFixedWingLaunchController(timeUs_t currentTimeUs);
|
void resetFixedWingLaunchController(timeUs_t currentTimeUs);
|
||||||
bool isFixedWingLaunchDetected(void);
|
|
||||||
void enableFixedWingLaunchController(timeUs_t currentTimeUs);
|
void enableFixedWingLaunchController(timeUs_t currentTimeUs);
|
||||||
bool isFixedWingLaunchFinishedOrAborted(void);
|
uint8_t fixedWingLaunchStatus(void);
|
||||||
void abortFixedWingLaunch(void);
|
void abortFixedWingLaunch(void);
|
||||||
void applyFixedWingLaunchController(timeUs_t currentTimeUs);
|
void applyFixedWingLaunchController(timeUs_t currentTimeUs);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue