28 #include <Eigen/Dense>
36 #include "../gvf_common.h"
62 #if PERIODIC_TELEMETRY
81 static void send_circle_parametric(
struct transport_tx *trans,
struct link_device *
dev)
111 #if PERIODIC_TELEMETRY
138 #ifdef FIXEDWING_FIRMWARE
151 float x = pos_enu->
x;
152 float y = pos_enu->
y;
154 float phi1 = L * (
x - f1);
155 float phi2 = L * (
y - f2);
162 X(0) = L * beta * f1d - kx * phi1;
163 X(1) = L * beta * f2d - ky * phi2;
164 X(2) = L + beta * (kx * phi1 * f1d + ky * phi2 * f2d);
171 J(2, 0) = (beta * L) * (beta * f1dd + kx * f1d);
172 J(2, 1) = (beta * L) * (beta * f2dd + ky * f2d);
173 J(2, 2) = beta * beta * (kx * (phi1 * f1dd - L * f1d * f1d) + ky * (phi2 * f2dd - L * f2d * f2d));
180 Eigen::Vector3f xi_dot;
184 xi_dot << vel_enu->
x, vel_enu->
y, w_dot;
188 Eigen::Matrix<float, 2, 3> Fp;
190 Eigen::Matrix<float, 1, 2> ht;
204 Eigen::Matrix<float, 1, 3> Xt =
X.transpose();
205 Eigen::Vector3f Xh =
X /
X.norm();
206 Eigen::Matrix<float, 1, 3> Xht = Xh.transpose();
210 float aux = ht * Fp *
X;
216 gvf_c_info.
kappa = (f1d * f2dd - f1dd * f2d) / powf(f1d * f1d + f2d * f2d, 1.5);
226 #ifdef FIXEDWING_FIRMWARE
228 float f3d,
float f1dd,
float f2dd,
float f3dd)
251 float x = pos_enu->
x;
252 float y = pos_enu->
y;
253 float z = pos_enu->
z;
255 float phi1 = L * (
x - f1);
256 float phi2 = L * (
y - f2);
257 float phi3 = L * (
z - f3);
266 X(0) = -f1d * L * L * beta - kx * phi1;
267 X(1) = -f2d * L * L * beta - ky * phi2;
268 X(2) = -f3d * L * L * beta - kz * phi3;
269 X(3) = -L * L + beta * (kx * phi1 * f1d + ky * phi2 * f2d + kz * phi3 * f3d);
277 J(3, 0) = kx * f1d * beta * L;
278 J(3, 1) = ky * f2d * beta * L;
279 J(3, 2) = kz * f3d * beta * L;
280 J(0, 3) = -(beta * L) * (beta * L * f1dd - kx * f1d);
281 J(1, 3) = -(beta * L) * (beta * L * f2dd - ky * f2d);
282 J(2, 3) = -(beta * L) * (beta * L * f3dd - kz * f3d);
283 J(3, 3) = beta * beta * (kx * (phi1 * f1dd - L * f1d * f1d) + ky * (phi2 * f2dd - L * f2d * f2d)
284 + kz * (phi3 * f3dd - L * f3d * f3d));
291 Eigen::Vector4f xi_dot;
295 xi_dot << vel_enu->
x, vel_enu->
y, vel_enu->
z, w_dot;
298 Eigen::Matrix<float, 2, 4> F;
299 Eigen::Matrix<float, 2, 4> Fp;
304 Eigen::Matrix<float, 1, 2> ht;
309 F << 1.0, 0.0, 0.0, 0.0,
313 G = F.transpose() * F;
315 Gp = F.transpose() *
E * F;
317 Eigen::Matrix<float, 1, 4> Xt =
X.transpose();
318 Eigen::Vector4f Xh =
X /
X.norm();
319 Eigen::Matrix<float, 1, 4> Xht = Xh.transpose();
321 float aux = ht * Fp *
X;
351 float f1, f2, f1d, f2d, f1dd, f2dd;
372 float fx, fy, fxd, fyd, fxdd, fydd;
431 #ifdef FIXEDWING_FIRMWARE
440 if (zl < 1 || zh < 1) {
458 float f1, f2, f3, f1d, f2d, f3d, f1dd, f2dd, f3dd;
478 float zl = alt_center - delta;
479 float zh = alt_center + delta;
488 float wz,
float dx,
float dy,
float dz,
float alpha)
513 float f1, f2, f3, f1d, f2d, f3d, f1dd, f2dd, f3dd;
523 float wz,
float dx,
float dy,
float dz,
float alpha)
528 gvf_parametric_3D_lissajous_XYZ(
waypoints[wp].
x,
waypoints[wp].
y, zo, cx, cy, cz, wx, wy, wz, dx, dy, dz,
alpha);
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
Core autopilot interface common to all firmwares.
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
static float ground_speed
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
gvf_common_omega gvf_c_omega
gvf_common_params gvf_c_info
gvf_parametric_con gvf_parametric_control
bool gvf_parametric_2D_bezier_wp(uint8_t first_wp)
uint32_t gvf_parametric_splines_ctr
bool gvf_parametric_2D_trefoil_XY(float xo, float yo, float w1, float w2, float ratio, float r, float alpha)
2D TRAJECTORIES
int gvf_parametric_plen_wps
static void send_gvf_parametric(struct transport_tx *trans, struct link_device *dev)
bool gvf_parametric_2D_bezier_XY(void)
bezier_t gvf_bezier_2D[GVF_PARAMETRIC_2D_BEZIER_N_SEG]
uint32_t gvf_parametric_t0
void gvf_parametric_init(void)
gvf_parametric_tra gvf_parametric_trajectory
void gvf_parametric_control_2D(float kx, float ky, float f1, float f2, float f1d, float f2d, float f1dd, float f2dd)
bool gvf_parametric_2D_trefoil_wp(uint8_t wp, float w1, float w2, float ratio, float r, float alpha)
void gvf_parametric_set_direction(int8_t s)
Guiding vector field algorithm for 2D and 3D parametric trajectories.
void gvf_parametric_control_3D(float, float, float, float, float, float, float, float, float, float, float, float)
#define GVF_PARAMETRIC_CONTROL_KCLIMB
#define GVF_PARAMETRIC_CONTROL_L
bool gvf_parametric_3D_ellipse_XYZ(float, float, float, float, float, float)
#define GVF_PARAMETRIC_CONTROL_BETA
#define GVF_PARAMETRIC_CONTROL_KROLL
bool gvf_parametric_3D_lissajous_XYZ(float, float, float, float, float, float, float, float, float, float, float, float, float)
#define GVF_PARAMETRIC_CONTROL_KPSI
bool gvf_parametric_3D_ellipse_wp_delta(uint8_t, float, float, float, float)
bool gvf_parametric_3D_lissajous_wp_center(uint8_t, float, float, float, float, float, float, float, float, float, float, float)
enum trajectories_parametric type
bool gvf_parametric_3D_ellipse_wp(uint8_t, float, float, float, float)
void gvf_parametric_2d_bezier_splines_info(bezier_t *bezier, float *f1, float *f2, float *f1d, float *f2d, float *f1dd, float *f2dd)
gvf_par_2d_bezier_par gvf_parametric_2d_bezier_par
void create_bezier_spline(bezier_t *bezier, float *px, float *py)
#define GVF_PARAMETRIC_2D_BEZIER_N_SEG
void gvf_parametric_2d_trefoil_info(float *f1, float *f2, float *f1d, float *f2d, float *f1dd, float *f2dd)
gvf_par_2d_tre_par gvf_parametric_2d_trefoil_par
Guiding vector field algorithm for 2D and 3D complex trajectories.
void gvf_parametric_3d_ellipse_info(float *f1, float *f2, float *f3, float *f1d, float *f2d, float *f3d, float *f1dd, float *f2dd, float *f3dd)
gvf_par_3d_ell_par gvf_parametric_3d_ellipse_par
Guiding vector field algorithm for 2D and 3D complex trajectories.
gvf_par_3d_lis_par gvf_parametric_3d_lissajous_par
void gvf_parametric_3d_lissajous_info(float *f1, float *f2, float *f3, float *f1d, float *f2d, float *f3d, float *f1dd, float *f2dd, float *f3dd)
Guiding vector field algorithm for 2D and 3D complex trajectories.
void gvf_parametric_low_level_control_3D(float heading_rate USED_IN_FIXEDWING_ONLY, float climbing_rate 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.
#define HORIZONTAL_MODE_CIRCLE
vector in East North Up coordinates Units: meters
static const struct usb_device_descriptor dev
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.