Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
nav_base.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
27 #ifndef NAV_BASE_H
28 #define NAV_BASE_H
29 
30 #include "std.h"
32 
35 struct NavGoto_t {
36  struct EnuCoor_f from;
37  struct EnuCoor_f to;
38  float dist2_to_wp;
39  float leg_progress;
40  float leg_length;
41 };
42 
45 struct NavCircle_t {
46  struct EnuCoor_f center;
47  float radius;
48  float qdr;
49  float radians;
50 };
51 
54 enum oval_status { OR12, OC2, OR21, OC1 };
55 struct NavOval_t {
56  enum oval_status status;
58 };
59 
62 struct NavBase_t {
63  struct NavGoto_t goto_wp;
64  struct NavCircle_t circle;
65  struct NavOval_t oval;
66 };
67 
70 static inline float nav_circle_get_count(struct NavCircle_t *circle)
71 {
72  return fabsf(circle->radians) / (2.f*M_PI);
73 }
74 
75 static inline float nav_circle_qdr(struct NavCircle_t *circle)
76 {
77  float qdr = DegOfRad(M_PI_2 - circle->qdr);
78  NormCourse(qdr);
79  return qdr;
80 }
81 
82 
83 #endif
84 
oval_status
Definition: nav.h:60
float leg_progress
progress over leg
Definition: nav_base.h:39
struct EnuCoor_f center
center WP position
Definition: nav_base.h:46
struct NavGoto_t goto_wp
Definition: nav_base.h:63
uint8_t count
number of laps
Definition: nav_base.h:57
float leg_length
leg length
Definition: nav_base.h:40
struct NavOval_t oval
Definition: nav_base.h:65
@ OC2
Definition: nav_base.h:54
@ OC1
Definition: nav_base.h:54
@ OR12
Definition: nav_base.h:54
@ OR21
Definition: nav_base.h:54
static float nav_circle_qdr(struct NavCircle_t *circle)
Definition: nav_base.h:75
struct EnuCoor_f to
end WP position
Definition: nav_base.h:37
float dist2_to_wp
squared distance to next waypoint
Definition: nav_base.h:38
struct NavCircle_t circle
Definition: nav_base.h:64
struct EnuCoor_f from
start WP position
Definition: nav_base.h:36
enum oval_status status
oval status
Definition: nav_base.h:56
float radians
incremental angular distance
Definition: nav_base.h:49
float radius
radius in meters
Definition: nav_base.h:47
static float nav_circle_get_count(struct NavCircle_t *circle)
helper functions
Definition: nav_base.h:70
float qdr
qdr in radians
Definition: nav_base.h:48
Basic Nav struct.
Definition: nav_base.h:62
Circle pattern.
Definition: nav_base.h:45
Waypoint and route pattern.
Definition: nav_base.h:35
Paparazzi floating point math for geodetic calculations.
vector in East North Up coordinates Units: meters
#define NormCourse(x)
Normalize a degree angle between 0 and 359.
Definition: navigation.h:151
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98