[flight plan] add on_enter and on_exit functions for nav block (#3385)

The functions passed to the attributes 'on_enter' and 'on_exit' will be
called once every time the flight plan state machine enters or leaves a
block, even if the block change is requested by the operator or if it is
caused by an exception.
It allows to properly activate and then disable services related to a
specific block.
Another good side effect is that the block and stage index are now
private and can't be modified by external modules. Old variables
nav_block and nav_stage can still be used as read-only.

Based on the work from:
Baptiste Pollien, Christophe Garion, Gautier Hattenberger, Pierre Roux, Xavier Thirioux.
A Verified UAV Flight Plan Generator. 2023 IEEE/ACM 11th International Conference on Formal Methods in Software Engineering (FormaliSE),
May 2023, Melbourne, Australia. pp.130-140, 10.1109/FormaliSE58978.2023.00021
This commit is contained in:
Gautier Hattenberger
2024-10-04 08:52:57 +02:00
committed by GitHub
parent d7c50a262b
commit cea5c644e5
9 changed files with 162 additions and 29 deletions
+1 -2
View File
@@ -531,8 +531,7 @@ static void send_survey(struct transport_tx *trans, struct link_device *dev)
*/
void nav_init(void)
{
nav_block = 0;
nav_stage = 0;
common_flight_plan_init();
ground_alt = GROUND_ALT;
nav_glide_pitch_trim = NAV_GLIDE_PITCH_TRIM;
nav_radius = DEFAULT_CIRCLE_RADIUS;
@@ -70,9 +70,7 @@ static inline void nav_set_altitude(void);
void nav_init(void)
{
waypoints_init();
nav_block = 0;
nav_stage = 0;
common_flight_plan_init();
nav.horizontal_mode = NAV_HORIZONTAL_MODE_WAYPOINT;
nav.vertical_mode = NAV_VERTICAL_MODE_ALT;
+1 -3
View File
@@ -79,9 +79,7 @@ static void send_wp_moved(struct transport_tx *trans, struct link_device *dev)
void nav_init(void)
{
waypoints_init();
nav_block = 0;
nav_stage = 0;
common_flight_plan_init();
nav.mode = NAV_MODE_WAYPOINT;