-
-
Notifications
You must be signed in to change notification settings - Fork 117
Add alti limiter For french Regulation #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
001a26c
da6ead7
ed102bb
3c018a9
80add07
58875fb
a354584
9488654
c930f3a
871288c
4bad358
02a62cb
c47bc2e
35d3ca4
9c55522
d019f89
6619aac
ea229e6
00b51c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,10 @@ | |
|
|
||
| #include "io/motors.h" | ||
|
|
||
| #ifdef USE_BARO | ||
| #include "io/gps.h" | ||
| #endif | ||
|
|
||
| #include "fc/config.h" | ||
| #include "fc/controlrate_profile.h" | ||
| #include "fc/rc_controls.h" | ||
|
|
@@ -62,9 +66,12 @@ | |
| #include "flight/mixer.h" | ||
| #include "flight/mixer_tricopter.h" | ||
| #include "flight/pid.h" | ||
| #include "flight/position.h" | ||
|
|
||
| #include "rx/rx.h" | ||
|
|
||
| #ifdef USE_BARO | ||
| #include "sensors/barometer.h" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a few have barometer.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok got it ! thanks @gretel i will improve this |
||
| #endif | ||
| #include "sensors/battery.h" | ||
| #include "sensors/gyro.h" | ||
|
|
||
|
|
@@ -74,11 +81,14 @@ PG_REGISTER_WITH_RESET_TEMPLATE(mixerConfig_t, mixerConfig, PG_MIXER_CONFIG, 0); | |
| #define TARGET_DEFAULT_MIXER MIXER_QUADX | ||
| #endif | ||
| PG_RESET_TEMPLATE(mixerConfig_t, mixerConfig, | ||
| .mixerMode = TARGET_DEFAULT_MIXER, | ||
| .yaw_motors_reversed = false, | ||
| .crashflip_motor_percent = 0, | ||
| .crashflip_power_percent = 70, | ||
| ); | ||
| .mixerMode = TARGET_DEFAULT_MIXER, | ||
| .yaw_motors_reversed = false, | ||
| .crashflip_motor_percent = 0, | ||
| .crashflip_power_percent = 70, | ||
| .alti_cutoff = 50, | ||
| .alti_start_lim = 40, | ||
| .altiLimiter = false | ||
| ); | ||
|
|
||
| PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 1); | ||
|
|
||
|
|
@@ -129,6 +139,9 @@ float motor_disarmed[MAX_SUPPORTED_MOTORS]; | |
| mixerMode_e currentMixerMode; | ||
| static motorMixer_t currentMixer[MAX_SUPPORTED_MOTORS]; | ||
|
|
||
| static uint8_t altiLimStatus = 0; | ||
|
|
||
|
|
||
| static FAST_RAM_ZERO_INIT int throttleAngleCorrection; | ||
|
|
||
|
|
||
|
|
@@ -825,6 +838,30 @@ FAST_CODE_NOINLINE void mixTable(timeUs_t currentTimeUs) { | |
| } | ||
| #endif | ||
| loggingThrottle = throttle; | ||
|
|
||
| #if defined(USE_BARO) || defined(USE_GPS) | ||
| if(isAltiLimit()){ | ||
| if(((gpsIsHealthy() && gpsSol.numSat > 7) || isBaroReady()) | ||
| && (mixerConfig()->alti_cutoff > 0 && mixerConfig()->alti_start_lim > 0)){ | ||
| if (getEstimatedAltitude() > (mixerConfig()->alti_cutoff*100)){ | ||
| throttle = 0.0f; | ||
| altiLimStatus = 1; | ||
| }else if(getEstimatedAltitude() > (mixerConfig()->alti_start_lim*100)){ | ||
| float limitingRatio = 0.4f * ((mixerConfig()->alti_cutoff*100) - getEstimatedAltitude()) / ((mixerConfig()->alti_cutoff*100) - (mixerConfig()->alti_start_lim*100)); | ||
| limitingRatio = constrainf(limitingRatio, 0.0f, 1.0f); | ||
| throttle = constrainf(limitingRatio, 0.0f, throttle); | ||
| altiLimStatus = 1; | ||
| }else { | ||
| altiLimStatus = 0; | ||
| } | ||
| }else{ | ||
| altiLimStatus = 2; | ||
| } | ||
| }else{ | ||
| altiLimStatus = 0; | ||
| } | ||
| #endif | ||
|
|
||
| motorMixRange = motorMixMax - motorMixMin; | ||
| if (motorMixRange > 1.0f && (hardwareMotorType != MOTOR_BRUSHED)) { | ||
| for (int i = 0; i < motorCount; i++) { | ||
|
|
@@ -903,3 +940,13 @@ void mixerSetThrottleAngleCorrection(int correctionValue) { | |
| float mixerGetLoggingThrottle(void) { | ||
| return loggingThrottle; | ||
| } | ||
|
|
||
| uint8_t getThrottleLimitationStatus(void) | ||
| { | ||
| return altiLimStatus; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please name either the function or the variable according to it's sibiling. |
||
| } | ||
|
|
||
| bool isAltiLimit(void) | ||
| { | ||
| return mixerConfig()->altiLimiter; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -533,7 +533,11 @@ bool gpsNewFrame(uint8_t c) { | |
| return false; | ||
| } | ||
|
|
||
|
|
||
| // Check for healthy communications | ||
| bool gpsIsHealthy() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to declare functions for a single occurance. this can be done inline. |
||
| { | ||
| return (gpsData.state == GPS_RECEIVING_DATA); | ||
| } | ||
| /* This is a light implementation of a GPS frame decoding | ||
| This should work with most of modern GPS devices configured to output 5 frames. | ||
| It assumes there are some NMEA GGA frames to decode on the serial bus | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,9 +72,9 @@ | |
|
|
||
| #include "flight/position.h" | ||
| #include "flight/imu.h" | ||
| #ifdef USE_ESC_SENSOR | ||
| //#ifdef USE_ESC_SENSOR | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? please add comments if this is intendend. |
||
| #include "flight/mixer.h" | ||
| #endif | ||
| //#endif | ||
| #include "flight/pid.h" | ||
|
|
||
| #include "io/asyncfatfs/asyncfatfs.h" | ||
|
|
@@ -799,8 +799,23 @@ static bool osdDrawSingleElement(uint8_t item) { | |
| case OSD_WARNINGS: { | ||
| #define OSD_WARNINGS_MAX_SIZE 11 | ||
| #define OSD_FORMAT_MESSAGE_BUFFER_SIZE (OSD_WARNINGS_MAX_SIZE + 1) | ||
| STATIC_ASSERT(OSD_FORMAT_MESSAGE_BUFFER_SIZE <= sizeof(buff), osd_warnings_size_exceeds_buffer_size); | ||
| const batteryState_e batteryState = getBatteryState(); | ||
|
|
||
| STATIC_ASSERT(OSD_FORMAT_MESSAGE_BUFFER_SIZE <= sizeof(buff), osd_warnings_size_exceeds_buffer_size); | ||
|
|
||
| const batteryState_e batteryState = getBatteryState(); | ||
|
|
||
| // Show warning if no altitude limitation applicable | ||
| if (getThrottleLimitationStatus() == 2) { | ||
| tfp_sprintf(buff,"NO ALTI LIM"); | ||
| SET_BLINK(OSD_WARNINGS); | ||
| } else if(getThrottleLimitationStatus() == 1) { | ||
| tfp_sprintf(buff, "ALTI LIM"); | ||
| SET_BLINK(OSD_WARNINGS); | ||
|
|
||
| } else { | ||
| CLR_BLINK(OSD_WARNINGS); | ||
| } | ||
|
|
||
| #ifdef USE_DSHOT | ||
| if (isTryingToArm() && !ARMING_FLAG(ARMED)) { | ||
| int armingDelayTime = (getLastDshotBeaconCommandTimeUs() + DSHOT_BEACON_GUARD_DELAY_US - micros()) / 1e5; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind flash space.