36 #include "generated/modules.h"
37 #include "generated/flight_plan.h"
46 #include "pprzlink/messages.h"
117 if (DL_BLOCK_ac_id(buf) != AC_ID) {
return; }
123 uint8_t ac_id = DL_MOVE_WP_ac_id(buf);
124 if (ac_id != AC_ID) {
return; }
126 uint8_t wp_id = DL_MOVE_WP_wp_id(buf);
128 lla.
lat = DL_MOVE_WP_lat(buf);
129 lla.
lon = DL_MOVE_WP_lon(buf);
139 #ifndef CLOSE_TO_WAYPOINT
140 #define CLOSE_TO_WAYPOINT 15.f
160 VECT2_SDIV(path_to_carrot, path_to_carrot, dist_to_waypoint);
168 #if GUIDANCE_H_USE_REF
185 static bool wp_reached =
false;
186 static struct EnuCoor_i wp_last = { 0, 0, 0 };
191 if ((wp_last.
x != wp_i.
x) || (wp_last.
y != wp_i.
y)) {
210 if (time_at_wp > stay_time) {
219 static float last_alt = 0.f;
285 VECT2_DIFF(wp_diff, *end_point, *start_point);
289 float alt = start_point->
z + (end_point->
z - start_point->
z) * progress;
330 #ifdef InGeofenceSector
bool autopilot_set_mode(uint8_t new_autopilot_mode)
set autopilot mode
struct pprz_autopilot autopilot
Global autopilot structure.
bool autopilot_in_flight(void)
get in_flight flag
Core autopilot interface common to all firmwares.
bool ground_detected
automatic detection of landing
uint16_t flight_time
flight time in seconds
void common_flight_plan_init(void)
void nav_goto_block(uint8_t b)
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
Common code for AP and FBW telemetry.
static void float_quat_identity(struct FloatQuat *q)
initialises a quaternion to identity
static float float_vect2_norm2(struct FloatVect2 *v)
#define FLOAT_VECT3_ZERO(_v)
static float float_vect2_norm(struct FloatVect2 *v)
#define FLOAT_RATES_ZERO(_r)
#define VECT2_SMUL(_vo, _vi, _s)
#define VECT2_DIFF(_c, _a, _b)
#define VECT2_STRIM(_v, _min, _max)
#define VECT2_COPY(_a, _b)
#define VECT2_SUM(_c, _a, _b)
#define VECT2_SDIV(_vo, _vi, _s)
#define VECT3_COPY(_a, _b)
#define INT_VECT3_ZERO(_v)
int32_t lat
in degrees*1e7
int32_t hmsl
Height above mean sea level in mm.
int32_t alt
in millimeters above WGS84 reference ellipsoid
struct LlaCoor_i lla
Reference point in lla.
int32_t lon
in degrees*1e7
#define ENU_BFP_OF_REAL(_o, _i)
vector in East North Up coordinates
vector in Latitude, Longitude and Altitude
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
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.
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
static bool stateIsLocalCoordinateValid(void)
Test if local coordinates are valid.
void WEAK ins_reset_local_origin(void)
INS local origin reset.
void WEAK ins_reset_altitude_ref(void)
INS altitude reference reset.
Integrated Navigation System interface.
void waypoints_localize_all(void)
update local ENU coordinates of global waypoints
float waypoint_get_alt(uint8_t wp_id)
Get altitude of waypoint in meters (above reference)
void waypoints_init(void)
initialize global and local waypoints
void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla)
void nav_oval(uint8_t p1, uint8_t p2, float radius)
#define NAVIGATION_FREQUENCY
Default fixedwing navigation frequency.
#define NavVerticalAltitudeMode(_alt, _pre_climb)
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
static void nav_goto(struct EnuCoor_f *wp)
static void _nav_oval_init(void)
static void nav_route(struct EnuCoor_f *wp_start, struct EnuCoor_f *wp_end)
static void nav_circle(struct EnuCoor_f *wp_center, float radius)
static bool nav_approaching(struct EnuCoor_f *wp, struct EnuCoor_f *from, float approaching_time)
static void nav_stage_init(void)
Implement basic nav function.
struct FloatVect2 pos_diff
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Paparazzi fixed point algebra.
float hmsl
Height above mean sea level in meters.
vector in East North Up coordinates Units: meters
Horizontal guidance for rotorcrafts.
void nav_home(void)
Home mode navigation.
static void empty_oval_init(void)
static bool empty_approaching(struct EnuCoor_f *wp_to UNUSED, struct EnuCoor_f *wp_from UNUSED, float approaching_time UNUSED)
float flight_altitude
Dynamically adjustable, reset to nav_altitude when it is changing.
void nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
void nav_register_oval(navigation_oval_init _nav_oval_init, navigation_oval nav_oval)
void nav_set_heading_current(void)
Set heading to the current yaw angle.
void nav_init_stage(void)
needs to be implemented by fixedwing and rotorcraft seperately
const float max_dist_from_home
void nav_set_heading_towards_waypoint(uint8_t wp)
Set heading in the direction of a waypoint.
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
bool nav_is_in_flight(void)
void nav_set_heading_towards(float x, float y)
Set heading to point towards x,y position in local coordinates.
struct RotorcraftNavigation nav
void nav_init(void)
Navigation Initialisation.
void nav_parse_MOVE_WP(uint8_t *buf)
void nav_register_circle(navigation_circle nav_circle)
void nav_register_goto_wp(navigation_goto nav_goto, navigation_route nav_route, navigation_approaching nav_approaching)
Registering functions.
static void empty_stage_init(void)
Empty navigation functions set at init.
static void empty_oval(struct EnuCoor_f *wp1 UNUSED, struct EnuCoor_f *wp2 UNUSED, float radius UNUSED)
void nav_parse_BLOCK(uint8_t *buf)
#define CLOSE_TO_WAYPOINT
static void empty_goto(struct EnuCoor_f *wp UNUSED)
void nav_set_heading_towards_target(void)
Set heading in the direction of the target.
float get_dist2_to_point(struct EnuCoor_f *p)
Returns squared horizontal distance to given point.
void nav_register_stage_init(navigation_stage_init nav_stage_init)
Register functions.
static void empty_route(struct EnuCoor_f *wp_start UNUSED, struct EnuCoor_f *wp_end UNUSED)
const float max_dist2_from_home
void nav_glide_points(struct EnuCoor_f *start_point, struct EnuCoor_f *end_point)
void nav_set_heading_rad(float rad)
Set nav_heading in radians.
bool nav_detect_ground(void)
void nav_set_heading_deg(float deg)
Set nav_heading in degrees.
static void empty_circle(struct EnuCoor_f *wp_center UNUSED, float radius UNUSED)
bool nav_check_wp_time(struct EnuCoor_f *wp, uint16_t stay_time)
Check the time spent in a radius of 'ARRIVED_AT_WAYPOINT' around a wp
void nav_periodic_task(void)
Navigation main: call to the code generated from the XML flight plan.
float get_dist2_to_waypoint(uint8_t wp_id)
Returns squared horizontal distance to given waypoint.
static void UNUSED nav_advance_carrot(void)
static void nav_set_altitude(void)
void nav_set_failsafe(void)
Rotorcraft navigation functions.
struct EnuCoor_f speed
speed setpoint (in m/s)
struct FloatRates rates
rates setpoint (in rad/s)
#define NAV_HORIZONTAL_MODE_WAYPOINT
Nav modes these modes correspond to the flight plan instructions used to set the high level navigatio...
float fp_max_speed
maximum speed setpoint from flight plan (in m/s), negative value means unset or invalid,...
uint32_t throttle
throttle command (in pprz_t)
float climb
climb setpoint (in m/s)
float dist2_to_home
squared distance to home waypoint
void(* navigation_goto)(struct EnuCoor_f *wp)
#define NAV_DESCEND_VSPEED
bool(* navigation_approaching)(struct EnuCoor_f *wp_to, struct EnuCoor_f *wp_from, float approaching_time)
float failsafe_mode_dist2
maximum squared distance to home wp before going to failsafe mode
void(* navigation_oval)(struct EnuCoor_f *wp1, struct EnuCoor_f *wp2, float radius)
navigation_stage_init nav_stage_init
navigation_approaching nav_approaching
struct FloatQuat quat
quaternion setpoint
#define DEFAULT_CIRCLE_RADIUS
default nav_circle_radius in meters
navigation_circle nav_circle
#define NAV_CARROT_DIST
Carrot distance during navigation.
void(* navigation_oval_init)(void)
struct EnuCoor_f accel
accel setpoint (in m/s)
float nav_altitude
current altitude setpoint (in meters): might differ from fp_altitude depending on altitude shift from...
#define NAV_VERTICAL_MODE_ALT
float radius
radius setpoint (in meters)
float descend_vspeed
descend speed setting, mostly used in flight plans
navigation_oval_init nav_oval_init
void(* navigation_route)(struct EnuCoor_f *wp_start, struct EnuCoor_f *wp_end)
float pitch
pitch angle (in radians)
void(* navigation_circle)(struct EnuCoor_f *wp_center, float radius)
float heading
heading setpoint (in radians)
struct EnuCoor_f carrot
carrot position (also used for GCS display)
navigation_route nav_route
#define NAV_SETPOINT_MODE_POS
Nav setpoint modes these modes correspond to submodes defined by navigation routines to tell which se...
float fp_altitude
altitude setpoint from flight plan (in meters)
void(* navigation_stage_init)(void)
#define FAILSAFE_MODE_DISTANCE
Maximum distance from HOME waypoint before going into failsafe mode.
struct EnuCoor_f target
final target position (in meters)
bool too_far_from_home
too_far flag
#define ARRIVED_AT_WAYPOINT
minimum horizontal distance to waypoint to mark as arrived
float climb_vspeed
climb speed setting, mostly used in flight plans
float roll
roll angle (in radians)
General Navigation structure.
#define NormCourseRad(x)
Normalize a rad angle between 0 and 2*PI.
API to get/set the generic vehicle states.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.