Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
mission_common.h File Reference

mission planner library More...

#include "std.h"
#include "math/pprz_geodetic_float.h"
#include "math/pprz_geodetic_int.h"
+ Include dependency graph for mission_common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _mission_wp
 
struct  _mission_circle
 
struct  _mission_segment
 
struct  _mission_path
 
struct  _mission_registered
 
struct  _mission_custom
 
struct  _mission_element
 
struct  _mission
 
union  _mission_wp.wp
 
union  _mission_circle.center
 
union  _mission_segment.from
 
union  _mission_segment.to
 
union  _mission_path.path
 
union  _mission_element.element
 

Macros

#define MISSION_PATH_NB   5
 
#define MISSION_CUSTOM_MAX   12
 
#define MISSION_TYPE_SIZE   6
 
#define MISSION_ELEMENT_NB   20
 Max number of elements in the tasks' list can be redefined. More...
 
#define MISSION_REGISTER_NB   6
 Max number of registered nav/action callbacks can be redefined. More...
 

Typedefs

typedef bool(* mission_custom_cb) (uint8_t nb, float *params, bool init)
 custom mission element callback More...
 

Enumerations

enum  MissionType {
  MissionWP = 1, MissionCircle = 2, MissionSegment = 3, MissionPath = 4,
  MissionCustom = 5
}
 
enum  MissionInsertMode {
  Append, Prepend, ReplaceCurrent, ReplaceAll,
  ReplaceNexts
}
 

Functions

void mission_init (void)
 Init mission structure. More...
 
bool mission_insert (enum MissionInsertMode insert, struct _mission_element *element)
 Insert a mission element according to the insertion mode. More...
 
bool mission_register (mission_custom_cb cb, char *type)
 Register a new navigation or action callback function. More...
 
bool mission_element_convert (struct _mission_element *el)
 Convert mission element's points format if needed. More...
 
struct _mission_elementmission_get (void)
 Get current mission element. More...
 
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. More...
 
int mission_run (void)
 Run mission. More...
 
void mission_status_report (void)
 Report mission status. More...
 
int mission_parse_GOTO_WP (uint8_t *buf)
 Parsing functions called when a mission message is received. More...
 
int mission_parse_GOTO_WP_LLA (uint8_t *buf)
 
int mission_parse_CIRCLE (uint8_t *buf)
 
int mission_parse_CIRCLE_LLA (uint8_t *buf)
 
int mission_parse_SEGMENT (uint8_t *buf)
 
int mission_parse_SEGMENT_LLA (uint8_t *buf)
 
int mission_parse_PATH (uint8_t *buf)
 
int mission_parse_PATH_LLA (uint8_t *buf)
 
int mission_parse_CUSTOM (uint8_t *buf)
 
int mission_parse_GOTO_MISSION (uint8_t *buf)
 
int mission_parse_NEXT_MISSION (uint8_t *buf)
 
int mission_parse_END_MISSION (uint8_t *buf)
 

Variables

struct _mission mission
 

Detailed Description

mission planner library

Provide the generic interface for the mission control Handle the parsing of datalink messages

Definition in file mission_common.h.


Data Structure Documentation

◆ _mission_wp

struct _mission_wp

Definition at line 53 of file mission_common.h.

Data Fields
union _mission_wp wp

◆ _mission_circle

struct _mission_circle

Definition at line 60 of file mission_common.h.

Data Fields
union _mission_circle center
float radius

◆ _mission_segment

struct _mission_segment

Definition at line 69 of file mission_common.h.

Data Fields
union _mission_segment from
union _mission_segment to

◆ _mission_path

struct _mission_path

Definition at line 82 of file mission_common.h.

Data Fields
uint8_t nb
union _mission_path path
uint8_t path_idx

◆ _mission_registered

struct _mission_registered

Definition at line 103 of file mission_common.h.

Data Fields
mission_custom_cb cb navigation/action function callback
char type[MISSION_TYPE_SIZE] mission element identifier (5 char max + 1 \0)

◆ _mission_custom

struct _mission_custom

Definition at line 108 of file mission_common.h.

+ Collaboration diagram for _mission_custom:
Data Fields
uint8_t nb number of parameters
float params[MISSION_CUSTOM_MAX] list of parameters
struct _mission_registered * reg pointer to a registered custom mission element

◆ _mission_element

struct _mission_element

Definition at line 114 of file mission_common.h.

Data Fields
float duration time to spend in the element (<= 0 to disable)
union _mission_element element
uint8_t index index of mission element
enum MissionType type

◆ _mission

struct _mission

Definition at line 142 of file mission_common.h.

+ Collaboration diagram for _mission:
Data Fields
uint8_t current_idx current mission element index
float element_time time in second spend in the current element
struct _mission_element elements[MISSION_ELEMENT_NB]
uint8_t insert_idx inserstion index
struct _mission_registered registered[MISSION_REGISTER_NB]

