Paparazzi UAS  v6.3_unstable
Paparazzi is a free software Unmanned Aircraft System.
guidance_h.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
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 
26 #ifndef GUIDANCE_H_H
27 #define GUIDANCE_H_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include "math/pprz_algebra_int.h"
35 
38 #include "generated/airframe.h"
39 #include "std.h"
40 
44 #ifndef GUIDANCE_H_USE_REF
45 #define GUIDANCE_H_USE_REF TRUE
46 #endif
47 
52 #ifndef GUIDANCE_H_USE_SPEED_REF
53 #define GUIDANCE_H_USE_SPEED_REF TRUE
54 #endif
55 
56 #define GUIDANCE_H_MODE_KILL 0
57 #define GUIDANCE_H_MODE_RATE 1
58 #define GUIDANCE_H_MODE_ATTITUDE 2
59 #define GUIDANCE_H_MODE_HOVER 3
60 #define GUIDANCE_H_MODE_NAV 4
61 #define GUIDANCE_H_MODE_RC_DIRECT 5
62 #define GUIDANCE_H_MODE_CARE_FREE 6
63 #define GUIDANCE_H_MODE_FORWARD 7
64 #define GUIDANCE_H_MODE_MODULE 8
65 #define GUIDANCE_H_MODE_FLIP 9
66 #define GUIDANCE_H_MODE_GUIDED 10
67 
70 #ifndef GUIDANCE_H_MAX_BANK
71 #define GUIDANCE_H_MAX_BANK RadOfDeg(20)
72 #endif
73 
74 
80  struct Int32Vect2 pos;
81  struct Int32Vect2 speed;
82  float heading;
83  float heading_rate;
85 };
86 
88  struct Int32Vect2 pos;
89  struct Int32Vect2 speed;
90  struct Int32Vect2 accel;
91 };
92 
95  /* configuration options */
96  bool use_ref;
97 
100 
101  struct FloatEulers rc_sp;
102 };
103 
104 extern struct HorizontalGuidance guidance_h;
105 
107 
108 extern void guidance_h_init(void);
109 extern void guidance_h_mode_changed(uint8_t new_mode);
110 extern void guidance_h_read_rc(bool in_flight);
111 extern void guidance_h_run(bool in_flight);
112 extern void guidance_h_run_enter(void);
113 extern struct StabilizationSetpoint guidance_h_run_pos(bool in_flight, struct HorizontalGuidance *gh);
114 extern struct StabilizationSetpoint guidance_h_run_speed(bool in_flight, struct HorizontalGuidance *gh);
115 extern struct StabilizationSetpoint guidance_h_run_accel(bool in_flight, struct HorizontalGuidance *gh);
116 
117 extern void guidance_h_hover_enter(void);
118 extern void guidance_h_nav_enter(void);
119 
122 extern void guidance_h_from_nav(bool in_flight);
123 
126 extern void guidance_h_guided_run(bool in_flight);
127 
132 extern void guidance_h_set_pos(float x, float y);
133 
137 extern void guidance_h_set_heading(float heading);
138 
143 extern void guidance_h_set_body_vel(float vx, float vy);
144 
149 extern void guidance_h_set_vel(float vx, float vy);
150 
154 extern void guidance_h_set_heading_rate(float rate);
155 
156 /* Make sure that ref can only be temporarily disabled for testing,
157  * but not enabled if GUIDANCE_H_USE_REF was defined to FALSE.
158  */
159 #define guidance_h_SetUseRef(_val) { \
160  guidance_h.use_ref = _val && GUIDANCE_H_USE_REF; \
161  }
162 
163 static inline void guidance_h_SetMaxSpeed(float speed)
164 {
165  gh_set_max_speed(speed);
166 }
167 
168 static inline void guidance_h_SetOmega(float omega)
169 {
170  gh_set_omega(omega);
171 }
172 
173 static inline void guidance_h_SetZeta(float zeta)
174 {
175  gh_set_zeta(zeta);
176 }
177 
178 static inline void guidance_h_SetTau(float tau)
179 {
180  gh_set_tau(tau);
181 }
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* GUIDANCE_H_H */
euler angles
float gh_set_zeta(float zeta)
float gh_set_tau(float tau)
float gh_set_omega(float omega)
float gh_set_max_speed(float max_speed)
Set a new maximum speed for waypoint navigation.
Reference generation for horizontal guidance.
Paparazzi floating point algebra.
Paparazzi fixed point algebra.
int32_t transition_percentage
Definition: guidance_h.c:52
void guidance_h_read_rc(bool in_flight)
Definition: guidance_h.c:218
void guidance_h_set_pos(float x, float y)
Set horizontal position setpoint.
Definition: guidance_h.c:550
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
Definition: guidance_h.h:90
uint8_t mask
bit 5: vx & vy, bit 6: vz, bit 7: vyaw
Definition: guidance_h.h:84
void guidance_h_mode_changed(uint8_t new_mode)
Definition: guidance_h.c:145
void guidance_h_run_enter(void)
void guidance_h_hover_enter(void)
Definition: guidance_h.c:390
struct StabilizationSetpoint guidance_h_run_pos(bool in_flight, struct HorizontalGuidance *gh)
struct Int32Vect2 pos
horizontal position setpoint in NED.
Definition: guidance_h.h:80
struct Int32Vect2 speed
with INT32_SPEED_FRAC
Definition: guidance_h.h:89
struct FloatEulers rc_sp
remote control setpoint
Definition: guidance_h.h:101
static void guidance_h_SetTau(float tau)
Definition: guidance_h.h:178
void guidance_h_guided_run(bool in_flight)
Run GUIDED mode control.
Definition: guidance_h.c:535
void guidance_h_from_nav(bool in_flight)
Set horizontal guidance from NAV and run control loop.
Definition: guidance_h.c:422
void guidance_h_set_heading(float heading)
Set heading setpoint.
Definition: guidance_h.c:557
struct StabilizationSetpoint guidance_h_run_speed(bool in_flight, struct HorizontalGuidance *gh)
void guidance_h_init(void)
Definition: guidance_h.c:103
struct HorizontalGuidance guidance_h
Definition: guidance_h.c:50
static void guidance_h_SetMaxSpeed(float speed)
Definition: guidance_h.h:163
void guidance_h_nav_enter(void)
Definition: guidance_h.c:411
struct Int32Vect2 pos
with INT32_POS_FRAC
Definition: guidance_h.h:88
struct HorizontalGuidanceReference ref
reference calculated from setpoints
Definition: guidance_h.h:99
struct StabilizationSetpoint guidance_h_run_accel(bool in_flight, struct HorizontalGuidance *gh)
struct Int32Vect2 speed
only used in HOVER mode if GUIDANCE_H_USE_SPEED_REF or in GUIDED mode
Definition: guidance_h.h:81
void guidance_h_set_vel(float vx, float vy)
Set horizontal velocity setpoint.
Definition: guidance_h.c:572
static void guidance_h_SetOmega(float omega)
Definition: guidance_h.h:168
void guidance_h_set_body_vel(float vx, float vy)
Set body relative horizontal velocity setpoint.
Definition: guidance_h.c:564
static void guidance_h_SetZeta(float zeta)
Definition: guidance_h.h:173
void guidance_h_set_heading_rate(float rate)
Set heading rate setpoint.
Definition: guidance_h.c:579
struct HorizontalGuidanceSetpoint sp
setpoints
Definition: guidance_h.h:98
void guidance_h_run(bool in_flight)
Definition: guidance_h.c:277
General stabilization interface for rotorcrafts.
Stabilization setpoint.
Definition: stabilization.h:42
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
float heading
Definition: wedgebug.c:258