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_flower.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008-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
29
31#include "state.h"
32#include "autopilot.h"
33#include "generated/flight_plan.h"
34
35#if USE_MISSION
37
38static bool nav_flower_mission(uint8_t nb, float *params, enum MissionRunFlag flag)
39{
40 if (nb != 2) {
41 return false; // wrong number of parameters
42 }
43 if (flag == MissionInit) {
44 uint8_t center = (uint8_t)(params[0]);
45 uint8_t edge = (uint8_t)(params[1]);
46 nav_flower_setup(center, edge);
47 }
48 return nav_flower_run();
49}
50#endif
51
52
54{
55#if USE_MISSION
57#endif
58}
59
60/************** Flower Navigation **********************************************/
61
69static float CircleX;
70static float CircleY;
71static float Fly2X;
72static float Fly2Y;
73static float FlyFromX;
74static float FlyFromY;
75static float TransCurrentX;
76static float TransCurrentY;
77static float EdgeCurrentX;
78static float EdgeCurrentY;
79static float DistanceFromCenter;
80static float FlowerTheta;
81static float Flowerradius;
84
114
116{
120
121 bool InCircle = true;
122 float CircleTheta;
123
125 InCircle = false;
126 }
127
128 NavVerticalAutoThrottleMode(0); /* No pitch */
130
131 switch (CFlowerStatus) {
132 case Outside:
134 if (InCircle) {
142 }
143 break;
144 case FlowerLine:
146 if (!InCircle) {
152 }
153 break;
154 case Circle:
156 if (InCircle) {
162 } else {
164 }
171 }
172 break;
173
174 default:
175 break;
176 }
177 return true;
178}
Core autopilot interface common to all firmwares.
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition common_nav.c:44
#define WaypointX(_wp)
Definition common_nav.h:45
#define WaypointY(_wp)
Definition common_nav.h:46
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition state.h:848
uint16_t foo
Definition main_demo5.c:58
bool mission_register(mission_custom_cb cb, char *type)
Register a new navigation or action callback function.
mission planner library
MissionRunFlag
@ MissionInit
first exec
void nav_init_stage(void)
needs to be implemented by fixedwing and rotorcraft seperately
Definition nav.c:92
float nav_radius
Definition nav.c:56
void nav_route_xy(float last_wp_x, float last_wp_y, float wp_x, float wp_y)
Computes the carrot position along the desired segment.
Definition nav.c:382
void nav_circle_XY(float x, float y, float radius)
Navigates around (x, y).
Definition nav.c:108
Fixedwing Navigation library.
#define NavVerticalAltitudeMode(_alt, _pre_climb)
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
Definition nav.h:191
#define NavVerticalAutoThrottleMode(_pitch)
Set the climb control to auto-throttle with the specified pitch pre-command.
Definition nav.h:177
void nav_flower_setup(uint8_t CenterWP, uint8_t EdgeWP)
Definition nav_flower.c:85
static float FlowerTheta
Definition nav_flower.c:80
static float TransCurrentY
Definition nav_flower.c:76
static float Fly2X
Definition nav_flower.c:71
static float EdgeCurrentY
Definition nav_flower.c:78
static enum FlowerStatus CFlowerStatus
Definition nav_flower.c:68
static float TransCurrentX
Definition nav_flower.c:75
static float FlyFromX
Definition nav_flower.c:73
static float CircleX
Definition nav_flower.c:69
static uint8_t Edge
Definition nav_flower.c:83
static float CircleY
Definition nav_flower.c:70
static float DistanceFromCenter
Definition nav_flower.c:79
static uint8_t Center
Definition nav_flower.c:82
bool nav_flower_run(void)
Definition nav_flower.c:115
static float Flowerradius
Definition nav_flower.c:81
static float EdgeCurrentX
Definition nav_flower.c:77
FlowerStatus
Makes a flower pattern.
Definition nav_flower.c:67
@ FlowerLine
Definition nav_flower.c:67
@ Outside
Definition nav_flower.c:67
@ Circle
Definition nav_flower.c:67
void nav_flower_init(void)
Definition nav_flower.c:53
static float FlyFromY
Definition nav_flower.c:74
static float Fly2Y
Definition nav_flower.c:72
float y
in meters
float x
in meters
API to get/set the generic vehicle states.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.