36 #include "generated/flight_plan.h"
43 #ifndef SURVEY_HYBRID_APPROACHING_TIME
44 #define SURVEY_HYBRID_APPROACHING_TIME 3.f
48 #ifndef SURVEY_HYBRID_MAX_POLYGON_SIZE
49 #define SURVEY_HYBRID_MAX_POLYGON_SIZE 20
53 #ifndef SURVEY_HYBRID_HALF_SWEEP_ENABLED
54 #define SURVEY_HYBRID_HALF_SWEEP_ENABLED true
58 #ifndef SURVEY_HYBRID_MAX_SWEEP
59 #define SURVEY_HYBRID_MAX_SWEEP 0
63 #ifndef SURVEY_HYBRID_MAX_SWEEP_BACK
64 #define SURVEY_HYBRID_MAX_SWEEP_BACK 0
68 #ifndef SURVEY_HYBRID_ENTRY_DISTANCE
69 #define SURVEY_HYBRID_ENTRY_DISTANCE (survey_private.sweep_distance / 2.f)
73 #ifndef SURVEY_HYBRID_ENTRY_CIRCLE
74 #define SURVEY_HYBRID_ENTRY_CIRCLE TRUE
114 #define MaxFloat 1000000000
115 #define MinFloat -1000000000
117 #ifndef LINE_START_FUNCTION
118 #define LINE_START_FUNCTION {}
120 #ifndef LINE_STOP_FUNCTION
121 #define LINE_STOP_FUNCTION {}
130 if (nb == 10 || nb == 12) {
132 float sweep = params[1];
134 float height = params[3];
155 if (nb == 10 || nb == 12) {
157 float sweep = params[1];
159 float height = params[3];
164 .
lat = RadOfDeg(params[4+2*i]),
165 .lon = RadOfDeg(params[4+2*i+1]),
210 float XIntercept1 = 0.f;
211 float XIntercept2 = 0.f;
219 if (radius < -0.1f) {
222 }
else if (radius > 0.1f) {
288 if (LeftYInt > RightYInt) {
300 if (LeftYInt > RightYInt) {
312 if (LeftYInt > RightYInt) {
322 entry_distance = -entry_distance;
334 XIntercept2 = XIntercept1;
371 for (
int i = 0; i < size; i++) {
388 if (start == NULL || second == NULL) {
392 float dx = second->
x - start->
x;
393 float dy = second->
y - start->
y;
394 float angle = DegOfRad(atan2f(dy, dx));
409 bool LastHalfSweep =
false;
410 static bool HalfSweep =
false;
411 float XIntercept1 = 0.f;
412 float XIntercept2 = 0.f;
453 LastHalfSweep = HalfSweep;
504 XIntercept2 = XIntercept1;
510 DInt1 = XIntercept1 - LastPoint.
x;
511 DInt2 = XIntercept2 - LastPoint.
x;
513 if (DInt1 *DInt2 >= 0) {
514 if (fabsf(DInt2) <= fabsf(DInt1)) {
619 p->x =
p->x - trans->
x;
620 p->y =
p->y - trans->
y;
623 p->x =
p->x * cosf(Zrot) +
p->y * sinf(Zrot);
624 p->y = -temp * sinf(Zrot) +
p->y * cosf(Zrot);
632 p->x =
p->x * cosf(Zrot) -
p->y * sinf(Zrot);
633 p->y = temp * sinf(Zrot) +
p->y * cosf(Zrot);
635 p->x =
p->x + trans->
x;
636 p->y =
p->y + trans->
y;
641 *
x = ((L2.
b - L1.
b) / (L1.
m - L2.
m));
642 *
y = L1.
m * (*x) + L1.
b;
648 return ((
y - L.
b) / L.
m);
653 float d1x = p1_end->
x - p1_start->
x;
654 float d1y = p1_end->
y - p1_start->
y;
655 float d2x = p2_end->
x - p2_start->
x;
656 float d2y = p2_end->
y - p2_start->
y;
657 return d1x * d2y - d1y * d2x;
void dc_send_command(uint8_t cmd)
Send Command To Camera.
Core autopilot interface common to all firmwares.
float dc_distance_interval
AutoShoot photos on distance to last shot in meters.
Standard Digital Camera Control Interface.
#define FLOAT_VECT2_ZERO(_v)
#define VECT2_COPY(_a, _b)
#define VECT3_COPY(_a, _b)
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
struct LtpDef_f ned_origin_f
Definition of the local (flat earth) coordinate system.
bool mission_register(mission_custom_cb cb, char *type)
Register a new navigation or action callback function.
struct EnuCoor_f * waypoint_get_enu_f(uint8_t wp_id)
Get ENU coordinates (float)
void nav_init_stage(void)
needs to be implemented by fixedwing and rotorcraft seperately
#define NavVerticalAltitudeMode(_alt, _pre_climb)
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
#define CloseRadAngles(_c1, _c2)
#define SURVEY_HYBRID_MAX_SWEEP_BACK
uint8_t size
size of the polygon
#define SURVEY_HYBRID_APPROACHING_TIME
struct EnuCoor_f to_wp
tmp point in rotated frame
struct EnuCoor_f from_wp
tmp point in rotated frame
float orientation
requested orientation in radians
#define LINE_STOP_FUNCTION
static float CrossProductZ(struct EnuCoor_f *p1_start, struct EnuCoor_f *p1_end, struct EnuCoor_f *p2_start, struct EnuCoor_f *p2_end)
#define SURVEY_HYBRID_ENTRY_DISTANCE
#define SURVEY_HYBRID_MAX_SWEEP
float sweep
oriented sweep distance
static void nav_survey_hybrid_setup(float orientation, float sweep, float radius, float height)
finish preparation of survey based on private structure
static float EvaluateLineForX(float y, struct Line L)
static void RotateAndTranslateToWorld(struct EnuCoor_f *p, float Zrot, struct EnuCoor_f *trans)
Rotates point round z by -Zrot then translates so (0,0) becomes (transX,transY)
struct EnuCoor_f entry
entry point
struct Line edges[SURVEY_HYBRID_MAX_POLYGON_SIZE]
polygon edges
void nav_survey_hybrid_init(void)
Init function.
static void TranslateAndRotateFromWorld(struct EnuCoor_f *p, float Zrot, struct EnuCoor_f *trans)
static struct SurveyHybridPrivate survey_private
struct EnuCoor_f circle
circle center
#define SURVEY_HYBRID_ENTRY_CIRCLE
static void FindInterceptOfTwoLines(float *x, float *y, struct Line L1, struct Line L2)
#define SURVEY_HYBRID_MAX_POLYGON_SIZE
#define LINE_START_FUNCTION
bool circle_turns
turns with circles (or lines between points otherwise)
float edge_min_y[SURVEY_HYBRID_MAX_POLYGON_SIZE]
tmp point in rotated frame
bool nav_survey_hybrid_run(void)
Run polygon hybrid survey.
void nav_survey_hybrid_setup_orientation(uint8_t start_wp, float orientation, uint8_t size, float sweep, float radius, float height)
Setup polygon survey.
float sweep_distance
requested sweep distance
#define SURVEY_HYBRID_HALF_SWEEP_ENABLED
struct EnuCoor_f segment_to
end of current segment
void nav_survey_hybrid_setup_towards(uint8_t start_wp, uint8_t second_wp, uint8_t size, float sweep, float radius, float height)
Setup "dynamic" polygon survey with sweep orientation towards a waypoint.
float edge_max_y[SURVEY_HYBRID_MAX_POLYGON_SIZE]
tmp point in rotated frame
enum SurveyStatus status
current state
struct EnuCoor_f corners[SURVEY_HYBRID_MAX_POLYGON_SIZE]
corners location
struct SurveyHybrid survey_hybrid
struct EnuCoor_f segment_from
start of current segment
struct EnuCoor_f smallest_corner
tmp point in rotated frame
uint16_t sweep_back_nb_max
Paparazzi floating point algebra.
void enu_of_lla_point_f(struct EnuCoor_f *enu, struct LtpDef_f *def, struct LlaCoor_f *lla)
float alt
in meters (normally above WGS84 reference ellipsoid)
struct LlaCoor_f lla
origin of local frame in LLA
vector in East North Up coordinates Units: meters
vector in Latitude, Longitude and Altitude
struct RotorcraftNavigation nav
Rotorcraft navigation functions.
navigation_approaching nav_approaching
navigation_circle nav_circle
navigation_route nav_route
API to get/set the generic vehicle states.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.