Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
gvf_parametric_2d_trefoil.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 
29 #include "modules/nav/common_nav.h"
32 
34 #ifndef GVF_PARAMETRIC_2D_TREFOIL_KX
35 #define GVF_PARAMETRIC_2D_TREFOIL_KX 0.001
36 #endif
37 
39 #ifndef GVF_PARAMETRIC_2D_TREFOIL_KY
40 #define GVF_PARAMETRIC_2D_TREFOIL_KY 0.001
41 #endif
42 
44 #ifndef GVF_PARAMETRIC_2D_TREFOIL_W1
45 #define GVF_PARAMETRIC_2D_TREFOIL_W1 0.02
46 #endif
47 
49 #ifndef GVF_PARAMETRIC_2D_TREFOIL_W2
50 #define GVF_PARAMETRIC_2D_TREFOIL_W2 0.03
51 #endif
52 
54 #ifndef GVF_PARAMETRIC_2D_TREFOIL_RATIO
55 #define GVF_PARAMETRIC_2D_TREFOIL_RATIO 160
56 #endif
57 
59 #ifndef GVF_PARAMETRIC_2D_TREFOIL_R
60 #define GVF_PARAMETRIC_2D_TREFOIL_R 80
61 #endif
62 
64 #ifndef GVF_PARAMETRIC_2D_TREFOIL_ALPHA
65 #define GVF_PARAMETRIC_2D_TREFOIL_ALPHA 0
66 #endif
67 
69 
70 void gvf_parametric_2d_trefoil_info(float *f1, float *f2, float *f1d, float *f2d, float *f1dd, float *f2dd)
71 {
76  float ratio = gvf_parametric_trajectory.p_parametric[4];
78  float alpha_rad = gvf_parametric_trajectory.p_parametric[6]*M_PI/180;
79 
80  float w = gvf_parametric_control.w;
82 
83  // Parametric equations of the trajectory and the partial derivatives w.r.t. 'w'
84  float nrf1 = cosf(wb*w1)*(r*cosf(wb*w2) + ratio);
85  float nrf2 = sinf(wb*w1)*(r*cosf(wb*w2) + ratio);
86 
87  float nrf1d = -w1*sinf(wb*w1)*(r*cosf(wb*w2) + ratio) - cosf(wb*w1)*r*w2*sinf(wb*w2);
88  float nrf2d = w1*cosf(wb*w1)*(r*cosf(wb*w2) + ratio) - sinf(wb*w1)*r*w2*sinf(wb*w2);
89 
90  float nrf1dd = -w1*w1*cosf(wb*w1)*(r*cosf(wb*w2) + ratio) + w1*sinf(wb*w1)*r*w2*sinf(wb*w2) + w1*sinf(wb*w1)*r*w2*sinf(wb*w2) - cosf(wb*w1)*r*w2*w2*cosf(wb*w2);
91  float nrf2dd = -w1*w1*sinf(wb*w1)*(r*cosf(wb*w2) + ratio) - w1*cosf(wb*w1)*r*w2*sinf(wb*w2) - w1*cosf(wb*w1)*r*w2*sinf(wb*w2) - sinf(wb*w1)*r*w2*w2*cosf(wb*w2);
92 
93  *f1 = cosf(alpha_rad)*nrf1 - sinf(alpha_rad)*nrf2 + xo;
94  *f2 = sinf(alpha_rad)*nrf1 + cosf(alpha_rad)*nrf2 + yo;
95 
96  *f1d = cosf(alpha_rad)*nrf1d - sinf(alpha_rad)*nrf2d;
97  *f2d = sinf(alpha_rad)*nrf1d + cosf(alpha_rad)*nrf2d;
98 
99  *f1dd = cosf(alpha_rad)*nrf1dd - sinf(alpha_rad)*nrf2dd;
100  *f2dd = sinf(alpha_rad)*nrf1dd + cosf(alpha_rad)*nrf2dd;
101 }
102 
gvf_parametric_con gvf_parametric_control
gvf_parametric_tra gvf_parametric_trajectory
Guiding vector field algorithm for 2D and 3D parametric trajectories.
#define GVF_PARAMETRIC_2D_TREFOIL_ALPHA
void gvf_parametric_2d_trefoil_info(float *f1, float *f2, float *f1d, float *f2d, float *f1dd, float *f2dd)
#define GVF_PARAMETRIC_2D_TREFOIL_KY
gvf_par_2d_tre_par gvf_parametric_2d_trefoil_par
#define GVF_PARAMETRIC_2D_TREFOIL_R
#define GVF_PARAMETRIC_2D_TREFOIL_KX
#define GVF_PARAMETRIC_2D_TREFOIL_W2
#define GVF_PARAMETRIC_2D_TREFOIL_RATIO
#define GVF_PARAMETRIC_2D_TREFOIL_W1
Guiding vector field algorithm for 2D and 3D complex trajectories.