|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
31 #include "generated/flight_plan.h"
37 #ifndef POLYSURVEY_DEFAULT_SIZE
38 #define POLYSURVEY_DEFAULT_SIZE 10
41 #ifndef POLYSURVEY_DEFAULT_DISTANCE
42 #define POLYSURVEY_DEFAULT_DISTANCE 25
46 #ifndef POLYSURVEY_ENTRY_DISTANCE
47 #define POLYSURVEY_ENTRY_DISTANCE 0
51 #ifndef POLYSURVEY_MAX_POLYGONSIZE
52 #define POLYSURVEY_MAX_POLYGONSIZE 20
56 #ifndef POLY_OSAM_HALF_SWEEP_ENABLED
57 #define POLY_OSAM_HALF_SWEEP_ENABLED TRUE
67 if (dx == 0.0
f) { dx = 0.000000001; }
68 float ang = atan(dy / dx);
78 struct Line {
float m;
float b;
float x;};
85 #define MaxPolygonSize POLYSURVEY_MAX_POLYGONSIZE
86 #define MaxFloat 1000000000
87 #define MinFloat -1000000000
89 #ifndef LINE_START_FUNCTION
90 #define LINE_START_FUNCTION {}
92 #ifndef LINE_STOP_FUNCTION
93 #define LINE_STOP_FUNCTION {}
133 float XIntercept1 = 0;
134 float XIntercept2 = 0;
135 float entry_distance;
139 if (PolySurveyEntryDistance == 0) {
140 entry_distance = sw / 2;
142 entry_distance = PolySurveyEntryDistance;
162 if (Size <= MaxPolygonSize && Orientation >= -90 && Orientation <= 90) {
164 for (i = 0; i < Size; i++) {
170 for (i = 0; i < Size; i++) {
177 for (i = 1; i < Size; i++) {
188 for (i = 0; i < Size; i++) {
193 EntryPoint.
x = Corners[0].
x;
194 EntryPoint.
y = Corners[0].
y;
198 for (i = 1; i < Size; i++) {
199 if (Corners[i].
y >
MaxY) {
205 for (i = 0; i < Size; i++) {
207 if (Corners[Size - 1].
x == Corners[i].
x) {
210 Edges[i].
m = ((Corners[Size - 1].
y - Corners[i].
y) / (Corners[Size - 1].
x - Corners[i].
x));
212 else if (Corners[i].
x == Corners[i - 1].
x) {
215 Edges[i].
m = ((Corners[i].
y - Corners[i - 1].
y) / (Corners[i].
x - Corners[i - 1].
x));
226 if (LeftYInt > RightYInt) {
234 for (i = 1; i < Size - 1; i++) {
238 if (LeftYInt > RightYInt) {
250 if (LeftYInt > RightYInt) {
259 if (EntryPoint.
y >=
MaxY / 2) {
260 entry_distance = -entry_distance;
267 ys = EntryPoint.
y + entry_distance;
272 XIntercept2 = XIntercept1;
278 if (fabs(EntryPoint.
x - XIntercept2) <= fabs(EntryPoint.
x - XIntercept1)) {
310 #ifdef NAV_SURVEY_POLY_DYNAMIC
321 static bool HalfSweep =
false;
322 float XIntercept1 = 0;
323 float XIntercept2 = 0;
349 LastHalfSweep = HalfSweep;
371 float line_length = fabsf((fabsf(FromP.
x) - fabsf(ToP.
x)));
392 ys = LastPoint.
y + (
dSweep / 2);
404 XIntercept2 = XIntercept1;
410 DInt1 = XIntercept1 - LastPoint.
x;
411 DInt2 = XIntercept2 - LastPoint.
x;
413 if (DInt1 *DInt2 >= 0) {
414 if (fabs(DInt2) <= fabs(DInt1)) {
501 p->x =
p->x - transX;
502 p->y =
p->y - transY;
505 p->x =
p->x * cosf(Zrot) +
p->y * sinf(Zrot);
506 p->y = -temp * sinf(Zrot) +
p->y * cosf(Zrot);
514 p->x =
p->x * cosf(Zrot) -
p->y * sinf(Zrot);
515 p->y = temp * sinf(Zrot) +
p->y * cosf(Zrot);
517 p->x =
p->x + transX;
518 p->y =
p->y + transY;
523 *
x = ((L2.
b - L1.
b) / (L1.
m - L2.
m));
524 *
y = L1.
m * (*x) + L1.
b;
530 return ((
y - L.
b) / L.
m);
static struct EnuCoor_f SurveyFromWP
static void RotateAndTranslateToWorld(struct EnuCoor_f *p, float Zrot, float transX, float transY)
Rotates point round z by -Zrot then translates so (0,0) becomes (transX,transY)
#define LINE_STOP_FUNCTION
static enum SurveyStatus CSurveyStatus
void nav_survey_poly_setup_towards(uint8_t FirstWP, uint8_t Size, float Sweep, int SecondWP)
Setup "dynamic" polygon survey with sweep orientation towards a waypoint.
static struct Point2D SmallestCorner
uint16_t PolySurveySweepBackNum
static float EdgeMaxY[MaxPolygonSize]
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
bool nav_approaching_from(struct EnuCoor_i *wp, struct EnuCoor_i *from, int16_t approaching_time)
Proximity tests on approaching a wp.
static float EdgeMinY[MaxPolygonSize]
struct EnuCoor_i navigation_target
static struct EnuCoor_f SurveyToWP
static void FindInterceptOfTwoLines(float *x, float *y, struct Line L1, struct Line L2)
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...
float dc_distance_interval
AutoShoot photos on distance to last shot in meters.
#define POLYSURVEY_DEFAULT_SIZE
static struct EnuCoor_f SurveyEntry
static float EvaluateLineForX(float y, struct Line L)
void dc_send_command(uint8_t cmd)
Send Command To Camera.
static uint8_t SurveySize
static struct EnuCoor_i survey_from_i survey_to_i
void nav_init_stage(void)
needs to be implemented by fixedwing and rotorcraft seperately
static void TranslateAndRotateFromWorld(struct EnuCoor_f *p, float Zrot, float transX, float transY)
static uint8_t SurveyEntryWP
#define POLY_OSAM_HALF_SWEEP_ENABLED
void nav_route(struct EnuCoor_i *wp_start, struct EnuCoor_i *wp_end)
vector in East North Up coordinates Units: meters
void nav_survey_poly_setup(uint8_t EntryWP, uint8_t Size, float sw, float Orientation)
Setup polygon survey.
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
bool nav_survey_poly_run(void)
Run polygon survey.
uint16_t PolySurveySweepNum
#define POLYSURVEY_ENTRY_DISTANCE
if 0 default to half sweep
static struct Line Edges[MaxPolygonSize]
void nav_set_heading_deg(float deg)
Set nav_heading in degrees.
#define LINE_START_FUNCTION
#define HORIZONTAL_MODE_ROUTE
#define POLYSURVEY_DEFAULT_DISTANCE
vector in East North Up coordinates
#define VECT3_COPY(_a, _b)
#define NavVerticalAltitudeMode(_alt, _pre_climb)
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
#define ENU_BFP_OF_REAL(_o, _i)