39 #include "physical_constants.h"
47 #include "acceldesired.h"
48 #include "altitudeholdsettings.h"
49 #include "altitudeholdstate.h"
50 #include "modulesettings.h"
51 #include "pathdesired.h"
52 #include "flightstatus.h"
53 #include "pathstatus.h"
54 #include "stabilizationdesired.h"
55 #include "systemsettings.h"
56 #include "velocitydesired.h"
57 #include "vtolpathfollowersettings.h"
58 #include "vtolpathfollowerstatus.h"
65 #define MAX_QUEUE_SIZE 4
66 #define STACK_SIZE_BYTES 1548
67 #define TASK_PRIORITY PIOS_THREAD_PRIO_NORMAL
88 FlightStatusConnectQueue(queue);
104 #ifdef MODULE_VtolPathFollower_BUILTIN
107 uint8_t module_state[MODULESETTINGS_ADMINSTATE_NUMELEM];
108 ModuleSettingsAdminStateGet(module_state);
109 if (module_state[MODULESETTINGS_ADMINSTATE_VTOLPATHFOLLOWER] == MODULESETTINGS_ADMINSTATE_ENABLED) {
127 if (AltitudeHoldSettingsInitialize() == -1 || VtolPathFollowerSettingsInitialize() == -1) {
132 if (AccelDesiredInitialize() == -1 \
133 || AltitudeHoldStateInitialize() == -1 \
134 || PathDesiredInitialize() == -1 \
135 || PathStatusInitialize() == -1 \
136 || VelocityDesiredInitialize() == -1 \
137 || VtolPathFollowerStatusInitialize() == -1 ) {
157 SystemSettingsData systemSettings;
158 FlightStatusData flightStatus;
171 SystemSettingsGet(&systemSettings);
172 if ( (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_VTOL) &&
173 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_QUADP) &&
174 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_QUADX) &&
175 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_HEXA) &&
176 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_HEXAX) &&
177 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_HEXACOAX) &&
178 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_OCTO) &&
179 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_OCTOV) &&
180 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_OCTOCOAXP) &&
181 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_OCTOCOAXX) &&
182 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_TRI) &&
183 (systemSettings.AirframeType != SYSTEMSETTINGS_AIRFRAMETYPE_HELICP) )
187 AlarmsSet(SYSTEMALARMS_ALARM_PATHFOLLOWER,SYSTEMALARMS_ALARM_CRITICAL);
196 static uint8_t last_flight_mode;
197 FlightStatusGet(&flightStatus);
199 static bool fsm_running =
false;
201 if (flightStatus.FlightMode != last_flight_mode) {
204 last_flight_mode = flightStatus.FlightMode;
206 switch(flightStatus.FlightMode) {
207 case FLIGHTSTATUS_FLIGHTMODE_RETURNTOHOME:
211 case FLIGHTSTATUS_FLIGHTMODE_POSITIONHOLD:
215 case FLIGHTSTATUS_FLIGHTMODE_PATHPLANNER:
216 case FLIGHTSTATUS_FLIGHTMODE_TABLETCONTROL:
int32_t vtol_follower_fsm_update()
int32_t vtol_follower_fsm_activate_goal(enum vtol_goals new_goal)
struct pios_queue * PIOS_Queue_Create(size_t queue_length, size_t item_size)
int32_t VtolPathFollowerStart()
VtolPathFollowerSettingsData vtol_guidanceSettings
void vtol_follower_control_settings_updated()
void UAVObjCbSetFlag(const UAVObjEvent *objEv, void *ctx, void *obj, int len)
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity)
bool PIOS_Queue_Receive(struct pios_queue *queuep, void *itemp, uint32_t timeout_ms)
volatile bool settings_updated
struct pid vtol_pids[VTOL_PID_NUM]
MODULE_INITCALL(VtolPathFollowerInitialize, VtolPathFollowerStart)
static struct pios_queue * queue
static bool module_enabled
Path calculation library with common API.
bool PIOS_SENSORS_IsRegistered(enum pios_sensor_type type)
Checks if a sensor type is registered with the PIOS_SENSORS interface.
static void vtolPathFollowerTask(void *parameters)
struct pios_thread * PIOS_Thread_Create(void(*fp)(void *), const char *namep, size_t stack_bytes, void *argp, enum pios_thread_prio_e prio)
int32_t TaskMonitorAdd(TaskInfoRunningElem task, struct pios_thread *threadp)
Includes for the internal methods.
void pid_zero(struct pid *pid)
void PIOS_Thread_Sleep(uint32_t time_ms)
Header for Coordinate conversions library in coordinate_conversions.c.
Includes PiOS and core architecture components.
int32_t AlarmsClear(SystemAlarmsAlarmElem alarm)
int32_t VtolPathFollowerInitialize()
static struct pios_thread * pathfollowerTaskHandle