-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
common_flight_plan.h
69 lines (55 loc) · 2.19 KB
/
common_flight_plan.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright (C) 2007-2011 The Paparazzi Team
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file subsystems/navigation/common_flight_plan.h
* Common flight_plan functions shared between fixedwing and rotorcraft.
*/
#ifndef COMMON_FLIGHT_PLAN_H
#define COMMON_FLIGHT_PLAN_H
#include "std.h"
/** In s */
extern uint16_t stage_time, block_time;
extern uint8_t nav_stage, nav_block;
extern uint8_t last_block, last_stage;
/** needs to be implemented by fixedwing and rotorcraft seperately */
void nav_init_stage(void);
void nav_init_block(void);
void nav_goto_block(uint8_t block_id);
#define InitStage() nav_init_stage();
#define Block(x) case x: nav_block=x;
#define NextBlock() nav_goto_block(nav_block + 1)
#define GotoBlock(b) nav_goto_block(b)
#define Stage(s) case s: nav_stage=s;
#define NextStage() { nav_stage++; InitStage(); }
#define NextStageAndBreak() { nav_stage++; InitStage(); break; }
#define NextStageAndBreakFrom(wp) { last_wp = wp; NextStageAndBreak(); }
#define Label(x) label_ ## x:
#define Goto(x) { goto label_ ## x; }
#define Return(RESET_STAGE) { nav_block=last_block; if (RESET_STAGE==1) {nav_stage=0;} else {nav_stage=last_stage;} block_time=0;}
#define And(x, y) ((x) && (y))
#define Or(x, y) ((x) || (y))
#define Min(x,y) (x < y ? x : y)
#define Max(x,y) (x > y ? x : y)
#define LessThan(_x, _y) ((_x) < (_y))
#define MoreThan(_x, _y) ((_x) > (_y))
/** Time in s since the entrance in the current block */
#define NavBlockTime() (block_time)
#endif /* COMMON_FLIGHT_PLAN_H */