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
nav_sin.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Hector Garcia de Marina
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, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 *
21 */
22
23#include "nav_sin.h"
24
25#include "generated/airframe.h"
27
29#ifndef GVF_SIN_KE
30#define GVF_SIN_KE 1
31#endif
32
34#ifndef GVF_SIN_KN
35#define GVF_SIN_KN 1
36#endif
37
39#ifndef GVF_SIN_ALPHA
40#define GVF_SIN_ALPHA 0
41#endif
42
44#ifndef GVF_SIN_W
45#define GVF_SIN_W 0
46#endif
47
49#ifndef GVF_SIN_OFF
50#define GVF_SIN_OFF 0
51#endif
52
54#ifndef GVF_SIN_A
55#define GVF_SIN_A 0
56#endif
57
61
62// Param array lenght
63static int gvf_p_len_wps = 0;
64
67// SINUSOIDAL (if w = 0 and off = 0, then we just have the straight line case)
68
69bool nav_gvf_sin_XY_alpha(float a, float b, float alpha, float w, float off, float A)
70{
71 float e;
72 struct gvf_grad grad_line;
73 struct gvf_Hess Hess_line;
74
76 gvf_trajectory.p[0] = a;
77 gvf_trajectory.p[1] = b;
79 gvf_trajectory.p[3] = w;
80 gvf_trajectory.p[4] = off;
81 gvf_trajectory.p[5] = A;
83 gvf_p_len_wps = 0;
84
88
90
91 return true;
92}
93
94bool nav_gvf_sin_wp1_wp2(uint8_t wp1, uint8_t wp2, float w, float off, float A)
95{
96 w = 2 * M_PI * w;
97
98 gvf_trajectory.p[6] = wp1;
99 gvf_trajectory.p[7] = wp2;
100 gvf_p_len_wps = 2;
101
102 float x1 = WaypointX(wp1);
103 float y1 = WaypointY(wp1);
104 float x2 = WaypointX(wp2);
105 float y2 = WaypointY(wp2);
106
107 float zx = x1 - x2;
108 float zy = y1 - y2;
109
110 float alpha = atanf(zy / zx);
111
112 nav_gvf_sin_XY_alpha(x1, y1, alpha, w, off, A);
113
114 return true;
115}
116
117bool nav_gvf_sin_wp_alpha(uint8_t wp, float alpha, float w, float off, float A)
118{
119 w = 2 * M_PI * w;
121
122 gvf_trajectory.p[6] = wp;
123 gvf_p_len_wps = 1;
124
125 float x = WaypointX(wp);
126 float y = WaypointY(wp);
127
128 nav_gvf_sin_XY_alpha(x, y, alpha, w, off, A);
129
130 return true;
131}
#define WaypointX(_wp)
Definition common_nav.h:45
#define WaypointY(_wp)
Definition common_nav.h:46
#define A
gvf_con gvf_control
Definition gvf.c:30
void gvf_control_2D(float ke, float kn, float e, struct gvf_grad *grad, struct gvf_Hess *hess)
Definition gvf.c:100
Guidance algorithm based on vector fields.
float ke
Definition gvf.h:54
float error
Definition gvf.h:56
void gvf_sin_info(float *phi, struct gvf_grad *grad, struct gvf_Hess *hess)
Definition gvf_traj.c:86
gvf_tra gvf_trajectory
Definition gvf_traj.c:24
enum trajectories type
Definition gvf_traj.h:34
float p[16]
Definition gvf_traj.h:35
int p_len
Definition gvf_traj.h:36
uint16_t foo
Definition main_demo5.c:58
#define GVF_SIN_ALPHA
Definition nav_sin.c:40
bool nav_gvf_sin_XY_alpha(float a, float b, float alpha, float w, float off, float A)
Definition nav_sin.c:69
gvf_s_par gvf_sin_par
Definition nav_sin.c:58
bool nav_gvf_sin_wp_alpha(uint8_t wp, float alpha, float w, float off, float A)
Definition nav_sin.c:117
#define GVF_SIN_A
Definition nav_sin.c:55
#define GVF_SIN_OFF
Definition nav_sin.c:50
#define GVF_SIN_KN
Definition nav_sin.c:35
bool nav_gvf_sin_wp1_wp2(uint8_t wp1, uint8_t wp2, float w, float off, float A)
Definition nav_sin.c:94
static int gvf_p_len_wps
Definition nav_sin.c:63
#define GVF_SIN_KE
Definition nav_sin.c:30
#define GVF_SIN_W
Definition nav_sin.c:45
float kn
Definition nav_sin.h:45
float ke
Definition nav_sin.h:44
float alpha
Definition textons.c:133
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
float b
Definition wedgebug.c:202