Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nav_spiral.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2013 The Paparazzi Team
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 
33 #include "modules/nav/nav_spiral.h"
34 
36 #include "state.h"
37 #include "autopilot.h"
38 #include "generated/flight_plan.h"
39 
40 #ifdef DIGITAL_CAM
41 #include "modules/digital_cam/dc.h"
42 #endif
43 
44 #ifndef NAV_SPIRAL_MIN_CIRCLE_RADIUS
45 #define NAV_SPIRAL_MIN_CIRCLE_RADIUS 60
46 #endif
47 
49 
50 bool_t nav_spiral_setup(uint8_t center_wp, uint8_t edge_wp, float radius_start, float radius_inc, float segments)
51 {
52  VECT2_COPY(nav_spiral.center, waypoints[center_wp]); // center of the helix
53  nav_spiral.center.z = waypoints[center_wp].a;
54  nav_spiral.radius_start = radius_start; // start radius of the helix
59  }
60  nav_spiral.radius_increment = radius_inc; // multiplier for increasing the spiral
61 
62  struct FloatVect2 edge;
63  VECT2_DIFF(edge, waypoints[edge_wp], nav_spiral.center);
64 
66 
67  // get a copy of the current position
68  struct EnuCoor_f pos_enu = *stateGetPositionEnu_f();
69 
72 
74 
75  // nav_spiral.alpha_limit denotes angle, where the radius will be increased
77  //current position
80 
83  }
84  return FALSE;
85 }
86 
87 bool_t nav_spiral_run(void)
88 {
89  struct EnuCoor_f pos_enu = *stateGetPositionEnu_f();
90 
93 
94  float DistanceStartEstim;
95  float CircleAlpha;
96 
97  switch (nav_spiral.status) {
98  case SpiralOutside:
99  //flys until center of the helix is reached an start helix
101  // center reached?
103  // nadir image
104 #ifdef DIGITAL_CAM
106 #endif
108  }
109  break;
110  case SpiralStartCircle:
111  // Starts helix
112  // storage of current coordinates
113  // calculation needed, State switch to SpiralCircle
118  // Start helix
119 #ifdef DIGITAL_CAM
121 #endif
122  }
123  break;
124  case SpiralCircle: {
126  // Trigonometrische Berechnung des bereits geflogenen Winkels alpha
127  // equation:
128  // alpha = 2 * asin ( |Starting position angular - current positon| / (2* nav_spiral.radius_start)
129  // if alphamax already reached, increase radius.
130 
131  //DistanceStartEstim = |Starting position angular - current positon|
132  struct FloatVect2 pos_diff;
133  VECT2_DIFF(pos_diff, nav_spiral.last_circle, pos_enu);
134  DistanceStartEstim = float_vect2_norm(&pos_diff);
135  CircleAlpha = (2.0 * asin(DistanceStartEstim / (2 * nav_spiral.radius_start)));
136  if (CircleAlpha >= nav_spiral.alpha_limit) {
139  }
140  break;
141  }
142  case SpiralInc:
143  // increasing circle radius as long as it is smaller than max helix radius
146 #ifdef DIGITAL_CAM
147  if (dc_cam_tracing) {
148  // calculating Cam angle for camera alignment
151  }
152 #endif
153  } else {
155 #ifdef DIGITAL_CAM
156  // Stopps DC
157  dc_stop();
158 #endif
159  }
161  break;
162  default:
163  break;
164  }
165 
166  NavVerticalAutoThrottleMode(0.); /* No pitch */
167  NavVerticalAltitudeMode(nav_spiral.center.z, 0.); /* No preclimb */
168 
169  return TRUE;
170 }
float alt
in meters above WGS84 reference ellipsoid
vector in East North Up coordinates Units: meters
#define VECT2_COPY(_a, _b)
Definition: pprz_algebra.h:67
#define VECT2_DIFF(_c, _a, _b)
Definition: pprz_algebra.h:91
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition: state.h:702
#define FLOAT_VECT3_NORM(_v)
#define FALSE
Definition: std.h:5
#define TRUE
Definition: std.h:4
Definition: dc.h:100
Standard Digital Camera Control Interface.
static float float_vect2_norm(struct FloatVect2 *v)
float x
in meters
void dc_send_command(uint8_t cmd)
Send Command To Camera.
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
Definition: state.h:675
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
uint8_t dc_stop(void)
Stop dc control.
Definition: dc.c:223
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: common_nav.c:38
float a
Definition: common_nav.h:42
uint8_t dc_cam_tracing
Definition: dc.c:64
#define dc_Circle(interval)
Definition: dc.h:188
float y
in meters
float dc_cam_angle
camera angle
Definition: dc.c:65