◆ _mission_wp.wp

union _mission_wp.wp

Definition at line 54 of file mission_common.h.

Data Fields
struct EnuCoor_f wp_f
struct EnuCoor_i wp_i

◆ _mission_circle.center

union _mission_circle.center

Definition at line 61 of file mission_common.h.

Data Fields
struct EnuCoor_f center_f
struct EnuCoor_i center_i

◆ _mission_segment.from

union _mission_segment.from

Definition at line 70 of file mission_common.h.

Data Fields
struct EnuCoor_f from_f
struct EnuCoor_i from_i

◆ _mission_segment.to

union _mission_segment.to

Definition at line 75 of file mission_common.h.

Data Fields
struct EnuCoor_f to_f
struct EnuCoor_i to_i

◆ _mission_path.path

union _mission_path.path

Definition at line 83 of file mission_common.h.

Data Fields
struct EnuCoor_f path_f[MISSION_PATH_NB]
struct EnuCoor_i path_i[MISSION_PATH_NB]

◆ _mission_element.element

union _mission_element.element

Definition at line 116 of file mission_common.h.

Data Fields
struct _mission_circle mission_circle
struct _mission_custom mission_custom
struct _mission_path mission_path
struct _mission_segment mission_segment
struct _mission_wp mission_wp

Macro Definition Documentation

◆ MISSION_CUSTOM_MAX

#define MISSION_CUSTOM_MAX   12

Definition at line 92 of file mission_common.h.

◆ MISSION_ELEMENT_NB

#define MISSION_ELEMENT_NB   20

Max number of elements in the tasks' list can be redefined.

Definition at line 132 of file mission_common.h.

◆ MISSION_PATH_NB

#define MISSION_PATH_NB   5

Definition at line 81 of file mission_common.h.

◆ MISSION_REGISTER_NB

#define MISSION_REGISTER_NB   6

Max number of registered nav/action callbacks can be redefined.

Definition at line 139 of file mission_common.h.

◆ MISSION_TYPE_SIZE

#define MISSION_TYPE_SIZE   6

Definition at line 93 of file mission_common.h.

Typedef Documentation

◆ mission_custom_cb

typedef bool(* mission_custom_cb) (uint8_t nb, float *params, bool init)

custom mission element callback

Parameters
[in]nbnumber of params
[in]paramsarray of params with a maximum of 12
[in]inittrue if the function is called for the first time
Returns
true until the function ends

Definition at line 101 of file mission_common.h.

Enumeration Type Documentation

◆ MissionInsertMode

Enumerator
Append 

add at the last position

Prepend 

add before the current element

ReplaceCurrent 

replace current element

ReplaceAll 

remove all elements and add the new one

ReplaceNexts 

replace the next element and remove all the others

Definition at line 45 of file mission_common.h.

◆ MissionType

Enumerator
MissionWP 
MissionCircle 
MissionSegment 
MissionPath 
MissionCustom 

Definition at line 37 of file mission_common.h.

Function Documentation

◆ mission_element_convert()

bool mission_element_convert ( struct _mission_element el)

Convert mission element's points format if needed.

Parameters
elpointer to the mission element
Returns
return TRUE if conversion is succesful, FALSE otherwise

Definition at line 126 of file mission_common.c.

References _mission_element::element, ENU_BFP_OF_REAL, MissionCircle, MissionPath, MissionSegment, MissionWP, and _mission_element::type.

Referenced by mission_insert().

+ Here is the caller graph for this function:

◆ mission_get()

struct _mission_element* mission_get ( void  )

Get current mission element.

Returns
return a pointer to the next mission element or NULL if no more elements

Definition at line 130 of file mission_common.c.

References _mission::current_idx, _mission::elements, _mission::insert_idx, and mission.

Referenced by mission_run().

+ Here is the caller graph for this function:

◆ mission_init()

void mission_init ( void  )

Init mission structure.

Definition at line 37 of file mission_common.c.

References _mission::current_idx, _mission::element_time, _mission::insert_idx, and mission.

◆ mission_insert()

bool mission_insert ( enum MissionInsertMode  insert,
struct _mission_element element 
)

Insert a mission element according to the insertion mode.

Parameters
insertinsertion mode
elementmission element structure
Returns
return TRUE if insertion is succesful, FALSE otherwise

Definition at line 55 of file mission_common.c.

References Append, _mission::current_idx, _mission::elements, _mission::insert_idx, mission, mission_element_convert(), MISSION_ELEMENT_NB, Prepend, ReplaceAll, ReplaceCurrent, and ReplaceNexts.

Referenced by mission_parse_CIRCLE(), mission_parse_CIRCLE_LLA(), mission_parse_CUSTOM(), mission_parse_GOTO_WP(), mission_parse_GOTO_WP_LLA(), mission_parse_PATH(), mission_parse_PATH_LLA(), mission_parse_SEGMENT(), and mission_parse_SEGMENT_LLA().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mission_parse_CIRCLE()

