Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
guidance_pid.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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_PID_H
27 #define GUIDANCE_PID_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include "std.h"
34 #include "math/pprz_algebra_int.h"
37 
38 struct GuidancePID {
39  // horizontal gains
45  // vertical gains
49  // outputs
50  struct Int32Vect2 cmd_earth; // Horizontal guidance command (north/east with #INT32_ANGLE_FRAC)
51  int32_t cmd_thrust; // Vertical guidance command (in pprz_t)
52  // options
53  bool approx_force_by_thrust; // Correction of force commands from thrust
54  bool adapt_throttle_enabled; // Use adaptive throttle command estimation
55 };
56 
59 extern struct GuidancePID guidance_pid;
60 
61 extern void guidance_pid_init(void);
62 extern void guidance_pid_h_enter(void);
63 extern void guidance_pid_v_enter(void);
64 extern struct StabilizationSetpoint guidance_pid_h_run_pos(bool in_flight, struct HorizontalGuidance *gh);
65 extern struct StabilizationSetpoint guidance_pid_h_run_speed(bool in_flight, struct HorizontalGuidance *gh);
66 extern struct StabilizationSetpoint guidance_pid_h_run_accel(bool in_flight, struct HorizontalGuidance *gh);
67 extern int32_t guidance_pid_v_run_pos(bool in_flight, struct VerticalGuidance *gv);
68 extern int32_t guidance_pid_v_run_speed(bool in_flight, struct VerticalGuidance *gv);
69 extern int32_t guidance_pid_v_run_accel(bool in_flight, struct VerticalGuidance *gv);
70 
71 extern void guidance_pid_set_h_igain(uint32_t igain);
72 extern void guidance_pid_set_v_igain(uint32_t igain);
73 
78 extern const struct Int32Vect2 *guidance_pid_get_h_pos_err(void);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* GUIDANCE_PID_H */
void guidance_pid_set_h_igain(uint32_t igain)
settings handler
Definition: guidance_pid.c:402
int32_t v_ki
Definition: guidance_pid.h:48
void guidance_pid_init(void)
Definition: guidance_pid.c:184
struct StabilizationSetpoint guidance_pid_h_run_pos(bool in_flight, struct HorizontalGuidance *gh)
Definition: guidance_pid.c:278
int32_t cmd_thrust
Definition: guidance_pid.h:51
int32_t guidance_pid_v_run_accel(bool in_flight, struct VerticalGuidance *gv)
struct StabilizationSetpoint guidance_pid_h_run_speed(bool in_flight, struct HorizontalGuidance *gh)
Definition: guidance_pid.c:294
bool approx_force_by_thrust
Definition: guidance_pid.h:53
void guidance_pid_set_v_igain(uint32_t igain)
Definition: guidance_pid.c:408
int32_t kv
Definition: guidance_pid.h:43
bool adapt_throttle_enabled
Definition: guidance_pid.h:54
struct GuidancePID guidance_pid
Guidance PID structyre.
Definition: guidance_pid.c:124
int32_t v_kp
Definition: guidance_pid.h:46
int32_t ki
Definition: guidance_pid.h:42
struct Int32Vect2 cmd_earth
Definition: guidance_pid.h:50
struct StabilizationSetpoint guidance_pid_h_run_accel(bool in_flight, struct HorizontalGuidance *gh)
int32_t kd
Definition: guidance_pid.h:41
int32_t guidance_pid_v_run_pos(bool in_flight, struct VerticalGuidance *gv)
Definition: guidance_pid.c:371
int32_t guidance_pid_v_run_speed(bool in_flight, struct VerticalGuidance *gv)
Definition: guidance_pid.c:376
int32_t ka
Definition: guidance_pid.h:44
const struct Int32Vect2 * guidance_pid_get_h_pos_err(void)
Gets the position error.
Definition: guidance_pid.c:415
void guidance_pid_v_enter(void)
Definition: guidance_pid.c:393
void guidance_pid_h_enter(void)
Definition: guidance_pid.c:387
int32_t kp
Definition: guidance_pid.h:40
int32_t v_kd
Definition: guidance_pid.h:47
Paparazzi fixed point algebra.
Horizontal guidance for rotorcrafts.
Vertical guidance for rotorcrafts.
Stabilization setpoint.
Definition: stabilization.h:42
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78