2012-07-14 23:26:17 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
/// @brief Imposes limits on location (geofence), altitude and other parameters
|
|
|
|
/// Each 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
|
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
#ifndef __AP_LIMIT_MODULE_H__
|
|
|
|
#define __AP_LIMIT_MODULE_H__
|
2012-07-14 23:26:17 -03:00
|
|
|
|
|
|
|
#include <AP_Common.h>
|
2012-08-20 20:22:44 -03:00
|
|
|
#include <AP_Param.h>
|
2012-07-14 23:26:17 -03:00
|
|
|
|
|
|
|
// The module IDs are defined as powers of 2, to make a bit-field
|
|
|
|
enum moduleid {
|
2012-10-11 22:35:35 -03:00
|
|
|
// not a module - used to set the "zero" value
|
|
|
|
AP_LIMITS_NULLMODULE = 0,
|
|
|
|
// a GPS-lock-required limit
|
|
|
|
AP_LIMITS_GPSLOCK = (1 << 0),
|
|
|
|
// fence within a set of coordinates
|
|
|
|
AP_LIMITS_GEOFENCE = (1 << 1),
|
|
|
|
// altitude limits
|
|
|
|
AP_LIMITS_ALTITUDE = (1 << 2)
|
2012-07-14 23:26:17 -03:00
|
|
|
};
|
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
extern const prog_char_t *get_module_name(enum moduleid i);
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
// an integer type big enough to fit a bit field for all modules.
|
|
|
|
// We have 3 modules, so 8-bit int is enough.
|
2012-07-14 23:26:17 -03:00
|
|
|
typedef uint8_t LimitModuleBits;
|
|
|
|
|
|
|
|
class AP_Limit_Module {
|
|
|
|
|
|
|
|
public:
|
2012-10-11 22:35:35 -03:00
|
|
|
// initialize a new module
|
|
|
|
AP_Limit_Module(enum moduleid id);
|
|
|
|
// initialize self
|
|
|
|
bool init();
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2012-08-17 03:20:06 -03:00
|
|
|
virtual moduleid get_module_id();
|
|
|
|
virtual bool enabled();
|
|
|
|
virtual bool required();
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
// return next module in linked list
|
|
|
|
virtual AP_Limit_Module * next();
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
// link the next module in the linked list
|
|
|
|
virtual void link(AP_Limit_Module *m);
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
// trigger check function
|
|
|
|
virtual bool triggered();
|
|
|
|
|
|
|
|
// recovery action
|
|
|
|
virtual void action();
|
2012-07-14 23:26:17 -03:00
|
|
|
|
|
|
|
protected:
|
2012-10-11 22:35:35 -03:00
|
|
|
// often exposed as a MAVLink parameter
|
|
|
|
AP_Int8 _enabled;
|
|
|
|
|
2012-08-17 03:20:06 -03:00
|
|
|
AP_Int8 _required;
|
|
|
|
AP_Int8 _triggered;
|
2012-07-14 23:26:17 -03:00
|
|
|
|
|
|
|
private:
|
2012-08-17 03:20:06 -03:00
|
|
|
enum moduleid _id;
|
|
|
|
AP_Limit_Module * _next;
|
2012-07-14 23:26:17 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
#endif // __AP_LIMIT_MODULE_H__
|