Paparazzi UAS  v5.12_stable-4-g9b43e9b
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"
33 
35 #include "generated/airframe.h"
36 #include "std.h"
37 
41 #ifndef GUIDANCE_H_USE_REF
42 #define GUIDANCE_H_USE_REF TRUE
43 #endif
44 
49 #ifndef GUIDANCE_H_USE_SPEED_REF
50 #define GUIDANCE_H_USE_SPEED_REF TRUE
51 #endif
52 
53 #define GUIDANCE_H_MODE_KILL 0
54 #define GUIDANCE_H_MODE_RATE 1
55 #define GUIDANCE_H_MODE_ATTITUDE 2
56 #define GUIDANCE_H_MODE_HOVER 3
57 #define GUIDANCE_H_MODE_NAV 4
58 #define GUIDANCE_H_MODE_RC_DIRECT 5
59 #define GUIDANCE_H_MODE_CARE_FREE 6
60 #define GUIDANCE_H_MODE_FORWARD 7
61 #define GUIDANCE_H_MODE_MODULE 8
62 #define GUIDANCE_H_MODE_FLIP 9
63 #define GUIDANCE_H_MODE_GUIDED 10
64 
65 
71  struct Int32Vect2 pos;
72  struct Int32Vect2 speed;
73  float heading;
74  float heading_rate;
76 };
77 
79  struct Int32Vect2 pos;
80  struct Int32Vect2 speed;
81  struct Int32Vect2 accel;
82 };
83 
90 };
91 
94  /* configuration options */
95  bool use_ref;
97  /* gains */
99 
102 
104 };
105 
106 extern struct HorizontalGuidance guidance_h;
107 
110 
111 extern void guidance_h_init(void);
112 extern void guidance_h_mode_changed(uint8_t new_mode);
113 extern void guidance_h_read_rc(bool in_flight);
114 extern void guidance_h_run(bool in_flight);
115 
116 extern void guidance_h_hover_enter(void);
117 extern void guidance_h_nav_enter(void);
118 
121 extern void guidance_h_from_nav(bool in_flight);
122 
123 extern void guidance_h_set_igain(uint32_t igain);
124 
127 extern void guidance_h_guided_run(bool in_flight);
128 
134 extern bool guidance_h_set_guided_pos(float x, float y);
135 
140 extern bool guidance_h_set_guided_heading(float heading);
141 
147 extern bool guidance_h_set_guided_body_vel(float vx, float vy);
148 
154 extern bool guidance_h_set_guided_vel(float vx, float vy);
155 
160 extern bool guidance_h_set_guided_heading_rate(float rate);
161 
166 extern const struct Int32Vect2 *guidance_h_get_pos_err(void);
167 
168 /* Make sure that ref can only be temporarily disabled for testing,
169  * but not enabled if GUIDANCE_H_USE_REF was defined to FALSE.
170  */
171 #define guidance_h_SetUseRef(_val) { \
172  guidance_h.use_ref = _val && GUIDANCE_H_USE_REF; \
173  }
174 
175 static inline void guidance_h_SetMaxSpeed(float speed)
176 {
177  gh_set_max_speed(speed);
178 }
179 
180 static inline void guidance_h_SetOmega(float omega)
181 {
182  gh_set_omega(omega);
183 }
184 
185 static inline void guidance_h_SetZeta(float zeta)
186 {
187  gh_set_zeta(zeta);
188 }
189 
190 static inline void guidance_h_SetTau(float tau)
191 {
192  gh_set_tau(tau);
193 }
194 
195 #endif /* GUIDANCE_H_H */
Reference generation for horizontal guidance.
struct Int32Vect2 pos
horizontal position setpoint in NED.
Definition: guidance_h.h:71
bool guidance_h_set_guided_vel(float vx, float vy)
Set horizontal velocity setpoint in GUIDED mode.
Definition: guidance_h.c:719
float gh_set_max_speed(float max_speed)
Set a new maximum speed for waypoint navigation.
void guidance_h_mode_changed(uint8_t new_mode)
Definition: guidance_h.c:213
bool approx_force_by_thrust
Definition: guidance_h.h:96
bool guidance_h_set_guided_pos(float x, float y)
Set horizontal position setpoint in GUIDED mode.
Definition: guidance_h.c:689
static void guidance_h_SetZeta(float zeta)
Definition: guidance_h.h:185
struct HorizontalGuidanceReference ref
reference calculated from setpoints
Definition: guidance_h.h:101
struct HorizontalGuidanceGains gains
Definition: guidance_h.h:98
void guidance_h_set_igain(uint32_t igain)
Definition: guidance_h.c:661
euler angles
bool guidance_h_set_guided_body_vel(float vx, float vy)
Set body relative horizontal velocity setpoint in GUIDED mode.
Definition: guidance_h.c:711
uint8_t mask
bit 5: vx & vy, bit 6: vz, bit 7: vyaw
Definition: guidance_h.h:75
float gh_set_omega(float omega)
static float heading
Definition: ahrs_infrared.c:45
struct Int32Vect2 speed
with INT32_SPEED_FRAC
Definition: guidance_h.h:80
float gh_set_tau(float tau)
static void guidance_h_SetMaxSpeed(float speed)
Definition: guidance_h.h:175
Paparazzi floating point algebra.
struct Int32Vect2 speed
only used in HOVER mode if GUIDANCE_H_USE_SPEED_REF or in GUIDED mode
Definition: guidance_h.h:72
int32_t transition_theta_offset
Definition: guidance_h.c:83
unsigned long uint32_t
Definition: types.h:18
struct HorizontalGuidance guidance_h
Definition: guidance_h.c:80
void guidance_h_run(bool in_flight)
Definition: guidance_h.c:351
signed long int32_t
Definition: types.h:19
void guidance_h_read_rc(bool in_flight)
Definition: guidance_h.c:292
bool guidance_h_set_guided_heading_rate(float rate)
Set heading rate setpoint in GUIDED mode.
Definition: guidance_h.c:730
struct Int32Vect2 pos
with INT32_POS_FRAC
Definition: guidance_h.h:79
unsigned char uint8_t
Definition: types.h:14
void guidance_h_hover_enter(void)
Definition: guidance_h.c:524
void guidance_h_guided_run(bool in_flight)
Run GUIDED mode control.
Definition: guidance_h.c:668
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
Definition: guidance_h.h:81
void guidance_h_init(void)
Definition: guidance_h.c:167
struct FloatEulers rc_sp
Definition: guidance_h.h:103
void guidance_h_nav_enter(void)
Definition: guidance_h.c:547
int32_t transition_percentage
Definition: guidance_h.c:82
float gh_set_zeta(float zeta)
bool guidance_h_set_guided_heading(float heading)
Set heading setpoint in GUIDED mode.
Definition: guidance_h.c:700
const struct Int32Vect2 * guidance_h_get_pos_err(void)
Gets the position error.
Definition: guidance_h.c:740
void guidance_h_from_nav(bool in_flight)
Set horizontal guidance from NAV and run control loop.
Definition: guidance_h.c:561
static void guidance_h_SetTau(float tau)
Definition: guidance_h.h:190
struct HorizontalGuidanceSetpoint sp
setpoints
Definition: guidance_h.h:100
Paparazzi fixed point algebra.
static void guidance_h_SetOmega(float omega)
Definition: guidance_h.h:180