30 #include "generated/flight_plan.h"
31 #include "generated/airframe.h"
71 if (tmp == mission.
insert_idx) {
return false; }
149 if (j == 0) { index_list[j++] = 0; }
151 float remaining_time = -1.;
167 if (DL_MISSION_GOTO_WP_ac_id(buf) != AC_ID) {
return false; }
171 me.
element.mission_wp.wp.wp_f.x = DL_MISSION_GOTO_WP_wp_east(buf);
172 me.
element.mission_wp.wp.wp_f.y = DL_MISSION_GOTO_WP_wp_north(buf);
173 me.
element.mission_wp.wp.wp_f.z = DL_MISSION_GOTO_WP_wp_alt(buf);
174 me.
duration = DL_MISSION_GOTO_WP_duration(buf);
175 me.
index = DL_MISSION_GOTO_WP_index(buf);
184 if (DL_MISSION_GOTO_WP_LLA_ac_id(buf) != AC_ID) {
return false; }
187 lla.
lat = DL_MISSION_GOTO_WP_LLA_wp_lat(buf);
188 lla.
lon = DL_MISSION_GOTO_WP_LLA_wp_lon(buf);
189 lla.
alt = DL_MISSION_GOTO_WP_LLA_wp_alt(buf);
195 me.
duration = DL_MISSION_GOTO_WP_LLA_duration(buf);
196 me.
index = DL_MISSION_GOTO_WP_LLA_index(buf);
205 if (DL_MISSION_CIRCLE_ac_id(buf) != AC_ID) {
return false; }
209 me.
element.mission_circle.center.center_f.x = DL_MISSION_CIRCLE_center_east(buf);
210 me.
element.mission_circle.center.center_f.y = DL_MISSION_CIRCLE_center_north(buf);
211 me.
element.mission_circle.center.center_f.z = DL_MISSION_CIRCLE_center_alt(buf);
212 me.
element.mission_circle.radius = DL_MISSION_CIRCLE_radius(buf);
213 me.
duration = DL_MISSION_CIRCLE_duration(buf);
214 me.
index = DL_MISSION_CIRCLE_index(buf);
223 if (DL_MISSION_CIRCLE_LLA_ac_id(buf) != AC_ID) {
return false; }
226 lla.
lat = DL_MISSION_CIRCLE_LLA_center_lat(buf);
227 lla.
lon = DL_MISSION_CIRCLE_LLA_center_lon(buf);
228 lla.
alt = DL_MISSION_CIRCLE_LLA_center_alt(buf);
234 me.
element.mission_circle.radius = DL_MISSION_CIRCLE_LLA_radius(buf);
235 me.
duration = DL_MISSION_CIRCLE_LLA_duration(buf);
236 me.
index = DL_MISSION_CIRCLE_LLA_index(buf);
245 if (DL_MISSION_SEGMENT_ac_id(buf) != AC_ID) {
return false; }
249 me.
element.mission_segment.from.from_f.x = DL_MISSION_SEGMENT_segment_east_1(buf);
250 me.
element.mission_segment.from.from_f.y = DL_MISSION_SEGMENT_segment_north_1(buf);
251 me.
element.mission_segment.from.from_f.z = DL_MISSION_SEGMENT_segment_alt(buf);
252 me.
element.mission_segment.to.to_f.x = DL_MISSION_SEGMENT_segment_east_2(buf);
253 me.
element.mission_segment.to.to_f.y = DL_MISSION_SEGMENT_segment_north_2(buf);
254 me.
element.mission_segment.to.to_f.z = DL_MISSION_SEGMENT_segment_alt(buf);
255 me.
duration = DL_MISSION_SEGMENT_duration(buf);
256 me.
index = DL_MISSION_SEGMENT_index(buf);
265 if (DL_MISSION_SEGMENT_LLA_ac_id(buf) != AC_ID) {
return false; }
268 from_lla.
lat = DL_MISSION_SEGMENT_LLA_segment_lat_1(buf);
269 from_lla.
lon = DL_MISSION_SEGMENT_LLA_segment_lon_1(buf);
270 from_lla.
alt = DL_MISSION_SEGMENT_LLA_segment_alt(buf);
271 to_lla.
lat = DL_MISSION_SEGMENT_LLA_segment_lat_2(buf);
272 to_lla.
lon = DL_MISSION_SEGMENT_LLA_segment_lon_2(buf);
273 to_lla.
alt = DL_MISSION_SEGMENT_LLA_segment_alt(buf);
280 me.
duration = DL_MISSION_SEGMENT_LLA_duration(buf);
281 me.
index = DL_MISSION_SEGMENT_LLA_index(buf);
290 if (DL_MISSION_PATH_ac_id(buf) != AC_ID) {
return false; }
294 me.
element.mission_path.path.path_f[0].x = DL_MISSION_PATH_point_east_1(buf);
295 me.
element.mission_path.path.path_f[0].y = DL_MISSION_PATH_point_north_1(buf);
296 me.
element.mission_path.path.path_f[0].z = DL_MISSION_PATH_path_alt(buf);
297 me.
element.mission_path.path.path_f[1].x = DL_MISSION_PATH_point_east_2(buf);
298 me.
element.mission_path.path.path_f[1].y = DL_MISSION_PATH_point_north_2(buf);
299 me.
element.mission_path.path.path_f[1].z = DL_MISSION_PATH_path_alt(buf);
300 me.
element.mission_path.path.path_f[2].x = DL_MISSION_PATH_point_east_3(buf);
301 me.
element.mission_path.path.path_f[2].y = DL_MISSION_PATH_point_north_3(buf);
302 me.
element.mission_path.path.path_f[2].z = DL_MISSION_PATH_path_alt(buf);
303 me.
element.mission_path.path.path_f[3].x = DL_MISSION_PATH_point_east_4(buf);
304 me.
element.mission_path.path.path_f[3].y = DL_MISSION_PATH_point_north_4(buf);
305 me.
element.mission_path.path.path_f[3].z = DL_MISSION_PATH_path_alt(buf);
306 me.
element.mission_path.path.path_f[4].x = DL_MISSION_PATH_point_east_5(buf);
307 me.
element.mission_path.path.path_f[4].y = DL_MISSION_PATH_point_north_5(buf);
308 me.
element.mission_path.path.path_f[4].z = DL_MISSION_PATH_path_alt(buf);
309 me.
element.mission_path.nb = DL_MISSION_PATH_nb(buf);
311 me.
element.mission_path.path_idx = 0;
312 me.
duration = DL_MISSION_PATH_duration(buf);
313 me.
index = DL_MISSION_PATH_index(buf);
322 if (DL_MISSION_PATH_LLA_ac_id(buf) != AC_ID) {
return false; }
325 lla[0].
lat = DL_MISSION_PATH_LLA_point_lat_1(buf);
326 lla[0].
lon = DL_MISSION_PATH_LLA_point_lon_1(buf);
327 lla[0].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
328 lla[1].
lat = DL_MISSION_PATH_LLA_point_lat_2(buf);
329 lla[1].
lon = DL_MISSION_PATH_LLA_point_lon_2(buf);
330 lla[1].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
331 lla[2].
lat = DL_MISSION_PATH_LLA_point_lat_3(buf);
332 lla[2].
lon = DL_MISSION_PATH_LLA_point_lon_3(buf);
333 lla[2].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
334 lla[3].
lat = DL_MISSION_PATH_LLA_point_lat_4(buf);
335 lla[3].
lon = DL_MISSION_PATH_LLA_point_lon_4(buf);
336 lla[3].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
337 lla[4].
lat = DL_MISSION_PATH_LLA_point_lat_5(buf);
338 lla[4].
lon = DL_MISSION_PATH_LLA_point_lon_5(buf);
339 lla[4].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
344 me.
element.mission_path.nb = DL_MISSION_PATH_LLA_nb(buf);
346 for (i = 0; i < me.
element.mission_path.nb; i++) {
350 me.
element.mission_path.path_idx = 0;
351 me.
duration = DL_MISSION_PATH_LLA_duration(buf);
352 me.
index = DL_MISSION_PATH_LLA_index(buf);
361 if (DL_MISSION_CUSTOM_ac_id(buf) != AC_ID) {
return false; }
366 if (me.
element.mission_custom.reg == NULL) {
369 me.
element.mission_custom.nb = DL_MISSION_CUSTOM_params_length(buf);
370 for (
int i = 0; i < me.
element.mission_custom.nb; i++) {
371 me.
element.mission_custom.params[i] = DL_MISSION_CUSTOM_params(buf)[i];
373 me.
duration = DL_MISSION_CUSTOM_duration(buf);
374 me.
index = DL_MISSION_CUSTOM_index(buf);
383 if (DL_GOTO_MISSION_ac_id(buf) != AC_ID) {
return false; }
385 uint8_t mission_id = DL_GOTO_MISSION_mission_id(buf);
388 }
else {
return false; }
395 if (DL_NEXT_MISSION_ac_id(buf) != AC_ID) {
return false; }
406 if (DL_END_MISSION_ac_id(buf) != AC_ID) {
return false; }
replace the next element and remove all the others
char type[MISSION_TYPE_SIZE]
mission element identifier (5 char max + 1 \0)
int mission_parse_SEGMENT_LLA(uint8_t *buf)
bool(* mission_custom_cb)(uint8_t nb, float *params, bool init)
custom mission element callback
struct _mission_element * mission_get(void)
Get current mission element.
struct _mission_registered registered[MISSION_REGISTER_NB]
Handling of messages coming from ground and other A/Cs.
int mission_parse_CIRCLE_LLA(uint8_t *buf)
void mission_init(void)
Init mission structure.
bool mission_insert(enum MissionInsertMode insert, struct _mission_element *element)
Insert a mission element according to the insertion mode.
bool mission_element_convert(struct _mission_element *el)
Convert mission element's points format if needed.
bool mission_register(mission_custom_cb cb, char *type)
Register a new navigation or action callback function.
int mission_parse_PATH_LLA(uint8_t *buf)
void mission_status_report(void)
Report mission status.
int mission_parse_END_MISSION(uint8_t *buf)
int mission_parse_PATH(uint8_t *buf)
remove all elements and add the new one
float duration
time to spend in the element (<= 0 to disable)
add before the current element
vector in Latitude, Longitude and Altitude
#define MISSION_REGISTER_NB
Max number of registered nav/action callbacks can be redefined.
int mission_parse_GOTO_WP_LLA(uint8_t *buf)
int32_t alt
in millimeters above WGS84 reference ellipsoid
int mission_parse_NEXT_MISSION(uint8_t *buf)
float element_time
time in second spend in the current element
#define MISSION_ELEMENT_NB
Max number of elements in the tasks' list can be redefined.
int mission_parse_CIRCLE(uint8_t *buf)
mission_custom_cb cb
navigation/action function callback
int32_t lon
in degrees*1e7
int mission_parse_SEGMENT(uint8_t *buf)
int mission_parse_GOTO_MISSION(uint8_t *buf)
uint8_t insert_idx
inserstion index
#define MISSION_TYPE_SIZE
uint8_t index
index of mission element
uint8_t current_idx
current mission element index
int mission_parse_GOTO_WP(uint8_t *buf)
Parsing functions called when a mission message is received.
Common code for AP and FBW telemetry.
struct _mission_element elements[MISSION_ELEMENT_NB]
bool mission_point_of_lla(struct EnuCoor_f *point, struct LlaCoor_i *lla)
Get the ENU component of LLA mission point This function is firmware specific.
int32_t lat
in degrees*1e7
int mission_parse_CUSTOM(uint8_t *buf)
static struct _mission_registered * mission_get_registered(char *type)
union _mission_element::@299 element