2012-07-14 23:26:17 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
|
|
|
|
/// @file limits.cpp
|
|
|
|
/// @brief Imposes limits on location (geofence), altitude and other parameters.
|
2012-10-11 22:35:35 -03:00
|
|
|
/// Each limit breach will trigger an action or set of actions to recover.
|
|
|
|
/// Adapted from geofence.
|
2012-07-14 23:26:17 -03:00
|
|
|
/// @author Andrew Tridgell
|
|
|
|
/// Andreas Antonopoulos
|
|
|
|
|
2015-08-11 03:28:44 -03:00
|
|
|
#include "AP_Limit_GPSLock.h"
|
2012-07-14 23:26:17 -03:00
|
|
|
|
|
|
|
const AP_Param::GroupInfo AP_Limit_GPSLock::var_info[] PROGMEM = {
|
2012-08-17 03:20:05 -03:00
|
|
|
// @Param: GPSLCK_ON
|
|
|
|
// @DisplayName: Enable gpslock
|
2012-12-08 00:19:36 -04:00
|
|
|
// @Description: Setting this to Enabled(1) will enable the gpslock. Setting this to Disabled(0) will disable the gpslock
|
2012-08-17 03:20:05 -03:00
|
|
|
// @Values: 0:Disabled,1:Enabled
|
|
|
|
// @User: Standard
|
2012-10-11 22:35:35 -03:00
|
|
|
AP_GROUPINFO("GPSLCK_ON", 0, AP_Limit_GPSLock, _enabled, 0),
|
2012-08-17 03:20:05 -03:00
|
|
|
|
|
|
|
// @Param: GPSLCK_REQ
|
|
|
|
// @DisplayName: Require gpslock
|
2012-12-08 00:19:36 -04:00
|
|
|
// @Description: Setting this to Enabled(1) will make being inside the gpslock a required check before arming the vehicle.
|
2012-08-17 03:20:05 -03:00
|
|
|
// @Values: 0:Disabled,1:Enabled
|
|
|
|
// @User: Standard
|
2012-10-11 22:35:35 -03:00
|
|
|
AP_GROUPINFO("GPSLCK_REQ", 1, AP_Limit_GPSLock, _required, 0),
|
2012-07-14 23:26:17 -03:00
|
|
|
AP_GROUPEND
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
AP_Limit_GPSLock::AP_Limit_GPSLock(GPS *&gps) :
|
2012-08-17 03:20:05 -03:00
|
|
|
AP_Limit_Module(AP_LIMITS_GPSLOCK), // enabled and required
|
|
|
|
_gps(gps)
|
2012-07-14 23:26:17 -03:00
|
|
|
{
|
2012-12-12 17:49:46 -04:00
|
|
|
AP_Param::setup_object_defaults(this, var_info);
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool AP_Limit_GPSLock::triggered() {
|
2012-08-17 03:20:05 -03:00
|
|
|
_triggered = false; // reset trigger before checking
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2012-08-17 03:20:05 -03:00
|
|
|
if (!_gps || !_gps->fix) {
|
|
|
|
_triggered = true;
|
|
|
|
}
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2012-08-17 03:20:05 -03:00
|
|
|
return _triggered;
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|