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_param_traj.c
Go to the documentation of this file.
1/*
2 * This file is part of paparazzi.
3 *
4 * paparazzi is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * paparazzi is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with paparazzi; see the file COPYING. If not, write to
16 * the Free Software Foundation, 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 */
20
21#include "gvf_param_traj.h"
22
23// Trajectory
25
29 float *f1, float *f2, float *f1d, float *f2d, float *f1dd, float *f2dd,
30 float wb)
31{
39
40 // Parametric equations of the trajectory and the partial derivatives w.r.t. 'w'
41 float nrf1 = cosf(wb*w1)*(r*cosf(wb*w2) + ratio);
42 float nrf2 = sinf(wb*w1)*(r*cosf(wb*w2) + ratio);
43
44 float nrf1d = -w1*sinf(wb*w1)*(r*cosf(wb*w2) + ratio) - cosf(wb*w1)*r*w2*sinf(wb*w2);
45 float nrf2d = w1*cosf(wb*w1)*(r*cosf(wb*w2) + ratio) - sinf(wb*w1)*r*w2*sinf(wb*w2);
46
47 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);
48 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);
49
52
55
58}
59
61 float *f1, float *f2, float *f3, float *f1d, float *f2d, float *f3d, float *f1dd, float *f2dd, float *f3dd,
62 float wb)
63{
70
71 // Parametric equations of the trajectory and the partial derivatives w.r.t. 'w'
72 *f1 = r * cosf(wb) + xo;
73 *f2 = r * sinf(wb) + yo;
74 *f3 = 0.5 * (zh + zl + (zl - zh) * sinf(alpha_rad - wb));
75
76 *f1d = -r * sinf(wb);
77 *f2d = r * cosf(wb);
78 *f3d = -0.5 * (zl - zh) * cosf(alpha_rad - wb);
79
80 *f1dd = -r * cosf(wb);
81 *f2dd = -r * sinf(wb);
82 *f3dd = -0.5 * (zl - zh) * sinf(alpha_rad - wb);
83}
84
86 float *f1, float *f2, float *f3, float *f1d, float *f2d, float *f3d, float *f1dd, float *f2dd, float *f3dd,
87 float wb)
88{
102
103 // Parametric equations of the trajectory and the partial derivatives w.r.t. 'w'
104
105 float nrf1 = cx*cosf(wx*wb + deltax_rad);
106 float nrf2 = cy*cosf(wy*wb + deltay_rad);
107
110 *f3 = cz*cosf(wz*wb + deltaz_rad) + zo;
111
112 float nrf1d = -wx*cx*sinf(wx*wb + deltax_rad);
113 float nrf2d = -wy*cy*sinf(wy*wb + deltay_rad);
114
117 *f3d = -wz*cz*sinf(wz*wb + deltaz_rad);
118
119 float nrf1dd = -wx*wx*cx*cosf(wx*wb + deltax_rad);
120 float nrf2dd = -wy*wy*cy*cosf(wy*wb + deltay_rad);
121
124 *f3dd = -wz*wz*cz*cosf(wz*wb + deltaz_rad);
125}
126
127// BEZIER
128
130 bezier_t *bezier, float *f1, float *f2, float *f1d, float *f2d, float *f1dd, float *f2dd,
131 float w)
132{
133 // How can we select in which bezier curve are we? Check w. spline zero: 0 <= t <= 1, spline ones: 1 <= t <= 2;
134 float t = w;
135 int n_seg = floorl(t);
136 float tt = t - n_seg;
137 if (n_seg < 0) {
138 n_seg = 0; // w could be < 0 in that case go to first point of first segment
139 tt = 0;
140 }
141 // Evalute the corresponding bezier curve
142 float p0x = bezier[n_seg].p0[0]; float p0y = bezier[n_seg].p0[1];
143 float p1x = bezier[n_seg].p1[0]; float p1y = bezier[n_seg].p1[1];
144 float p2x = bezier[n_seg].p2[0]; float p2y = bezier[n_seg].p2[1];
145 float p3x = bezier[n_seg].p3[0]; float p3y = bezier[n_seg].p3[1];
146
147 // Bézier curves
148
149 // Curve (x,y)
150 *f1 = (1 - tt) * (1 - tt) * (1 - tt) * p0x + 3 * (1 - tt) * (1 - tt) * tt * p1x + 3 *
151 (1 - tt) * tt * tt * p2x + tt * tt * tt * p3x;
152 *f2 = (1 - tt) * (1 - tt) * (1 - tt) * p0y + 3 * (1 - tt) * (1 - tt) * tt * p1y + 3 *
153 (1 - tt) * tt * tt * p2y + tt * tt * tt * p3y;
154
155 // First derivative
156 *f1d = 3 * (1 - tt) * (1 - tt) * (p1x - p0x) + 6 * (1 - tt) * tt * (p2x - p1x) + 3 * tt * tt * (p3x - p2x);
157 *f2d = 3 * (1 - tt) * (1 - tt) * (p1y - p0y) + 6 * (1 - tt) * tt * (p2y - p1y) + 3 * tt * tt * (p3y - p2y);
158
159 // Second derivative
160 *f1dd = 6 * (1 - tt) * (p2x - 2 * p1x + p0x) + 6 * tt * (p3x - 2 * p2x + p1x);
161 *f2dd = 6 * (1 - tt) * (p2y - 2 * p1y + p0y) + 6 * tt * (p3y - 2 * p2y + p1y);
162}
void gvf_parametric_3d_ellipse_info(float *f1, float *f2, float *f3, float *f1d, float *f2d, float *f3d, float *f1dd, float *f2dd, float *f3dd, float wb)
void gvf_parametric_3d_lissajous_info(float *f1, float *f2, float *f3, float *f1d, float *f2d, float *f3d, float *f1dd, float *f2dd, float *f3dd, float wb)
void gvf_parametric_2d_trefoil_info(float *f1, float *f2, float *f1d, float *f2d, float *f1dd, float *f2dd, float wb)
gvf_parametric_tra gvf_parametric_trajectory
void gvf_parametric_2d_bezier_splines_info(bezier_t *bezier, float *f1, float *f2, float *f1d, float *f2d, float *f1dd, float *f2dd, float w)
@ NONE_PARAMETRIC
uint16_t foo
Definition main_demo5.c:58