|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
39 #include "generated/modules.h"
40 #include "generated/flight_plan.h"
48 #include "pprzlink/messages.h"
54 #ifndef DEFAULT_CIRCLE_RADIUS
55 #define DEFAULT_CIRCLE_RADIUS 5.
58 #ifndef NAV_CLIMB_VSPEED
59 #define NAV_CLIMB_VSPEED 0.5
62 #ifndef NAV_DESCEND_VSPEED
63 #define NAV_DESCEND_VSPEED -0.8
67 #ifndef ARRIVED_AT_WAYPOINT
68 #define ARRIVED_AT_WAYPOINT 3.0
72 #ifndef FAILSAFE_MODE_DISTANCE
73 #define FAILSAFE_MODE_DISTANCE (1.5*MAX_DIST_FROM_HOME)
76 #define CLOSE_TO_WAYPOINT (15 << INT32_POS_FRAC)
77 #define CARROT_DIST (12 << INT32_POS_FRAC)
127 #if PERIODIC_TELEMETRY
141 pprz_msg_send_SEGMENT(trans,
dev, AC_ID, &sx, &sy, &ex, &ey);
149 pprz_msg_send_CIRCLE(trans,
dev, AC_ID, &cx, &cy, &r);
156 pprz_msg_send_ROTORCRAFT_NAV_STATUS(trans,
dev, AC_ID,
158 &dist_home, &dist_wp,
173 pprz_msg_send_WP_MOVED_ENU(trans,
dev, AC_ID,
217 #if PERIODIC_TELEMETRY
234 VECT2_STRIM(path_to_waypoint, -(1 << 15), (1 << 15));
243 VECT2_SDIV(path_to_carrot, path_to_carrot, dist_to_waypoint);
251 #if GUIDANCE_H_USE_REF
269 if (approaching_time > 0) {
273 VECT2_SMUL(estimated_progress, *speed, approaching_time);
275 VECT2_SUM(estimated_pos, *pos, estimated_progress);
300 return (diff_f.
x * from_diff_f.
x + diff_f.
y * from_diff_f.
y < 0);
311 static bool wp_reached =
false;
312 static struct EnuCoor_i wp_last = { 0, 0, 0 };
315 if ((wp_last.
x != wp->
x) || (wp_last.
y != wp->
y)) {
335 if (time_at_wp > stay_time) {
344 static int32_t last_nav_alt = 0;
482 #ifdef InGeofenceSector
568 int8_t sign_radius = radius > 0 ? 1 : -1;
570 int32_t abs_radius = abs(radius);
598 uint32_t leg_length2 =
Max((wp_diff.
x * wp_diff.
x + wp_diff.
y * wp_diff.
y), 1);
609 nav_segment_start = *wp_start;
619 #ifndef LINE_START_FUNCTION
620 #define LINE_START_FUNCTION {}
622 #ifndef LINE_STOP_FUNCTION
623 #define LINE_STOP_FUNCTION {}
650 float d = sqrtf(p2_p1_x * p2_p1_x + p2_p1_y * p2_p1_y);
744 uint32_t __attribute__((unused)) height) {}
int32_t int32_atan2(int32_t y, int32_t x)
struct FloatVect3 speed_sp
#define FLOAT_VECT2_ZERO(_v)
int32_t nav_flight_altitude
#define LINE_START_FUNCTION
static void send_wp_moved(struct transport_tx *trans, struct link_device *dev)
#define VECT2_SMUL(_vo, _vi, _s)
struct EnuCoor_i nav_circle_center
float dist2_to_home
squared distance to home waypoint
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
void ins_reset_altitude_ref(void)
INS altitude reference reset.
uint16_t flight_time
flight time in seconds
bool nav_check_wp_time(struct EnuCoor_i *wp, uint16_t stay_time)
Check the time spent in a radius of 'ARRIVED_AT_WAYPOINT' around a wp
static void send_segment(struct transport_tx *trans, struct link_device *dev)
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.
int32_t nav_circle_radians
Status on the current circle.
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
void nav_circle(struct EnuCoor_i *wp_center, int32_t radius)
void nav_set_heading_towards(float x, float y)
Set heading to point towards x,y position in local coordinates.
#define PPRZ_ITRIG_COS(_c, _a)
void nav_follow(uint8_t _ac_id, uint32_t distance, uint32_t height)
#define VECT3_SDIV(_vo, _vi, _s)
struct EnuCoor_i navigation_target
struct EnuCoor_i navigation_carrot
#define POS_FLOAT_OF_BFP(_ai)
#define NavQdrCloseTo(x)
True if x (in degrees) is close to the current QDR (less than 10 degrees)
void nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
void navigation_update_wp_from_speed(uint8_t wp, struct Int16Vect3 speed_sp, int16_t heading_rate_sp)
float get_dist2_to_waypoint(uint8_t wp_id)
Returns squared horizontal distance to given waypoint.
int32_t nav_heading
with INT32_ANGLE_FRAC
int32_t int32_atan2_2(int32_t y, int32_t x)
static void UNUSED nav_advance_carrot(void)
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
void ins_reset_local_origin(void)
local implemetation of the ins_reset functions
void nav_set_heading_current(void)
Set heading to the current yaw angle.
#define HORIZONTAL_MODE_MANUAL
Paparazzi fixed point algebra.
static void nav_set_altitude(void)
#define VECT2_DIFF(_c, _a, _b)
#define HORIZONTAL_MODE_WAYPOINT
#define VECT2_COPY(_a, _b)
#define VECT2_SDIV(_vo, _vi, _s)
#define VECT2_STRIM(_v, _min, _max)
void nav_init(void)
Navigation Initialisation.
#define CARROT
default approaching_time for a wp
bool autopilot_in_flight(void)
get in_flight flag
struct FloatVect2 pos_diff
uint8_t last_wp
Index of last waypoint.
#define LINE_STOP_FUNCTION
int32_t nav_circle_radius
static float float_vect2_norm(struct FloatVect2 *v)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
int32_t psi
in rad with INT32_ANGLE_FRAC
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Device independent GPS code (interface)
struct pprz_autopilot autopilot
Global autopilot structure.
#define INT32_VECT3_RSHIFT(_o, _i, _r)
#define DEFAULT_CIRCLE_RADIUS
default nav_circle_radius in meters
const uint8_t nb_waypoint
#define CLOSE_TO_WAYPOINT
struct EnuCoor_i nav_last_point
#define ANGLE_BFP_OF_REAL(_af)
float flight_altitude
Dynamically adjustable, reset to nav_altitude when it is changing.
static const struct usb_device_descriptor dev
float get_dist2_to_point(struct EnuCoor_i *p)
Returns squared horizontal distance to given point.
struct FloatVect2 line_vect to_end_vect
#define HORIZONTAL_MODE_CIRCLE
static uint32_t int32_vect2_norm(struct Int32Vect2 *v)
return norm of 2D vector
void nav_route(struct EnuCoor_i *wp_start, struct EnuCoor_i *wp_end)
struct EnuCoor_i nav_segment_start nav_segment_end
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
void nav_oval(uint8_t p1, uint8_t p2, float radius)
Navigation along a figure O.
vector in East North Up coordinates Units: meters
bool ground_detected
automatic detection of landing
uint32_t int32_sqrt(uint32_t in)
float failsafe_mode_dist2
maximum squared distance to home wp before going to failsafe mode
void nav_home(void)
Home mode navigation.
static void send_circle(struct transport_tx *trans, struct link_device *dev)
static void send_nav_status(struct transport_tx *trans, struct link_device *dev)
Common code for AP and FBW telemetry.
bool nav_detect_ground(void)
void set_exception_flag(uint8_t flag_num)
#define VECT2_ASSIGN(_a, _x, _y)
void waypoints_init(void)
initialize global and local waypoints
void waypoints_localize_all(void)
update local ENU coordinates of global waypoints
#define FAILSAFE_MODE_DISTANCE
Maximum distance from HOME waypoint before going into failsafe mode.
#define INT32_VECT2_RSHIFT(_o, _i, _r)
void nav_periodic_task(void)
Navigation main: call to the code generated from the XML flight plan.
#define VERTICAL_MODE_ALT
#define VECT2_SUM(_c, _a, _b)
#define ARRIVED_AT_WAYPOINT
minimum horizontal distance to waypoint to mark as arrived
#define INT32_DEG_OF_RAD(_rad)
bool autopilot_set_mode(uint8_t new_autopilot_mode)
set autopilot mode
void nav_set_heading_deg(float deg)
Set nav_heading in degrees.
void nav_init_stage(void)
needs to be implemented by fixedwing and rotorcraft seperately
void nav_set_manual(int32_t roll, int32_t pitch, int32_t yaw)
Set manual roll, pitch and yaw without stabilization.
#define POS_BFP_OF_REAL(_af)
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
#define INT_VECT3_ZERO(_v)
#define NAV_DESCEND_VSPEED
void nav_set_heading_towards_waypoint(uint8_t wp)
Set heading in the direction of a waypoint.
bool nav_is_in_flight(void)
const float max_dist2_from_home
#define HORIZONTAL_MODE_ROUTE
void nav_set_heading_rad(float rad)
Set nav_heading in radians.
uint8_t nav_oval_count
Navigation along a figure O.
float dist2_to_wp
squared distance to next waypoint
uint32_t nav_throttle
direct throttle from 0:MAX_PPRZ, used in VERTICAL_MODE_MANUAL
#define DefaultPeriodic
Set default periodic telemetry.
vector in East North Up coordinates
void nav_set_heading_towards_target(void)
Set heading in the direction of the target.
#define VECT3_COPY(_a, _b)
void nav_set_failsafe(void)
const float max_dist_from_home
#define INT32_COURSE_NORMALIZE(_a)
#define INT32_ANGLE_NORMALIZE(_a)
#define PPRZ_ITRIG_SIN(_s, _a)