Paparazzi UAS  v7.0_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  struct Int32Vect2 accel;
83 
84  float heading;
85  float heading_rate;
86 
87  enum {
91  } h_mask;
92  enum {
96 };
97 
99  struct Int32Vect2 pos;
100  struct Int32Vect2 speed;
101  struct Int32Vect2 accel;
102 };
103 
106  /* configuration options */
107  bool use_ref;
108 
111 
112  struct FloatEulers rc_sp;
113 };
114 
115 extern struct HorizontalGuidance guidance_h;
116 
118 
119 extern void guidance_h_init(void);
120 extern void guidance_h_mode_changed(uint8_t new_mode);
121 extern void guidance_h_read_rc(bool in_flight);
122 extern void guidance_h_run(bool in_flight);
123 extern void guidance_h_run_enter(void);
124 extern struct StabilizationSetpoint guidance_h_run_pos(bool in_flight, struct HorizontalGuidance *gh);
125 extern struct StabilizationSetpoint guidance_h_run_speed(bool in_flight, struct HorizontalGuidance *gh);
126 extern struct StabilizationSetpoint guidance_h_run_accel(bool in_flight, struct HorizontalGuidance *gh);
127 
128 extern void guidance_h_hover_enter(void);
129 extern void guidance_h_nav_enter(void);
130 
133 extern void guidance_h_from_nav(bool in_flight);
134 
137 extern void guidance_h_guided_run(bool in_flight);
138 
143 extern void guidance_h_set_pos(float x, float y);
144 
148 extern void guidance_h_set_heading(float heading);
149 
154 extern void guidance_h_set_body_vel(float vx, float vy);
155 
160 extern void guidance_h_set_acc(float ax, float ay);
161 
166 extern void guidance_h_set_body_acc(float ax, float ay);
167 
172 extern void guidance_h_set_vel(float vx, float vy);
173 
177 extern void guidance_h_set_heading_rate(float rate);
178 
179 /* Make sure that ref can only be temporarily disabled for testing,
180  * but not enabled if GUIDANCE_H_USE_REF was defined to FALSE.
181  */
182 #define guidance_h_SetUseRef(_val) { \
183  guidance_h.use_ref = _val && GUIDANCE_H_USE_REF; \
184  }
185 
186 static inline void guidance_h_SetMaxSpeed(float speed)
187 {
188  gh_set_max_speed(speed);
189 }
190 
191 static inline void guidance_h_SetOmega(float omega)
192 {
193  gh_set_omega(omega);
194 }
195 
196 static inline void guidance_h_SetZeta(float zeta)
197 {
198  gh_set_zeta(zeta);
199 }
200 
201 static inline void guidance_h_SetTau(float tau)
202 {
203  gh_set_tau(tau);
204 }
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #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_set_acc(float ax, float ay)
Set horizontal velocity setpoint.
Definition: guidance_h.c:621
void guidance_h_read_rc(bool in_flight)
Definition: guidance_h.c:224
void guidance_h_set_pos(float x, float y)
Set horizontal position setpoint.
Definition: guidance_h.c:578
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
Definition: guidance_h.h:101
void guidance_h_mode_changed(uint8_t new_mode)
Definition: guidance_h.c:151
void guidance_h_run_enter(void)
void guidance_h_hover_enter(void)
Definition: guidance_h.c:416
struct StabilizationSetpoint guidance_h_run_pos(bool in_flight, struct HorizontalGuidance *gh)
void guidance_h_set_body_acc(float ax, float ay)
Set body relative horizontal acceleration setpoint.
Definition: guidance_h.c:613
struct Int32Vect2 speed
with INT32_SPEED_FRAC
Definition: guidance_h.h:100
struct FloatEulers rc_sp
remote control setpoint
Definition: guidance_h.h:112
static void guidance_h_SetTau(float tau)
Definition: guidance_h.h:201
void guidance_h_guided_run(bool in_flight)
Run GUIDED mode control.
Definition: guidance_h.c:563
void guidance_h_from_nav(bool in_flight)
Set horizontal guidance from NAV and run control loop.
Definition: guidance_h.c:448
void guidance_h_set_heading(float heading)
Set heading setpoint.
Definition: guidance_h.c:588
struct StabilizationSetpoint guidance_h_run_speed(bool in_flight, struct HorizontalGuidance *gh)
void guidance_h_init(void)
Definition: guidance_h.c:107
struct HorizontalGuidance guidance_h
Definition: guidance_h.c:50
static void guidance_h_SetMaxSpeed(float speed)
Definition: guidance_h.h:186
void guidance_h_nav_enter(void)
Definition: guidance_h.c:437
struct Int32Vect2 pos
with INT32_POS_FRAC
Definition: guidance_h.h:99
struct HorizontalGuidanceReference ref
reference calculated from setpoints
Definition: guidance_h.h:110
struct StabilizationSetpoint guidance_h_run_accel(bool in_flight, struct HorizontalGuidance *gh)
void guidance_h_set_vel(float vx, float vy)
Set horizontal acceleration setpoint.
Definition: guidance_h.c:603
static void guidance_h_SetOmega(float omega)
Definition: guidance_h.h:191
void guidance_h_set_body_vel(float vx, float vy)
Set body relative horizontal velocity setpoint.
Definition: guidance_h.c:595
static void guidance_h_SetZeta(float zeta)
Definition: guidance_h.h:196
void guidance_h_set_heading_rate(float rate)
Set heading rate setpoint.
Definition: guidance_h.c:631
struct HorizontalGuidanceSetpoint sp
setpoints
Definition: guidance_h.h:109
void guidance_h_run(bool in_flight)
Definition: guidance_h.c:283
General stabilization interface for rotorcrafts.
enum HorizontalGuidanceSetpoint::@269 h_mask
enum HorizontalGuidanceSetpoint::@270 yaw_mask
struct Int32Vect2 pos
horizontal position setpoint in NED.
Definition: guidance_h.h:80
struct Int32Vect2 accel
For direct control of acceleration, if the guidance scheme is able to provide it.
Definition: guidance_h.h:82
struct Int32Vect2 speed
only used in HOVER mode if GUIDANCE_H_USE_SPEED_REF or in GUIDED mode
Definition: guidance_h.h:81
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