Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nav_poles.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2015 ENAC
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 
26 #include "modules/nav/nav_poles.h"
28 
30 float nav_poles_time = 0.;
32 
33 #define SAFETY_MARGIN 0.7
34 
38  uint8_t wp1c, uint8_t wp2c,
39  float radius)
40 {
41  float x = WaypointX(wp2) - WaypointX(wp1);
42  float y = WaypointY(wp2) - WaypointY(wp1);
43  float d = sqrt(x * x + y * y);
44 
45  /* Unit vector from wp1 to wp2 */
46  x /= d;
47  y /= d;
48 
49  WaypointX(wp2c) = WaypointX(wp2) - (x * SAFETY_MARGIN + y) * radius;
50  WaypointY(wp2c) = WaypointY(wp2) - (y * SAFETY_MARGIN - x) * radius;
51 
52  WaypointX(wp1c) = WaypointX(wp1) + (x * SAFETY_MARGIN - y) * radius;
53  WaypointY(wp1c) = WaypointY(wp1) + (y * SAFETY_MARGIN + x) * radius;
54 
55  return false;
56 }
57 
#define WaypointX(_wp)
Definition: common_nav.h:45
#define WaypointY(_wp)
Definition: common_nav.h:46
unsigned char uint8_t
Definition: types.h:14
signed char int8_t
Definition: types.h:15