Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
gvf_parametric_low_level_control.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Hector Garcia de Marina <hgarciad@ucm.es>
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 
27 #include "autopilot.h"
29 #include "gvf_parametric.h"
30 
31 #if defined(FIXEDWING_FIRMWARE)
33 #include "firmwares/fixedwing/guidance/guidance_v_n.h" // gvf_parametric is only compatible with the new pprz controller!
34 #endif
35 
36 #if defined(FIXEDWING_FIRMWARE)
37 #define USED_IN_FIXEDWING_ONLY
38 #else
39 #define USED_IN_FIXEDWING_ONLY UNUSED
40 #endif
41 
43 {
44 #if defined(FIXEDWING_FIRMWARE)
46  // Lateral XY coordinates
48 
49  struct FloatEulers *att = stateGetNedToBodyEulers_f();
51 
53  -gvf_parametric_control.k_roll * atanf(heading_rate * ground_speed / GVF_PARAMETRIC_GRAVITY / cosf(att->theta));
54  BoundAbs(h_ctl_roll_setpoint, h_ctl_roll_max_setpoint); // Setting point for roll angle
55  }
56 // Allow for rover operation
57 #elif defined(ROVER_FIRMWARE)
58 #else
59 #error gvf_parametric does not support your firmware yet
60 #endif
61 }
62 
64 {
65 #if defined(FIXEDWING_FIRMWARE)
67  // Vertical Z coordinate
70 
71  v_ctl_climb_setpoint = gvf_parametric_control.k_climb * climbing_rate; // Setting point for vertical speed
72 
73  // Lateral XY coordinates
75 
76  struct FloatEulers *att = stateGetNedToBodyEulers_f();
78 
80  -gvf_parametric_control.k_roll * atanf(heading_rate * ground_speed / GVF_PARAMETRIC_GRAVITY / cosf(att->theta));
81  BoundAbs(h_ctl_roll_setpoint, h_ctl_roll_max_setpoint); // Setting point for roll angle
82  }
83 // Allow for rover operation
84 #elif defined(ROVER_FIRMWARE)
85 #else
86 #error gvf_parametric does not support your firmware yet
87 #endif
88 }
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition: autopilot.c:217
Core autopilot interface common to all firmwares.
static float ground_speed
Definition: follow_me.c:76
uint8_t v_ctl_speed_mode
Definition: energy_ctrl.c:135
float v_ctl_climb_setpoint
Definition: energy_ctrl.c:98
uint8_t v_ctl_mode
Definition: energy_ctrl.c:74
#define V_CTL_SPEED_THROTTLE
Definition: energy_ctrl.h:36
uint8_t lateral_mode
#define LATERAL_MODE_ROLL
#define AP_MODE_AUTO2
Fixed wing horizontal control.
float theta
in radians
euler angles
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1143
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
Definition: state.h:935
#define V_CTL_MODE_AUTO_CLIMB
"New" vertical control for fixed wing vehicles.
gvf_parametric_con gvf_parametric_control
Guiding vector field algorithm for 2D and 3D parametric trajectories.
#define GVF_PARAMETRIC_GRAVITY
void gvf_parametric_low_level_control_3D(float heading_rate USED_IN_FIXEDWING_ONLY, float climbing_rate USED_IN_FIXEDWING_ONLY)
#define USED_IN_FIXEDWING_ONLY
void gvf_parametric_low_level_control_2D(float heading_rate USED_IN_FIXEDWING_ONLY)
Firmware dependent file for the guiding vector field algorithm for 2D and 3D parametric trajectories.
float h_ctl_roll_max_setpoint
float h_ctl_roll_setpoint