Paparazzi UAS  v5.18.0_stable
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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef GUIDANCE_H_H
28 #define GUIDANCE_H_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include "math/pprz_algebra_int.h"
36 
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 
68 
74  struct Int32Vect2 pos;
75  struct Int32Vect2 speed;
76  float heading;
77  float heading_rate;
79 };
80 
82  struct Int32Vect2 pos;
83  struct Int32Vect2 speed;
84  struct Int32Vect2 accel;
85 };
86 
93 };
94 
97  /* configuration options */
98  bool use_ref;
100  /* gains */
102 
105 
107 };
108 
109 extern struct HorizontalGuidance guidance_h;
110 
112 
113 extern void guidance_h_init(void);
114 extern void guidance_h_mode_changed(uint8_t new_mode);
115 extern void guidance_h_read_rc(bool in_flight);
116 extern void guidance_h_run(bool in_flight);
117 
118 extern void guidance_h_hover_enter(void);
119 extern void guidance_h_nav_enter(void);
120 
123 extern void guidance_h_from_nav(bool in_flight);
124 
125 extern void guidance_h_set_igain(uint32_t igain);
126 
129 extern void guidance_h_guided_run(bool in_flight);
130 
136 extern bool guidance_h_set_guided_pos(float x, float y);
137 
142 extern bool guidance_h_set_guided_heading(float heading);
143 
149 extern bool guidance_h_set_guided_body_vel(float vx, float vy);
150 
156 extern bool guidance_h_set_guided_vel(float vx, float vy);
157 
162 extern bool guidance_h_set_guided_heading_rate(float rate);
163 
168 extern const struct Int32Vect2 *guidance_h_get_pos_err(void);
169 
170 /* Make sure that ref can only be temporarily disabled for testing,
171  * but not enabled if GUIDANCE_H_USE_REF was defined to FALSE.
172  */
173 #define guidance_h_SetUseRef(_val) { \
174  guidance_h.use_ref = _val && GUIDANCE_H_USE_REF; \
175  }
176 
177 static inline void guidance_h_SetMaxSpeed(float speed)
178 {
179  gh_set_max_speed(speed);
180 }
181 
182 static inline void guidance_h_SetOmega(float omega)
183 {
184  gh_set_omega(omega);
185 }
186 
187 static inline void guidance_h_SetZeta(float zeta)
188 {
189  gh_set_zeta(zeta);
190 }
191 
192 static inline void guidance_h_SetTau(float tau)
193 {
194  gh_set_tau(tau);
195 }
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 #endif /* GUIDANCE_H_H */
HorizontalGuidance::ref
struct HorizontalGuidanceReference ref
reference calculated from setpoints
Definition: guidance_h.h:104
guidance_h_set_guided_body_vel
bool guidance_h_set_guided_body_vel(float vx, float vy)
Set body relative horizontal velocity setpoint in GUIDED mode.
Definition: guidance_h.c:731
HorizontalGuidanceSetpoint::mask
uint8_t mask
bit 5: vx & vy, bit 6: vz, bit 7: vyaw
Definition: guidance_h.h:78
guidance_h_set_guided_heading_rate
bool guidance_h_set_guided_heading_rate(float rate)
Set heading rate setpoint in GUIDED mode.
Definition: guidance_h.c:750
HorizontalGuidanceGains::i
int32_t i
Definition: guidance_h.h:90
gh_set_omega
float gh_set_omega(float omega)
Definition: guidance_h_ref.c:89
transition_percentage
int32_t transition_percentage
Definition: guidance_h.c:92
guidance_h_guided_run
void guidance_h_guided_run(bool in_flight)
Run GUIDED mode control.
Definition: guidance_h.c:688
HorizontalGuidanceSetpoint::pos
struct Int32Vect2 pos
horizontal position setpoint in NED.
Definition: guidance_h.h:74
HorizontalGuidanceReference::accel
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
Definition: guidance_h.h:84
uint32_t
unsigned long uint32_t
Definition: types.h:18
guidance_h_SetMaxSpeed
static void guidance_h_SetMaxSpeed(float speed)
Definition: guidance_h.h:177
HorizontalGuidanceGains
Definition: guidance_h.h:87
HorizontalGuidanceSetpoint::heading
float heading
Definition: guidance_h.h:76
HorizontalGuidance
Definition: guidance_h.h:95
pprz_algebra_float.h
Paparazzi floating point algebra.
HorizontalGuidanceGains::d
int32_t d
Definition: guidance_h.h:89
HorizontalGuidanceReference::speed
struct Int32Vect2 speed
with INT32_SPEED_FRAC
Definition: guidance_h.h:83
HorizontalGuidance::use_ref
bool use_ref
Definition: guidance_h.h:98
guidance_h_mode_changed
void guidance_h_mode_changed(uint8_t new_mode)
Definition: guidance_h.c:222
gh_set_tau
float gh_set_tau(float tau)
Definition: guidance_h_ref.c:81
guidance_h_run
void guidance_h_run(bool in_flight)
Definition: guidance_h.c:361
pprz_algebra_int.h
Paparazzi fixed point algebra.
std.h
HorizontalGuidanceSetpoint::speed
struct Int32Vect2 speed
only used in HOVER mode if GUIDANCE_H_USE_SPEED_REF or in GUIDED mode
Definition: guidance_h.h:75
HorizontalGuidance::mode
uint8_t mode
Definition: guidance_h.h:96
guidance_h_set_igain
void guidance_h_set_igain(uint32_t igain)
Definition: guidance_h.c:681
guidance_h_set_guided_pos
bool guidance_h_set_guided_pos(float x, float y)
Set horizontal position setpoint in GUIDED mode.
Definition: guidance_h.c:709
Int32Vect2
Definition: pprz_algebra_int.h:83
uint8_t
unsigned char uint8_t
Definition: types.h:14
HorizontalGuidance::approx_force_by_thrust
bool approx_force_by_thrust
Definition: guidance_h.h:99
HorizontalGuidanceSetpoint::heading_rate
float heading_rate
Definition: guidance_h.h:77
guidance_h
struct HorizontalGuidance guidance_h
Definition: guidance_h.c:90
guidance_h_ref.h
HorizontalGuidanceSetpoint
Definition: guidance_h.h:69
HorizontalGuidance::sp
struct HorizontalGuidanceSetpoint sp
setpoints
Definition: guidance_h.h:103
guidance_h_hover_enter
void guidance_h_hover_enter(void)
Definition: guidance_h.c:542
HorizontalGuidance::gains
struct HorizontalGuidanceGains gains
Definition: guidance_h.h:101
HorizontalGuidanceGains::v
int32_t v
Definition: guidance_h.h:91
guidance_h_SetZeta
static void guidance_h_SetZeta(float zeta)
Definition: guidance_h.h:187
int32_t
signed long int32_t
Definition: types.h:19
guidance_h_SetOmega
static void guidance_h_SetOmega(float omega)
Definition: guidance_h.h:182
HorizontalGuidanceReference
Definition: guidance_h.h:81
guidance_h_set_guided_vel
bool guidance_h_set_guided_vel(float vx, float vy)
Set horizontal velocity setpoint in GUIDED mode.
Definition: guidance_h.c:739
HorizontalGuidanceReference::pos
struct Int32Vect2 pos
with INT32_POS_FRAC
Definition: guidance_h.h:82
guidance_h_nav_enter
void guidance_h_nav_enter(void)
Definition: guidance_h.c:565
gh_set_zeta
float gh_set_zeta(float zeta)
Definition: guidance_h_ref.c:98
guidance_h_set_guided_heading
bool guidance_h_set_guided_heading(float heading)
Set heading setpoint in GUIDED mode.
Definition: guidance_h.c:720
HorizontalGuidanceGains::p
int32_t p
Definition: guidance_h.h:88
FloatEulers
euler angles
Definition: pprz_algebra_float.h:84
gh_set_max_speed
float gh_set_max_speed(float max_speed)
Set a new maximum speed for waypoint navigation.
Definition: guidance_h_ref.c:73
HorizontalGuidanceGains::a
int32_t a
Definition: guidance_h.h:92
guidance_h_from_nav
void guidance_h_from_nav(bool in_flight)
Set horizontal guidance from NAV and run control loop.
Definition: guidance_h.c:579
guidance_h_SetTau
static void guidance_h_SetTau(float tau)
Definition: guidance_h.h:192
guidance_h_read_rc
void guidance_h_read_rc(bool in_flight)
Definition: guidance_h.c:302
guidance_h_get_pos_err
const struct Int32Vect2 * guidance_h_get_pos_err(void)
Gets the position error.
Definition: guidance_h.c:760
guidance_h_init
void guidance_h_init(void)
Definition: guidance_h.c:176
HorizontalGuidance::rc_sp
struct FloatEulers rc_sp
Definition: guidance_h.h:106
heading
float heading
Definition: wedgebug.c:258