30 #include "generated/flight_plan.h"
31 #include "generated/airframe.h"
34 #if PERIODIC_TELEMETRY
39 #ifndef MISSION_CHECK_UNIQUE_ID
40 #define MISSION_CHECK_UNIQUE_ID TRUE
54 if (j == 0) { index_list[j++] = 0; }
56 float remaining_time = -1.;
62 pprz_msg_send_MISSION_STATUS(trans, device, AC_ID, &remaining_time, j, index_list);
76 #if PERIODIC_TELEMETRY
87 #if MISSION_CHECK_UNIQUE_ID
200 if (DL_MISSION_GOTO_WP_ac_id(buf) != AC_ID) {
return false; }
204 me.
element.mission_wp.wp.x = DL_MISSION_GOTO_WP_wp_east(buf);
205 me.
element.mission_wp.wp.y = DL_MISSION_GOTO_WP_wp_north(buf);
206 me.
element.mission_wp.wp.z = DL_MISSION_GOTO_WP_wp_alt(buf);
207 me.
duration = DL_MISSION_GOTO_WP_duration(buf);
208 me.
index = DL_MISSION_GOTO_WP_index(buf);
217 if (DL_MISSION_GOTO_WP_LLA_ac_id(buf) != AC_ID) {
return false; }
220 lla.
lat = DL_MISSION_GOTO_WP_LLA_wp_lat(buf);
221 lla.
lon = DL_MISSION_GOTO_WP_LLA_wp_lon(buf);
222 lla.
alt = DL_MISSION_GOTO_WP_LLA_wp_alt(buf);
228 me.
duration = DL_MISSION_GOTO_WP_LLA_duration(buf);
229 me.
index = DL_MISSION_GOTO_WP_LLA_index(buf);
238 if (DL_MISSION_CIRCLE_ac_id(buf) != AC_ID) {
return false; }
242 me.
element.mission_circle.center.x = DL_MISSION_CIRCLE_center_east(buf);
243 me.
element.mission_circle.center.y = DL_MISSION_CIRCLE_center_north(buf);
244 me.
element.mission_circle.center.z = DL_MISSION_CIRCLE_center_alt(buf);
245 me.
element.mission_circle.radius = DL_MISSION_CIRCLE_radius(buf);
246 me.
duration = DL_MISSION_CIRCLE_duration(buf);
247 me.
index = DL_MISSION_CIRCLE_index(buf);
256 if (DL_MISSION_CIRCLE_LLA_ac_id(buf) != AC_ID) {
return false; }
259 lla.
lat = DL_MISSION_CIRCLE_LLA_center_lat(buf);
260 lla.
lon = DL_MISSION_CIRCLE_LLA_center_lon(buf);
261 lla.
alt = DL_MISSION_CIRCLE_LLA_center_alt(buf);
267 me.
element.mission_circle.radius = DL_MISSION_CIRCLE_LLA_radius(buf);
268 me.
duration = DL_MISSION_CIRCLE_LLA_duration(buf);
269 me.
index = DL_MISSION_CIRCLE_LLA_index(buf);
278 if (DL_MISSION_SEGMENT_ac_id(buf) != AC_ID) {
return false; }
282 me.
element.mission_segment.from.x = DL_MISSION_SEGMENT_segment_east_1(buf);
283 me.
element.mission_segment.from.y = DL_MISSION_SEGMENT_segment_north_1(buf);
284 me.
element.mission_segment.from.z = DL_MISSION_SEGMENT_segment_alt(buf);
285 me.
element.mission_segment.to.x = DL_MISSION_SEGMENT_segment_east_2(buf);
286 me.
element.mission_segment.to.y = DL_MISSION_SEGMENT_segment_north_2(buf);
287 me.
element.mission_segment.to.z = DL_MISSION_SEGMENT_segment_alt(buf);
288 me.
duration = DL_MISSION_SEGMENT_duration(buf);
289 me.
index = DL_MISSION_SEGMENT_index(buf);
298 if (DL_MISSION_SEGMENT_LLA_ac_id(buf) != AC_ID) {
return false; }
301 from_lla.
lat = DL_MISSION_SEGMENT_LLA_segment_lat_1(buf);
302 from_lla.
lon = DL_MISSION_SEGMENT_LLA_segment_lon_1(buf);
303 from_lla.
alt = DL_MISSION_SEGMENT_LLA_segment_alt(buf);
304 to_lla.
lat = DL_MISSION_SEGMENT_LLA_segment_lat_2(buf);
305 to_lla.
lon = DL_MISSION_SEGMENT_LLA_segment_lon_2(buf);
306 to_lla.
alt = DL_MISSION_SEGMENT_LLA_segment_alt(buf);
313 me.
duration = DL_MISSION_SEGMENT_LLA_duration(buf);
314 me.
index = DL_MISSION_SEGMENT_LLA_index(buf);
323 if (DL_MISSION_PATH_ac_id(buf) != AC_ID) {
return false; }
327 me.
element.mission_path.path[0].x = DL_MISSION_PATH_point_east_1(buf);
328 me.
element.mission_path.path[0].y = DL_MISSION_PATH_point_north_1(buf);
329 me.
element.mission_path.path[0].z = DL_MISSION_PATH_path_alt(buf);
330 me.
element.mission_path.path[1].x = DL_MISSION_PATH_point_east_2(buf);
331 me.
element.mission_path.path[1].y = DL_MISSION_PATH_point_north_2(buf);
332 me.
element.mission_path.path[1].z = DL_MISSION_PATH_path_alt(buf);
333 me.
element.mission_path.path[2].x = DL_MISSION_PATH_point_east_3(buf);
334 me.
element.mission_path.path[2].y = DL_MISSION_PATH_point_north_3(buf);
335 me.
element.mission_path.path[2].z = DL_MISSION_PATH_path_alt(buf);
336 me.
element.mission_path.path[3].x = DL_MISSION_PATH_point_east_4(buf);
337 me.
element.mission_path.path[3].y = DL_MISSION_PATH_point_north_4(buf);
338 me.
element.mission_path.path[3].z = DL_MISSION_PATH_path_alt(buf);
339 me.
element.mission_path.path[4].x = DL_MISSION_PATH_point_east_5(buf);
340 me.
element.mission_path.path[4].y = DL_MISSION_PATH_point_north_5(buf);
341 me.
element.mission_path.path[4].z = DL_MISSION_PATH_path_alt(buf);
342 me.
element.mission_path.nb = DL_MISSION_PATH_nb(buf);
344 me.
element.mission_path.path_idx = 0;
345 me.
duration = DL_MISSION_PATH_duration(buf);
346 me.
index = DL_MISSION_PATH_index(buf);
355 if (DL_MISSION_PATH_LLA_ac_id(buf) != AC_ID) {
return false; }
358 lla[0].
lat = DL_MISSION_PATH_LLA_point_lat_1(buf);
359 lla[0].
lon = DL_MISSION_PATH_LLA_point_lon_1(buf);
360 lla[0].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
361 lla[1].
lat = DL_MISSION_PATH_LLA_point_lat_2(buf);
362 lla[1].
lon = DL_MISSION_PATH_LLA_point_lon_2(buf);
363 lla[1].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
364 lla[2].
lat = DL_MISSION_PATH_LLA_point_lat_3(buf);
365 lla[2].
lon = DL_MISSION_PATH_LLA_point_lon_3(buf);
366 lla[2].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
367 lla[3].
lat = DL_MISSION_PATH_LLA_point_lat_4(buf);
368 lla[3].
lon = DL_MISSION_PATH_LLA_point_lon_4(buf);
369 lla[3].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
370 lla[4].
lat = DL_MISSION_PATH_LLA_point_lat_5(buf);
371 lla[4].
lon = DL_MISSION_PATH_LLA_point_lon_5(buf);
372 lla[4].
alt = DL_MISSION_PATH_LLA_path_alt(buf);
377 me.
element.mission_path.nb = DL_MISSION_PATH_LLA_nb(buf);
379 for (i = 0; i < me.
element.mission_path.nb; i++) {
383 me.
element.mission_path.path_idx = 0;
384 me.
duration = DL_MISSION_PATH_LLA_duration(buf);
385 me.
index = DL_MISSION_PATH_LLA_index(buf);
394 if (DL_MISSION_CUSTOM_ac_id(buf) != AC_ID) {
return false; }
399 if (me.
element.mission_custom.reg == NULL) {
402 me.
element.mission_custom.nb = DL_MISSION_CUSTOM_params_length(buf);
403 for (
int i = 0; i < me.
element.mission_custom.nb; i++) {
404 me.
element.mission_custom.params[i] = DL_MISSION_CUSTOM_params(buf)[i];
406 me.
duration = DL_MISSION_CUSTOM_duration(buf);
407 me.
index = DL_MISSION_CUSTOM_index(buf);
416 if (DL_MISSION_UPDATE_ac_id(buf) != AC_ID) {
return false; }
423 float duration = DL_MISSION_UPDATE_duration(buf);
428 uint8_t nb = DL_MISSION_UPDATE_params_length(buf);
430 memcpy(params, DL_MISSION_UPDATE_params(buf), nb*
sizeof(
float));
448 if (DL_GOTO_MISSION_ac_id(buf) != AC_ID) {
return false; }
450 uint8_t mission_id = DL_GOTO_MISSION_mission_id(buf);
456 }
else {
return false; }
463 if (DL_NEXT_MISSION_ac_id(buf) != AC_ID) {
return false; }
476 if (DL_END_MISSION_ac_id(buf) != AC_ID) {
return false; }
Handling of messages coming from ground and other A/Cs.
Common code for AP and FBW telemetry.
int32_t lat
in degrees*1e7
int32_t alt
in millimeters above WGS84 reference ellipsoid
int32_t lon
in degrees*1e7
vector in Latitude, Longitude and Altitude
int mission_parse_END_MISSION(uint8_t *buf)
int mission_parse_GOTO_WP_LLA(uint8_t *buf)
int mission_parse_CUSTOM(uint8_t *buf)
static struct _mission_registered * mission_get_registered(char *type)
void mission_init(void)
Init mission structure.
int mission_parse_NEXT_MISSION(uint8_t *buf)
int mission_parse_PATH_LLA(uint8_t *buf)
bool mission_insert(enum MissionInsertMode insert, struct _mission_element *element)
Insert a mission element according to the insertion mode.
void mission_status_report(void)
Report mission status.
int mission_parse_SEGMENT_LLA(uint8_t *buf)
int mission_parse_GOTO_WP(uint8_t *buf)
Parsing functions called when a mission message is received.
int mission_parse_CIRCLE(uint8_t *buf)
int mission_parse_UPDATE(uint8_t *buf)
struct _mission_element * mission_get_from_index(uint8_t index)
Get mission element by index.
int mission_parse_SEGMENT(uint8_t *buf)
static void send_mission_status(struct transport_tx *trans, struct link_device *device)
int mission_parse_GOTO_MISSION(uint8_t *buf)
bool mission_register(mission_custom_cb cb, char *type)
Register a new navigation or action callback function.
struct _mission_element * mission_get(void)
Get current mission element.
int mission_parse_PATH(uint8_t *buf)
int mission_parse_CIRCLE_LLA(uint8_t *buf)
#define MISSION_TYPE_SIZE
union _mission_element::@299 element
bool(* mission_custom_cb)(uint8_t nb, float *params, enum MissionRunFlag flag)
custom mission element callback
char type[MISSION_TYPE_SIZE]
mission element identifier (5 char max + 1 \0)
mission_custom_cb cb
navigation/action function callback
struct _mission_registered registered[MISSION_REGISTER_NB]
@ MissionUpdate
param update
struct _mission_element elements[MISSION_ELEMENT_NB]
float element_time
time in second spend in the current element
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.
uint8_t index
index of mission element
#define MISSION_REGISTER_NB
Max number of registered nav/action callbacks can be redefined.
#define MISSION_ELEMENT_NB
Max number of elements in the tasks' list can be redefined.
uint8_t insert_idx
inserstion index
@ ReplaceCurrent
replace current element
@ Append
add at the last position
@ ReplaceNexts
replace the next element and remove all the others
@ ReplaceAll
remove all elements and add the new one
@ Prepend
add before the current element
float duration
time to spend in the element (<= 0 to disable)
#define MISSION_CUSTOM_MAX
uint8_t current_idx
current mission element index
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.