34 #include "generated/flight_plan.h"
49 #define PRTDEB(TYPE,EXP) \
50 printf("%5d: " #EXP ": %"#TYPE"\n",CPTDEBUG,EXP);fflush(stdout);CPTDEBUG++;
51 #define PRTDEBSTR(EXP) \
52 printf("%5d: STR: "#EXP"\n",CPTDEBUG);fflush(stdout);CPTDEBUG++;
54 #define PRTDEB(TYPE,EXP) \
57 #define PRTDEBSTR(EXP) \
71 #define DISTXY(P1X,P1Y,P2X,P2Y)\
72 (sqrt( ( (P2X-P1X) * (P2X-P1X) ) + ( (P2Y-P1Y) * (P2Y-P1Y) ) ) )
74 #define NORMXY(P1X,P1Y)\
75 (sqrt( ( (P1X) * (P1X) ) + ( (P1Y) * (P1Y) ) ) )
89 #define USE_ONBOARD_CAMERA 1
91 #if USE_ONBOARD_CAMERA
139 #include "generated/modules.h"
155 static uint8_t dummy_state = 0;
156 static uint8_t snapshot_valid = 1;
157 static float dummy_temp = NAN;
187 cartography_periodic_downlink_carto_status = MODULES_START;
196 cartography_periodic_downlink_carto_status = MODULES_START;
205 cartography_periodic_downlink_carto_status = MODULES_START;
224 float *normAMf,
float *normBMf,
float *distancefromrailf);
228 float *normAMf,
float *normBMf,
float *distancefromrailf)
231 float a, b, c, xa, xb, xc, ya, yb, yc;
238 float AMx, AMy, BMx, BMy;
255 c = (yb - yc) * xb + (xc - xb) * yb ;
260 if (fabs(a) > 1e-10) {
261 *distancefromrailf = fabs((a * xa + b * ya + c) / sqrt(a * a + b *
270 PRTDEB(f, *distancefromrailf)
276 if (fabs(AA1) > 1e-10) {
277 f = (b - (a * BB1 / AA1));
278 if (fabs(f) > 1e-10) {
279 YP = (-(a * xa) - (a * BB1 * ya / AA1) - c) / f;
290 XP = (-c - b * YP) / a ;
300 AMx = XP - pointAf.
x;
301 AMy = YP - pointAf.
y;
302 BMx = XP - pointBf.
x;
303 BMy = YP - pointBf.
y;
305 *normAMf =
NORMXY(AMx, AMy);
306 *normBMf =
NORMXY(BMx, BMy);
311 if (((*normAMf) + (*normBMf)) > 1.05 *
DISTXY(pointBf.
x, pointBf.
y, pointAf.
x, pointAf.
y)) {
349 vec12.x = point2.x - point1.x;
350 vec12.y = point2.y - point1.y;
372 if (fabs(distrailinit) <= 1) {
486 || (
normBM < (
DISTXY(pointB.x, pointB.y, pointA.x, pointA.y)))) {
717 cartography_periodic_downlink_carto_status = MODULES_START;
#define PRTDEB(TYPE, EXP)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define DISTXY(P1X, P1Y, P2X, P2Y)
static struct point point1 point2 point3
static struct point vec12 vec13
bool nav_survey_Snapshoot(void)
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
uint16_t railnumberSinceBoot
#define NavCircleWaypoint(wp, radius)
bool nav_survey_Inc_railnumberSinceBoot(void)
bool nav_survey_StopSnapshoot(void)
bool nav_survey_losange_carto(void)
bool survey_losange_uturn
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 init_carto(void)
Automatic survey of an oriented rectangle (defined by three points)
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
static struct point pointA pointB pointC
API to get/set the generic vehicle states.
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
Common code for AP and FBW telemetry.
bool ProjectionInsideLimitOfRail
void periodic_downlink_carto(void)
bool nav_survey_losange_carto_init(uint8_t wp1, uint8_t wp2, uint8_t wp3, float distrailinit, float distplusinit)
bool nav_survey_computefourth_corner(uint8_t wp1, uint8_t wp2, uint8_t wp3, uint8_t wp4)
bool nav_survey_ComputeProjectionOnLine(struct point pointAf, struct point pointBf, float pos_xf, float pos_yf, float *normAMf, float *normBMf, float *distancefromrailf)
bool nav_survey_Snapshoot_Continu(void)
Fixedwing Navigation library.
uint16_t camera_snapshot_image_number