int mission_parse_CIRCLE ( uint8_t buf)

Definition at line 203 of file mission_common.c.

References _mission_element::duration, _mission_element::element, _mission_element::index, mission_insert(), MissionCircle, and _mission_element::type.

+ Here is the call graph for this function:

◆ mission_parse_CIRCLE_LLA()

int mission_parse_CIRCLE_LLA ( uint8_t buf)

◆ mission_parse_CUSTOM()

int mission_parse_CUSTOM ( uint8_t buf)

◆ mission_parse_END_MISSION()

int mission_parse_END_MISSION ( uint8_t buf)

Definition at line 404 of file mission_common.c.

References _mission::current_idx, _mission::insert_idx, and mission.

◆ mission_parse_GOTO_MISSION()

int mission_parse_GOTO_MISSION ( uint8_t buf)

Definition at line 381 of file mission_common.c.

References _mission::current_idx, mission, and MISSION_ELEMENT_NB.

◆ mission_parse_GOTO_WP()

int mission_parse_GOTO_WP ( uint8_t buf)

Parsing functions called when a mission message is received.

Definition at line 165 of file mission_common.c.

References _mission_element::duration, _mission_element::element, _mission_element::index, mission_insert(), MissionWP, and _mission_element::type.

+ Here is the call graph for this function:

◆ mission_parse_GOTO_WP_LLA()

int mission_parse_GOTO_WP_LLA ( uint8_t buf)

◆ mission_parse_NEXT_MISSION()

int mission_parse_NEXT_MISSION ( uint8_t buf)

◆ mission_parse_PATH()

int mission_parse_PATH ( uint8_t buf)

◆ mission_parse_PATH_LLA()

◆ mission_parse_SEGMENT()

int mission_parse_SEGMENT ( uint8_t buf)

Definition at line 243 of file mission_common.c.

References _mission_element::duration, _mission_element::element, _mission_element::index, mission_insert(), MissionSegment, and _mission_element::type.

+ Here is the call graph for this function:

◆ mission_parse_SEGMENT_LLA()

int mission_parse_SEGMENT_LLA ( uint8_t buf)

◆ mission_point_of_lla()

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.

Parameters
pointpointer to the output ENU point (float)
llapointer to the input LLA coordinates (int)
Returns
TRUE if conversion is succesful, FALSE otherwise

Get the ENU component of LLA mission point This function is firmware specific.

TODO: don't convert to float, either use double or do completely in fixed point

Definition at line 38 of file mission_fw_nav.c.

References LlaCoor_f::alt, LlaCoor_i::alt, BUFFER_ZONE_DIST, UtmCoor_f::east, enu_of_lla_point_i(), float_vect2_norm(), LtpDef_i::hmsl, LtpDef_i::lla, LLA_FLOAT_OF_BFP, max_dist_from_home, nav_utm_east0, nav_utm_north0, nav_utm_zone0, State::ned_initialized_i, State::ned_origin_i, UtmCoor_f::north, state, utm_of_lla_f(), VECT2_DIFF, VECT2_SMUL, VECT2_SUM, VECT3_SMUL, waypoint_get_x(), waypoint_get_y(), waypoints, point::x, FloatVect2::x, point::y, FloatVect2::y, EnuCoor_f::z, and UtmCoor_f::zone.

Referenced by mission_parse_CIRCLE_LLA(), mission_parse_GOTO_WP_LLA(), mission_parse_PATH_LLA(), and mission_parse_SEGMENT_LLA().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mission_register()

bool mission_register ( mission_custom_cb  cb,
char *  type 
)

Register a new navigation or action callback function.

Parameters
cbcallback f(nb, param array)
typestring identifier with 5 characters max (+ 1 '\0' char)
Returns
return TRUE if register is succesful, FALSE otherwise

Definition at line 99 of file mission_common.c.

References _mission_registered::cb, mission, MISSION_REGISTER_NB, MISSION_TYPE_SIZE, _mission::registered, type(), and _mission_registered::type.

Referenced by nav_flower_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mission_run()

int mission_run ( void  )

Run mission.

This function should be implemented into a dedicated file since navigation functions are different for different firmwares

Currently, this function should be called from the flight plan

Returns
return TRUE when the mission is running, FALSE when it is finished

Definition at line 148 of file mission_fw_nav.c.

References _mission::current_idx, dt_navigation, _mission_element::duration, _mission_element::element, _mission::element_time, mission, MISSION_ELEMENT_NB, mission_get(), mission_nav_circle(), mission_nav_custom(), mission_nav_path(), mission_nav_segment(), mission_nav_wp(), MissionCircle, MissionCustom, MissionPath, MissionSegment, MissionWP, and _mission_element::type.

+ Here is the call graph for this function:

◆ mission_status_report()

void mission_status_report ( void  )

Variable Documentation

◆ mission