Recently I started to learning C Language and I wanna to analysis MultiWii 2.4 code.
by the way, I interested in LAND mode and it looks like operated in GPS.cpp and MultiWii.cpp
GPS.cpp
Code: Select all
switch(NAV_state) //Navigation state machine
{
case NAV_STATE_NONE: //Just for clarity, do nothing when nav_state is none
break;
case NAV_STATE_LAND_START:
GPS_calc_poshold(); //Land in position hold
land_settle_timer = millis();
debug[0] = 111;
NAV_state = NAV_STATE_LAND_SETTLE;
break;
case NAV_STATE_LAND_SETTLE:
GPS_calc_poshold();
if (millis()-land_settle_timer > 1000)
debug[0] = 222;
NAV_state = NAV_STATE_LAND_START_DESCENT;
break;
.
.
.
.
.
MultiWii.cpp
Code: Select all
#if GPS
if (f.LAND_IN_PROGRESS) { //If autoland is in progress then take over and decrease alt slowly
AltHoldCorr -= GPS_conf.land_speed; //100
if(abs(AltHoldCorr) > 512) {
AltHold += AltHoldCorr/512;
AltHoldCorr %= 512;
debug[3] = AltHold;
}
test1 = 0;
}
I think, when LAND mode ON, then [AltHold = Now altitude] and AltHold keep decrease.
also the throttle goin down to 0.
it that a right logic?
or tell me how to work LAND
I wonder so much!