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.0f) { dx = 0.000000001; }
94struct Line {
float m;
float b;
float x;};
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 {}
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++) {
228 for (i = 1; i <
Size; i++) {
235 for (i = 0; i <
Size; i++) {
264 for (i = 1; i <
Size - 1; i++) {
351 #ifdef NAV_SURVEY_POLY_OSAM_DYNAMIC
411 float dist =
FromP.x - C.
x;
611 *
y =
L1.m * (*x) +
L1.b;
617 return ((
y - L.
b) / L.
m);
Core autopilot interface common to all firmwares.
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
dc_autoshoot_type dc_autoshoot
Standard Digital Camera Control Interface.
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
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_init_stage(void)
needs to be implemented by fixedwing and rotorcraft seperately
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.
void nav_circle_XY(float x, float y, float radius)
Navigates around (x, y).
Fixedwing Navigation library.
#define NavCircleCountNoRewind()
#define NavQdrCloseTo(x)
True if x (in degrees) is close to the current QDR (less than 10 degrees)
#define NavVerticalAltitudeMode(_alt, _pre_climb)
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
#define NavVerticalAutoThrottleMode(_pitch)
Set the climb control to auto-throttle with the specified pitch pre-command.
#define POLY_OSAM_DEFAULT_SIZE
#define POLY_OSAM_DEFAULT_SWEEP
#define LINE_STOP_FUNCTION
static struct Line Edges[PolygonSize]
#define POLY_OSAM_FIRST_SWEEP_DISTANCE
if 0 default to half sweep
static struct Point2D SurveyCircle
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.
#define POLY_OSAM_USE_FULL_CIRCLE
static float EvaluateLineForX(float y, struct Line L)
static uint8_t SurveySize
uint16_t PolySurveySweepNum
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 SmallestCorner
static void FindInterceptOfTwoLines(float *x, float *y, struct Line L1, struct Line L2)
#define LINE_START_FUNCTION
void nav_survey_poly_osam_setup(uint8_t EntryWP, uint8_t Size, float sw, float Orientation)
Setup polygon survey.
static float SurveyCircleQdr
static uint8_t SurveyEntryWP
static float SurveyRadius
uint16_t PolySurveySweepBackNum
#define POLY_OSAM_MIN_RADIUS
if 0 never check for min radius
#define POLY_OSAM_ENTRY_RADIUS
Default entry radius, if 0 default to half sweep.
#define POLY_OSAM_HALF_SWEEP_ENABLED
void nav_survey_poly_osam_ResetSweepNumber(bool rst)
Reset sweep number.
static void TranslateAndRotateFromWorld(struct Point2D *p, float Zrot, float transX, float transY)
static struct Point2D SurveyFromWP
static struct Point2D SurveyToWP
static float EdgeMinY[PolygonSize]
static float EdgeMaxY[PolygonSize]
bool nav_survey_poly_osam_run(void)
Run polygon survey.
static enum SurveyStatus CSurveyStatus
API to get/set the generic vehicle states.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.