To let the copter come back to home position when lost control single, I set receiver give out a AUX single to active RTH and Baro. PITCH, ROLL and YAW are centered and THROTTLE are keep hold.
The copter will go home at current altitude when out of control range.
But the problem is: if copter lost control when climbing, the copter will continue climbing until out of power.
My suggestion is add a define called “KEEP_ALTITUDE_RTH”, when this is truned on, do not change the Baro altitude when GPS_HOME is on. Code will be like this:
Code: Select all
if ((abs(rcCommand[THROTTLE]-initialThrottleHold)>ALT_HOLD_THROTTLE_NEUTRAL_ZONE)&& !f.GPS_HOME_MODE ) {
// Slowly increase/decrease AltHold proportional to stick movement ( +100 throttle gives ~ +50 cm in 1 second with cycle time about 3-4ms)
AltHoldCorr+= rcCommand[THROTTLE] - initialThrottleHold;
if(abs(AltHoldCorr) > 500) {
AltHold += AltHoldCorr/500;
AltHoldCorr %= 500;
}
To get the RTH more safe, we can have two define:
Code: Select all
RTH_ALTITUDE
HOME_HOLD_ALTITUDE
When RTH is active , the baro altitude can be slowly increase/decrease to RTH_ALTITUDE.
When HOME is reached, the baro altitude can be slowly increase/decrease to HOME_HOLD_ALTITUDE.
I have tried to upload some code on google code, but I always got some problems. So, If I have these idears, can someone write the code into google code?