Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
31 #include "math/pprz_algebra_int.h"
32 
34 #include "generated/airframe.h"
35 #include "std.h"
36 
40 #ifndef GUIDANCE_H_USE_REF
41 #define GUIDANCE_H_USE_REF TRUE
42 #endif
43 
48 #ifndef GUIDANCE_H_USE_SPEED_REF
49 #define GUIDANCE_H_USE_SPEED_REF TRUE
50 #endif
51 
52 #define GUIDANCE_H_MODE_KILL 0
53 #define GUIDANCE_H_MODE_RATE 1
54 #define GUIDANCE_H_MODE_ATTITUDE 2
55 #define GUIDANCE_H_MODE_HOVER 3
56 #define GUIDANCE_H_MODE_NAV 4
57 #define GUIDANCE_H_MODE_RC_DIRECT 5
58 #define GUIDANCE_H_MODE_CARE_FREE 6
59 #define GUIDANCE_H_MODE_FORWARD 7
60 #define GUIDANCE_H_MODE_MODULE 8
61 #define GUIDANCE_H_MODE_FLIP 9
62 #define GUIDANCE_H_MODE_GUIDED 10
63 
64 
70  struct Int32Vect2 pos;
71  struct Int32Vect2 speed;
75 };
76 
78  struct Int32Vect2 pos;
79  struct Int32Vect2 speed;
80  struct Int32Vect2 accel;
81 };
82 
89 };
90 
93  /* configuration options */
94  bool use_ref;
96  /* gains */
98 
101 
103 };
104 
105 extern struct HorizontalGuidance guidance_h;
106 
109 
110 extern void guidance_h_init(void);
111 extern void guidance_h_mode_changed(uint8_t new_mode);
112 extern void guidance_h_read_rc(bool in_flight);
113 extern void guidance_h_run(bool in_flight);
114 
115 extern void guidance_h_set_igain(uint32_t igain);
116 
122 extern bool guidance_h_set_guided_pos(float x, float y);
123 
128 extern bool guidance_h_set_guided_heading(float heading);
129 
135 extern bool guidance_h_set_guided_body_vel(float vx, float vy);
136 
142 extern bool guidance_h_set_guided_vel(float vx, float vy);
143 
148 extern bool guidance_h_set_guided_heading_rate(float rate);
149 
154 extern const struct Int32Vect2 *guidance_h_get_pos_err(void);
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 #endif /* GUIDANCE_H_H */
int32_t heading_rate
with INT32_RATE_FRAC
Definition: guidance_h.h:73
uint8_t mask
bit 5: vx & vy, bit 6: vz, bit 7: vyaw
Definition: guidance_h.h:74
Reference generation for horizontal guidance.
void guidance_h_mode_changed(uint8_t new_mode)
Definition: guidance_h.c:222
struct Int32Eulers rc_sp
with INT32_ANGLE_FRAC
Definition: guidance_h.h:102
static void guidance_h_SetTau(float tau)
Definition: guidance_h.h:178
void guidance_h_run(bool in_flight)
Definition: guidance_h.c:365
bool guidance_h_set_guided_heading_rate(float rate)
Set heading rate setpoint in GUIDED mode.
Definition: guidance_h.c:722
float gh_set_max_speed(float max_speed)
Set a new maximum speed for waypoint navigation.
struct HorizontalGuidance guidance_h
Definition: guidance_h.c:80
const struct Int32Vect2 * guidance_h_get_pos_err(void)
Gets the position error.
Definition: guidance_h.c:732
bool guidance_h_set_guided_heading(float heading)
Set heading setpoint in GUIDED mode.
Definition: guidance_h.c:692
struct HorizontalGuidanceReference ref
reference calculated from setpoints
Definition: guidance_h.h:100
struct HorizontalGuidanceSetpoint sp
setpoints
Definition: guidance_h.h:99
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
Definition: guidance_h.h:80
bool guidance_h_set_guided_pos(float x, float y)
Set horizontal position setpoint in GUIDED mode.
Definition: guidance_h.c:681
static void guidance_h_SetMaxSpeed(float speed)
Definition: guidance_h.h:163
float gh_set_omega(float omega)
static float heading
Definition: ahrs_infrared.c:45
float gh_set_tau(float tau)
int32_t transition_theta_offset
Definition: guidance_h.c:83
struct Int32Vect2 speed
with INT32_SPEED_FRAC
Definition: guidance_h.h:79
euler angles
unsigned long uint32_t
Definition: types.h:18
bool guidance_h_set_guided_vel(float vx, float vy)
Set horizontal velocity setpoint in GUIDED mode.
Definition: guidance_h.c:711
void guidance_h_read_rc(bool in_flight)
Definition: guidance_h.c:306
static void guidance_h_SetZeta(float zeta)
Definition: guidance_h.h:173
int32_t transition_percentage
Definition: guidance_h.c:82
signed long int32_t
Definition: types.h:19
void guidance_h_init(void)
Definition: guidance_h.c:169
int32_t heading
with INT32_ANGLE_FRAC
Definition: guidance_h.h:72
unsigned char uint8_t
Definition: types.h:14
struct HorizontalGuidanceGains gains
Definition: guidance_h.h:97
struct Int32Vect2 pos
with INT32_POS_FRAC
Definition: guidance_h.h:78
bool approx_force_by_thrust
Definition: guidance_h.h:95
bool guidance_h_set_guided_body_vel(float vx, float vy)
Set body relative horizontal velocity setpoint in GUIDED mode.
Definition: guidance_h.c:703
float gh_set_zeta(float zeta)
void guidance_h_set_igain(uint32_t igain)
Definition: guidance_h.c:675
struct Int32Vect2 speed
only used in HOVER mode if GUIDANCE_H_USE_SPEED_REF or in GUIDED mode
Definition: guidance_h.h:71
struct Int32Vect2 pos
horizontal position setpoint in NED.
Definition: guidance_h.h:70
Paparazzi fixed point algebra.
static void guidance_h_SetOmega(float omega)
Definition: guidance_h.h:168