Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
gvf_common.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Alfredo Gonzalez Calvin <alfredgo@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
21#include "gvf_common.h"
22
23// Get MODULE_H from loaded modules
24#include "generated/modules.h"
25
31
32// State
34
38{
39
42
43 #if defined(FIXEDWING_FIRMWARE)
48
49 #elif defined(ROVER_FIRMWARE) || defined(ROTORCRAFT_FIRMWARE)
50 // We assume that the course and psi
51 // of the rover (steering wheel) are the same
55 #endif
56}
57
58void gvf_low_level_control_2D(float omega)
59{
60
61 #if defined(FIXEDWING_FIRMWARE)
63
64 // Coordinated turn
67
69
73 }
74 #endif
75
76 gvf_c_ctrl.omega = omega;
77}
78
79void gvf_low_level_control_3D(float heading_rate, float climbing_rate)
80{
81 #if defined(FIXEDWING_FIRMWARE)
83 // Vertical Z coordinate
86
87 v_ctl_climb_setpoint = gvf_c_params.k_climb * climbing_rate; // Setting point for vertical speed
88
89 // Lateral XY coordinates
91
94
96 -gvf_c_params.k_roll * atanf(heading_rate * ground_speed / GVF_GRAVITY / cosf(att->theta));
97 BoundAbs(h_ctl_roll_setpoint, h_ctl_roll_max_setpoint); // Setting point for roll angle
98 }
99 #endif
100
101 gvf_low_level_control_2D(heading_rate);
102
103 (void)(climbing_rate); // Avoid unused parameter warning
104}
105
106bool gvf_nav_approaching(float wp_x, float wp_y, float from_x, float from_y, float t)
107{
108
109 #if defined(FIXEDWING_FIRMWARE)
111
112 #else // FIXEDWING & ROVER FIRMWARE
113 struct EnuCoor_f wp, from;
114
115 wp.x = wp_x;
116 wp.y = wp_y;
117 from.x = from_x;
118 from.y = from_y;
119
120 return nav.nav_approaching(&wp, &from, t);
121 #endif
122
123 // Avoid unused parameter warning
124}
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition autopilot.c:222
static float ground_speed
Definition follow_me.c:76
uint8_t v_ctl_speed_mode
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
float theta
in radians
float psi
in radians
euler angles
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition state.h:1306
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition state.h:848
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
Definition state.h:1076
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
Definition state.h:1085
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
Definition state.h:1058
#define V_CTL_MODE_AUTO_CLIMB
gvf_common_ctrl gvf_c_ctrl
Definition gvf_common.c:28
gvf_common_params gvf_c_params
Definition gvf_common.c:30
void gvf_low_level_control_2D(float omega)
Definition gvf_common.c:58
gvf_common_info gvf_c_info
Definition gvf_common.c:29
void gvf_low_level_control_3D(float heading_rate, float climbing_rate)
Definition gvf_common.c:79
gvf_common_state gvf_c_state
Definition gvf_common.c:33
void gvf_low_level_getState(void)
Definition gvf_common.c:37
bool gvf_nav_approaching(float wp_x, float wp_y, float from_x, float from_y, float t)
Definition gvf_common.c:106
#define GVF_GRAVITY
Definition gvf_common.h:54
uint16_t foo
Definition main_demo5.c:58
bool nav_approaching_xy(float x, float y, float from_x, float from_y, float approaching_time)
Decide if the UAV is approaching the current waypoint.
Definition nav.c:325
float y
in meters
float x
in meters
vector in East North Up coordinates Units: meters
struct RotorcraftNavigation nav
Definition navigation.c:51
navigation_approaching nav_approaching
Definition navigation.h:153
float h_ctl_roll_max_setpoint
float h_ctl_roll_setpoint