|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
32 #include "generated/flight_plan.h"
38 #ifndef POLY_OSAM_DEFAULT_SIZE
39 #define POLY_OSAM_DEFAULT_SIZE 5
42 #ifndef POLY_OSAM_DEFAULT_SWEEP
43 #define POLY_OSAM_DEFAULT_SWEEP 100
47 #ifndef POLY_OSAM_ENTRY_RADIUS
48 #define POLY_OSAM_ENTRY_RADIUS 0
52 #ifndef POLY_OSAM_MIN_RADIUS
53 #define POLY_OSAM_MIN_RADIUS 30
57 #ifndef POLY_OSAM_FIRST_SWEEP_DISTANCE
58 #define POLY_OSAM_FIRST_SWEEP_DISTANCE 0
62 #ifndef POLY_OSAM_POLYGONSIZE
63 #define POLY_OSAM_POLYGONSIZE 10
66 #ifndef POLY_OSAM_USE_FULL_CIRCLE
67 #define POLY_OSAM_USE_FULL_CIRCLE TRUE
71 #ifndef POLY_OSAM_HALF_SWEEP_ENABLED
72 #define POLY_OSAM_HALF_SWEEP_ENABLED TRUE
85 if (dx == 0.0
f) { dx = 0.000000001; }
86 float ang = atan(dy / dx);
109 #define PolygonSize POLY_OSAM_POLYGONSIZE
110 #define MaxFloat 1000000000
111 #define MinFloat -1000000000
113 #ifndef LINE_START_FUNCTION
114 #define LINE_START_FUNCTION {}
116 #ifndef LINE_STOP_FUNCTION
117 #define LINE_STOP_FUNCTION {}
152 static struct Point2D EntryPoint;
156 float XIntercept1 = 0;
157 float XIntercept2 = 0;
158 float entry_distance;
163 if (PolySurveyEntryDistance == 0) {
164 entry_distance = sw / 2;
166 entry_distance = PolySurveyEntryDistance;
169 if (PolySurveyEntryRadius == 0) {
192 if (Size <= PolygonSize && Orientation >= -90 && Orientation <= 90) {
194 for (i = 0; i < Size; i++) {
200 for (i = 0; i < Size; i++) {
207 for (i = 1; i < Size; i++) {
218 for (i = 0; i < Size; i++) {
223 EntryPoint.
x = Corners[0].
x;
224 EntryPoint.
y = Corners[0].
y;
228 for (i = 1; i < Size; i++) {
229 if (Corners[i].
y >
MaxY) {
235 for (i = 0; i < Size; i++) {
237 if (Corners[Size - 1].
x == Corners[i].
x) {
240 Edges[i].
m = ((Corners[Size - 1].
y - Corners[i].
y) / (Corners[Size - 1].
x - Corners[i].
x));
242 else if (Corners[i].
x == Corners[i - 1].
x) {
245 Edges[i].
m = ((Corners[i].
y - Corners[i - 1].
y) / (Corners[i].
x - Corners[i - 1].
x));
256 if (LeftYInt > RightYInt) {
264 for (i = 1; i < Size - 1; i++) {
268 if (LeftYInt > RightYInt) {
280 if (LeftYInt > RightYInt) {
289 if (EntryPoint.
y >=
MaxY / 2) {
290 entry_distance = -entry_distance;
305 ys = EntryPoint.
y + entry_distance;
310 XIntercept2 = XIntercept1;
316 if (fabs(EntryPoint.
x - XIntercept2) <= fabs(EntryPoint.
x - XIntercept1)) {
351 #ifdef NAV_SURVEY_POLY_OSAM_DYNAMIC
359 static struct Point2D LastPoint;
362 static bool HalfSweep =
false;
363 float XIntercept1 = 0;
364 float XIntercept2 = 0;
396 LastHalfSweep = HalfSweep;
411 float dist = FromP.
x - C.
x;
442 ys = LastPoint.
y + (
dSweep / 2);
452 ys = LastPoint.
y + (
dSweep / 2);
472 XIntercept2 = XIntercept1;
478 DInt1 = XIntercept1 - LastPoint.
x;
479 DInt2 = XIntercept2 - LastPoint.
x;
481 if (DInt1 * DInt2 >= 0) {
482 if (fabs(DInt2) <= fabs(DInt1)) {
525 if (fabs(temp) < min_radius) {
526 if (temp < 0) { temp = -min_radius; }
else { temp = min_radius; }
588 p->x =
p->x - transX;
589 p->y =
p->y - transY;
592 p->x =
p->x * cosf(Zrot) +
p->y * sinf(Zrot);
593 p->y = -temp * sinf(Zrot) +
p->y * cosf(Zrot);
601 p->x =
p->x * cosf(Zrot) -
p->y * sinf(Zrot);
602 p->y = temp * sinf(Zrot) +
p->y * cosf(Zrot);
604 p->x =
p->x + transX;
605 p->y =
p->y + transY;
610 *
x = ((L2.
b - L1.
b) / (L1.
m - L2.
m));
611 *
y = L1.
m * (*x) + L1.
b;
617 return ((
y - L.
b) / L.
m);
static struct Point2D SurveyToWP
dc_autoshoot_type dc_autoshoot
void nav_survey_poly_osam_setup(uint8_t EntryWP, uint8_t Size, float sw, float Orientation)
Setup polygon survey.
static struct Point2D SurveyCircle
#define POLY_OSAM_DEFAULT_SWEEP
static float EdgeMaxY[PolygonSize]
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
void nav_circle_XY(float x, float y, float radius)
Navigates around (x, y).
static float EdgeMinY[PolygonSize]
#define NavQdrCloseTo(x)
True if x (in degrees) is close to the current QDR (less than 10 degrees)
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
SurveyStatus
This routine will cover the enitre area of any Polygon defined in the flightplan which is a convex po...
static uint8_t SurveySize
#define LINE_START_FUNCTION
static void TranslateAndRotateFromWorld(struct Point2D *p, float Zrot, float transX, float transY)
#define NavVerticalAutoThrottleMode(_pitch)
Set the climb control to auto-throttle with the specified pitch pre-command.
#define NavCircleCountNoRewind()
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.
#define POLY_OSAM_DEFAULT_SIZE
static uint8_t SurveyEntryWP
#define POLY_OSAM_MIN_RADIUS
if 0 never check for min radius
void nav_init_stage(void)
needs to be implemented by fixedwing and rotorcraft seperately
static void RotateAndTranslateToWorld(struct Point2D *p, float Zrot, float transX, float transY)
Rotates point round z by -Zrot then translates so (0,0) becomes (transX,transY)
static struct Point2D SurveyFromWP
uint16_t PolySurveySweepBackNum
uint16_t PolySurveySweepNum
bool nav_survey_poly_osam_run(void)
Run polygon survey.
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
static struct Line Edges[PolygonSize]
static float EvaluateLineForX(float y, struct Line L)
#define POLY_OSAM_USE_FULL_CIRCLE
#define LINE_STOP_FUNCTION
bool nav_approaching_xy(float x, float y, float from_x, float from_y, float approaching_time)
Decide if the UAV is approaching the current waypoint.
void nav_survey_poly_osam_ResetSweepNumber(bool rst)
Reset sweep number.
void nav_survey_poly_osam_setup_towards(uint8_t FirstWP, uint8_t Size, float Sweep, int SecondWP)
Setup "dynamic" polygon survey with sweep orientation towards a waypoint.
static float SurveyRadius
#define POLY_OSAM_HALF_SWEEP_ENABLED
static float SurveyCircleQdr
static enum SurveyStatus CSurveyStatus
static void FindInterceptOfTwoLines(float *x, float *y, struct Line L1, struct Line L2)
#define POLY_OSAM_FIRST_SWEEP_DISTANCE
if 0 default to half sweep
static struct Point2D SmallestCorner
#define NavVerticalAltitudeMode(_alt, _pre_climb)
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
#define POLY_OSAM_ENTRY_RADIUS
Default entry radius, if 0 default to half sweep.