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_launcher.c
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2016, Michal Podhradsky
4 *
5 * This file is part of paparazzi.
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, write to
19 * the Free Software Foundation, 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 *
22 */
23
47#include "generated/airframe.h"
48#include "state.h"
50#include "autopilot.h"
53
54#ifndef LAUNCHER_TAKEOFF_PITCH //> desired takeoff pitch [rad]
55#define LAUNCHER_TAKEOFF_PITCH 0.23
56#endif
57
58#ifndef LAUNCHER_TAKEOFF_HEIGHT //> desired height AGL [m]
59#define LAUNCHER_TAKEOFF_HEIGHT 80
60#endif
61
62#ifndef LAUNCHER_TAKEOFF_DISTANCE //> minimal distance from the takeoff point [m]
63#define LAUNCHER_TAKEOFF_DISTANCE 30
64#endif
65
66#ifndef LAUNCHER_TAKEOFF_MIN_SPEED_LINE //> minimal takeoff ground speed [m/s] to switch into line following
67#define LAUNCHER_TAKEOFF_MIN_SPEED_LINE 5
68#endif
69
70#ifndef LAUNCHER_TAKEOFF_MIN_SPEED_CIRCLE //> mininmal takeoff ground speed [m/s] to switch into circle climb
71#define LAUNCHER_TAKEOFF_MIN_SPEED_CIRCLE 8
72#endif
73
74#ifndef LAUNCHER_TAKEOFF_CIRCLE_ALT //> desired circle AGL [m]
75#define LAUNCHER_TAKEOFF_CIRCLE_ALT 200
76#endif
77
78#ifndef LAUNCHER_TAKEOFF_CIRCLE_RADIUS //> desired circle radius [m]
79#define LAUNCHER_TAKEOFF_CIRCLE_RADIUS 200
80#endif
81
82#ifndef LAUNCHER_TAKEOFF_MAX_CIRCLE_DISTANCE //> max distance from the takeoff point [m] before the plane circles up
83#define LAUNCHER_TAKEOFF_MAX_CIRCLE_DISTANCE 800
84#endif
85
86#ifndef LAUNCHER_TAKEOFF_HEIGHT_THRESHOLD //> height threshold [m] before switching modes
87#define LAUNCHER_TAKEOFF_HEIGHT_THRESHOLD 10
88#endif
89
90struct Point2D
91{
92 float x;
93 float y;
94};
100static float launch_x;
101static float launch_y;
102static float launch_alt;
103static float launch_pitch;
104static float launch_time;
105static struct Point2D launch_circle;
106static float launch_circle_alt;
107
108static float launch_line_x;
109static float launch_line_y;
110
124
126{
127 //Find distance from laucher
131 if (launch_dist <= 0.01) {
132 launch_dist = 0.01;
133 }
134
135 switch (CLaunch_Status) {
136 case L_Pitch_Nav:
137 //Follow Launch Line
141 NavAttitude(0);
142
143
144 //If the plane has been launched and has traveled for more than a specified distance, switch to line nav
150 }
151 }
152
153 break;
154 case L_Line_Nav:
155 //Follow Launch Line
160
161 //If the aircraft is above a specific alt, greater than a specific speed or too far away, circle up
162 if (((stateGetPositionUtm_f()->alt
168
169 //Find position of circle
170 float x_1 = dist_x / launch_dist;
171 float y_1 = dist_y / launch_dist;
172
177 }
178 break;
179 case L_CircleUp:
184
185 if (stateGetPositionUtm_f()->alt
188 return FALSE;
189 }
190 break;
191 default:
192 break;
193 }
194 return TRUE;
195}
196
Core autopilot interface common to all firmwares.
Fixed wing horizontal control.
float theta
in radians
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition state.h:1306
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
Definition state.h:821
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition state.h:848
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
Definition state.h:1076
uint16_t foo
Definition main_demo5.c:58
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 NavVerticalThrottleMode(_throttle)
Set the vertical mode to fixed throttle with the specified setpoint.
Definition nav.h:204
#define NavAttitude(_roll)
Definition nav.h:214
#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_launcher_setup(void)
static float launch_line_y
static float launch_circle_alt
#define LAUNCHER_TAKEOFF_CIRCLE_RADIUS
#define LAUNCHER_TAKEOFF_CIRCLE_ALT
#define LAUNCHER_TAKEOFF_MIN_SPEED_CIRCLE
static float launch_y
static enum Launch_Status CLaunch_Status
#define LAUNCHER_TAKEOFF_HEIGHT_THRESHOLD
#define LAUNCHER_TAKEOFF_PITCH
static float launch_time
static float launch_pitch
#define LAUNCHER_TAKEOFF_DISTANCE
Launch_Status
@ L_CircleUp
@ L_Pitch_Nav
@ L_Line_Nav
@ L_Finished
static float launch_x
#define LAUNCHER_TAKEOFF_HEIGHT
static struct Point2D launch_circle
bool nav_launcher_run(void)
static float launch_line_x
#define LAUNCHER_TAKEOFF_MAX_CIRCLE_DISTANCE
static float launch_alt
#define LAUNCHER_TAKEOFF_MIN_SPEED_LINE
Pneumatic launcher system See video of the system: https://www.youtube.com/watch?v=qc1uwH-8Dbw Launch...
float x
float y
#define MAX_PPRZ
Definition paparazzi.h:8
float y
in meters
float x
in meters
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
API to get/set the generic vehicle states.
#define TRUE
Definition std.h:4
#define FALSE
Definition std.h:5