2011-03-19 07:20:11 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2012-06-30 19:34:55 -03:00
|
|
|
static int32_t get_RTL_alt()
|
2011-02-17 05:36:33 -04:00
|
|
|
{
|
2012-11-29 08:08:19 -04:00
|
|
|
if(g.rtl_altitude <= 0) {
|
|
|
|
return min(current_loc.alt, RTL_ALT_MAX);
|
|
|
|
}else if (g.rtl_altitude < current_loc.alt) {
|
|
|
|
return min(current_loc.alt, RTL_ALT_MAX);
|
2012-08-16 21:50:03 -03:00
|
|
|
}else{
|
2012-11-29 08:08:19 -04:00
|
|
|
return g.rtl_altitude;
|
2012-08-16 21:50:03 -03:00
|
|
|
}
|
2011-02-17 03:25:31 -04:00
|
|
|
}
|
2010-12-19 12:40:33 -04:00
|
|
|
|
|
|
|
// run this at setup on the ground
|
|
|
|
// -------------------------------
|
2011-07-17 07:32:00 -03:00
|
|
|
static void init_home()
|
2010-12-19 12:40:33 -04:00
|
|
|
{
|
2012-11-10 01:55:51 -04:00
|
|
|
set_home_is_set(true);
|
2014-01-03 07:33:57 -04:00
|
|
|
ahrs.set_home(g_gps->latitude, g_gps->longitude, 0);
|
2012-08-16 21:50:03 -03:00
|
|
|
|
2014-01-03 07:41:23 -04:00
|
|
|
inertial_nav.setup_home_position();
|
2012-11-07 06:03:30 -04:00
|
|
|
|
2014-02-27 22:16:33 -04:00
|
|
|
// log new home position which mission library will pull from ahrs
|
|
|
|
if (g.log_bitmask & MASK_LOG_CMD) {
|
|
|
|
AP_Mission::Mission_Command temp_cmd;
|
2014-03-10 23:27:53 -03:00
|
|
|
if (mission.read_cmd_from_storage(0, temp_cmd)) {
|
2014-03-16 05:41:59 -03:00
|
|
|
Log_Write_Cmd(temp_cmd);
|
2014-03-10 23:27:53 -03:00
|
|
|
}
|
2014-02-27 22:16:33 -04:00
|
|
|
}
|
2012-08-16 21:50:03 -03:00
|
|
|
|
2012-12-17 03:54:03 -04:00
|
|
|
// update navigation scalers. used to offset the shrinking longitude as we go towards the poles
|
2013-08-04 21:18:53 -03:00
|
|
|
scaleLongDown = longitude_scale(home);
|
2013-01-27 10:35:12 -04:00
|
|
|
scaleLongUp = 1.0f/scaleLongDown;
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|