Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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;
73 };
74 
76  struct Int32Vect2 pos;
77  struct Int32Vect2 speed;
78  struct Int32Vect2 accel;
79 };
80 
87 };
88 
91  /* configuration options */
92  bool_t use_ref;
94  /* gains */
96 
99 
101 };
102 
103 extern struct HorizontalGuidance guidance_h;
104 
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_t in_flight);
111 extern void guidance_h_run(bool_t in_flight);
112 
113 extern void guidance_h_set_igain(uint32_t igain);
114 
120 bool_t guidance_h_set_guided_pos(float x, float y);
121 
127 
128 /* Make sure that ref can only be temporarily disabled for testing,
129  * but not enabled if GUIDANCE_H_USE_REF was defined to FALSE.
130  */
131 #define guidance_h_SetUseRef(_val) { \
132  guidance_h.use_ref = _val && GUIDANCE_H_USE_REF; \
133  }
134 
135 static inline void guidance_h_SetMaxSpeed(float speed)
136 {
137  gh_set_max_speed(speed);
138 }
139 
140 static inline void guidance_h_SetOmega(float omega)
141 {
142  gh_set_omega(omega);
143 }
144 
145 static inline void guidance_h_SetZeta(float zeta)
146 {
147  gh_set_zeta(zeta);
148 }
149 
150 static inline void guidance_h_SetTau(float tau)
151 {
152  gh_set_tau(tau);
153 }
154 
155 #endif /* GUIDANCE_H_H */
Reference generation for horizontal guidance.
void guidance_h_mode_changed(uint8_t new_mode)
Definition: guidance_h.c:216
struct Int32Eulers rc_sp
with INT32_ANGLE_FRAC
Definition: guidance_h.h:100
static void guidance_h_SetTau(float tau)
Definition: guidance_h.h:150
float gh_set_max_speed(float max_speed)
Set a new maximum speed for waypoint navigation.
struct HorizontalGuidance guidance_h
Definition: guidance_h.c:79
void guidance_h_run(bool_t in_flight)
Definition: guidance_h.c:347
bool_t approx_force_by_thrust
Definition: guidance_h.h:93
struct HorizontalGuidanceReference ref
reference calculated from setpoints
Definition: guidance_h.h:98
struct HorizontalGuidanceSetpoint sp
setpoints
Definition: guidance_h.h:97
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
Definition: guidance_h.h:78
static void guidance_h_SetMaxSpeed(float speed)
Definition: guidance_h.h:135
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:82
struct Int32Vect2 speed
with INT32_SPEED_FRAC
Definition: guidance_h.h:77
void guidance_h_read_rc(bool_t in_flight)
Definition: guidance_h.c:293
euler angles
unsigned long uint32_t
Definition: types.h:18
static void guidance_h_SetZeta(float zeta)
Definition: guidance_h.h:145
int32_t transition_percentage
Definition: guidance_h.c:81
signed long int32_t
Definition: types.h:19
void guidance_h_init(void)
Definition: guidance_h.c:168
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:95
bool_t guidance_h_set_guided_pos(float x, float y)
Set horizontal position setpoint in GUIDED mode.
Definition: guidance_h.c:621
struct Int32Vect2 pos
with INT32_POS_FRAC
Definition: guidance_h.h:76
float gh_set_zeta(float zeta)
void guidance_h_set_igain(uint32_t igain)
Definition: guidance_h.c:615
struct Int32Vect2 speed
only used if GUIDANCE_H_USE_SPEED_REF
Definition: guidance_h.h:71
bool_t guidance_h_set_guided_heading(float heading)
Set heading setpoint in GUIDED mode.
Definition: guidance_h.c:631
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:140