35 #include "physical_constants.h"
37 #include "geofencesettings.h"
38 #include "positionactual.h"
39 #include "modulesettings.h"
45 #define SAMPLE_PERIOD_MS 250
53 void *ctx,
void *obj,
int len);
55 void *ctx,
void *obj,
int len);
68 #ifdef MODULE_Geofence_BUILTIN
69 module_enabled =
true;
71 uint8_t module_state[MODULESETTINGS_ADMINSTATE_NUMELEM];
72 ModuleSettingsAdminStateGet(module_state);
73 if (module_state[MODULESETTINGS_ADMINSTATE_GEOFENCE] == MODULESETTINGS_ADMINSTATE_ENABLED) {
74 module_enabled =
true;
76 module_enabled =
false;
80 if (GeoFenceSettingsInitialize() == -1) {
81 module_enabled =
false;
89 module_enabled =
false;
111 .
obj = PositionActualHandle(),
127 void *ctx,
void *obj,
int len)
129 (void) ev; (void) ctx; (void) obj; (void) len;
130 if (PositionActualHandle()) {
131 PositionActualData positionActual;
132 PositionActualGet(&positionActual);
134 const float distance2 = powf(positionActual.North, 2) + powf(positionActual.East, 2);
138 AlarmsSet(SYSTEMALARMS_ALARM_GEOFENCE, SYSTEMALARMS_ALARM_ERROR);
140 AlarmsSet(SYSTEMALARMS_ALARM_GEOFENCE, SYSTEMALARMS_ALARM_WARNING);
151 void *ctx,
void *obj,
int len)
153 (void) ev; (void) ctx; (void) obj; (void) len;
int32_t GeofenceInitialize(void)
void * PIOS_malloc(size_t size)
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity)
int32_t GeofenceStart(void)
MODULE_INITCALL(GeofenceInitialize, GeofenceStart)
int32_t EventPeriodicCallbackCreate(UAVObjEvent *ev, UAVObjEventCallback cb, uint16_t periodMs)
Event dispatcher, distributes object events as callbacks. Alternative to using tasks and queues...
static void checkPosition(const UAVObjEvent *ev, void *ctx, void *obj, int len)
static void settingsUpdated(const UAVObjEvent *ev, void *ctx, void *obj, int len)
Includes PiOS and core architecture components.
int32_t AlarmsClear(SystemAlarmsAlarmElem alarm)
static GeoFenceSettingsData * geofenceSettings