Paparazzi UAS
v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
|
Fixedwing functions to compute navigation. More...
#include <math.h>
#include "firmwares/fixedwing/nav.h"
#include "subsystems/gps.h"
#include "firmwares/fixedwing/stabilization/stabilization_attitude.h"
#include "firmwares/fixedwing/autopilot.h"
#include "inter_mcu.h"
#include "subsystems/navigation/traffic_info.h"
#include "generated/flight_plan.h"
#include "subsystems/navigation/common_nav.c"
Go to the source code of this file.
Macros | |
#define | NAV_C |
#define | RCLost() bit_is_set(fbw_state->status, STATUS_RADIO_REALLY_LOST) |
#define | NAV_GLIDE_PITCH_TRIM 0. |
#define | PowerVoltage() (vsupply/10.) |
#define | RcRoll(travel) (fbw_state->channels[RADIO_ROLL]* (float)travel /(float)MAX_PPRZ) |
#define | MIN_DX ((int16_t)(MAX_PPRZ * 0.05)) |
#define | NavGlide(_last_wp, _wp) |
#define | MAX_DIST_CARROT 250. |
#define | MIN_HEIGHT_CARROT 50. |
#define | MAX_HEIGHT_CARROT 150. |
#define | Goto3D(radius) |
#define | NavFollow(_ac_id, _distance, _height) nav_follow(_ac_id, _distance, _height); |
#define | LINE_START_FUNCTION {} |
#define | LINE_STOP_FUNCTION {} |
#define | FAILSAFE_HOME_RADIUS DEFAULT_CIRCLE_RADIUS |
Enumerations | |
enum | eight_status { R1T, RT2, C2, R2T, RT1, C1 } |
Functions | |
void | nav_init_stage (void) |
needs to be implemented by fixedwing and rotorcraft seperately More... | |
void | nav_circle_XY (float x, float y, float radius) |
Navigates around (x, y). More... | |
static void | nav_follow (uint8_t _ac_id, float _distance, float _height) |
static bool_t | nav_compute_baseleg (uint8_t wp_af, uint8_t wp_td, uint8_t wp_baseleg, float radius) |
static bool_t | nav_compute_final_from_glide (uint8_t wp_af, uint8_t wp_td, float glide) |
static bool_t | compute_TOD (uint8_t _af, uint8_t _td, uint8_t _tod, float glide_airspeed, float glide_vspeed) |
bool_t | 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. More... | |
void | fly_to_xy (float x, float y) |
Computes desired_x, desired_y and desired_course. More... | |
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. More... | |
static void | nav_set_altitude (void) |
void | nav_home (void) |
Home mode navigation (circle around HOME) More... | |
void | nav_periodic_task (void) |
Navigation main: call to the code generated from the XML flight plan. More... | |
void | nav_init (void) |
Periodic telemetry. More... | |
void | nav_without_gps (void) |
Failsafe navigation without position estimation. More... | |
void | nav_eight_init (void) |
void | nav_eight (uint8_t target, uint8_t c1, float radius) |
Navigation along a figure 8. More... | |
void | nav_oval_init (void) |
void | nav_oval (uint8_t p1, uint8_t p2, float radius) |
Fixedwing functions to compute navigation.
Definition in file nav.c.
#define FAILSAFE_HOME_RADIUS DEFAULT_CIRCLE_RADIUS |
Definition at line 420 of file nav.c.
Referenced by nav_home().
#define LINE_START_FUNCTION {} |
Definition at line 292 of file nav.c.
Referenced by nav_oval().
#define LINE_STOP_FUNCTION {} |
Definition at line 295 of file nav.c.
Referenced by nav_oval().
#define NAV_GLIDE_PITCH_TRIM 0. |
Definition at line 77 of file nav.c.
Referenced by nav_init().
#define NavFollow | ( | _ac_id, | |
_distance, | |||
_height | |||
) | nav_follow(_ac_id, _distance, _height); |
#define NavGlide | ( | _last_wp, | |
_wp | |||
) |
#define RcRoll | ( | travel | ) | (fbw_state->channels[RADIO_ROLL]* (float)travel /(float)MAX_PPRZ) |
enum eight_status |
|
inlinestatic |
Definition at line 273 of file nav.c.
References FALSE, stateGetHorizontalWindspeed_f(), WaypointAlt, WaypointX, WaypointY, FloatVect2::x, and FloatVect2::y.
void fly_to_xy | ( | float | x, |
float | y | ||
) |
Computes desired_x, desired_y and desired_course.
Definition at line 367 of file nav.c.
References CARROT, h_ctl_course_pgain, h_ctl_course_setpoint, h_ctl_roll_max_setpoint, h_ctl_roll_setpoint, lateral_mode, LATERAL_MODE_COURSE, LATERAL_MODE_ROLL, NAV_MODE_COURSE, stateGetHorizontalSpeedDir_f(), stateGetHorizontalSpeedNorm_f(), stateGetPositionEnu_f(), EnuCoor_f::x, and EnuCoor_f::y.
Referenced by formation_flight(), mission_nav_wp(), nav_circle_XY(), nav_follow(), nav_route_xy(), and potential_task().
bool_t 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.
Computes dist2_to_wp and compare it to square carrot. Return true if it is smaller. Else computes by scalar products if uav has not gone past waypoint. approaching_time can be negative and in this case, the UAV will fly after the waypoint for the given number of seconds.
distance to waypoint in x
distance to waypoint in y
Definition at line 335 of file nav.c.
References dist2_to_wp, Max, stateGetHorizontalSpeedNorm_f(), stateGetPositionEnu_f(), TRUE, EnuCoor_f::x, and EnuCoor_f::y.
Referenced by mission_nav_path(), mission_nav_segment(), mission_nav_wp(), nav_eight(), nav_line_osam_run(), nav_oval(), nav_spiral_run(), nav_survey_disc_run(), nav_survey_poly_osam_run(), nav_survey_polygon_run(), nav_survey_zamboni_run(), and snav_route().
void nav_circle_XY | ( | float | x, |
float | y, | ||
float | radius | ||
) |
Navigates around (x, y).
Angle from center to mobile.
Clockwise iff radius > 0
Computes a prebank. Go straight if inside or outside the circle
Definition at line 110 of file nav.c.
References CARROT, DistanceSquare, fly_to_xy(), HORIZONTAL_MODE_CIRCLE, Max, Min, nav_circle_trigo_qdr, NAV_GRAVITY, NAV_MODE_COURSE, nav_shift, radius, Square, stateGetHorizontalSpeedNorm_f(), stateGetPositionEnu_f(), TRUE, EnuCoor_f::x, and EnuCoor_f::y.
Referenced by mission_nav_circle(), nav_eight(), nav_flower_run(), nav_line_border_run(), nav_line_osam_run(), nav_line_run(), nav_oval(), nav_spiral_run(), nav_survey_disc_run(), nav_survey_poly_osam_run(), nav_survey_polygon_run(), nav_survey_zamboni_run(), nav_vertical_raster_run(), snav_circle1(), snav_circle2(), and snav_on_time().
Navigation along a figure 8.
The cross center is defined by the waypoint [target], the center of one of the circles is defined by [c1]. Altitude is given by [target]. The navigation goes through 6 states: C1 (circle around [c1]), R1T, RT2 (route from circle 1 to circle 2 over [target]), C2 and R2T, RT1. If necessary, the [c1] waypoint is moved in the direction of [target] to be not far than [2*radius].
Definition at line 601 of file nav.c.
References point::a, c1, C1, C2, CARROT, InitStage, Max, nav_approaching_xy(), nav_circle_XY(), nav_route_xy(), NavCircleWaypoint, NavQdrCloseTo, R1T, R2T, RT1, RT2, target, waypoints, point::x, and point::y.
|
inlinestatic |
Definition at line 300 of file nav.c.
References ac_info_::alt, ac_info_::course, ac_info_::east, fly_to_xy(), get_ac_info(), ground_alt, ac_info_::gspeed, Max, NavVerticalAltitudeMode, NavVerticalAutoThrottleMode, ac_info_::north, stateGetPositionEnu_f(), EnuCoor_f::x, and EnuCoor_f::y.
void nav_home | ( | void | ) |
Home mode navigation (circle around HOME)
Nominal speed
Definition at line 434 of file nav.c.
Referenced by autopilot_periodic(), and navigation_task().
void nav_init | ( | void | ) |
Periodic telemetry.
Navigation Initialisation
Definition at line 530 of file nav.c.
Referenced by autopilot_init(), and init_ap().
void nav_init_stage | ( | void | ) |
needs to be implemented by fixedwing and rotorcraft seperately
Definition at line 91 of file nav.c.
Referenced by nav_anemotaxis(), nav_bungee_takeoff_run(), nav_flower_run(), nav_line_border_run(), nav_line_osam_run(), nav_line_run(), nav_survey_disc_run(), nav_survey_poly_osam_run(), nav_survey_poly_run(), nav_survey_polygon_run(), nav_survey_zamboni_run(), and nav_vertical_raster_run().
Definition at line 730 of file nav.c.
References point::a, CARROT, InitStage, LINE_START_FUNCTION, LINE_STOP_FUNCTION, nav_approaching_xy(), nav_circle_XY(), nav_route_xy(), NavQdrCloseTo, OC1, OC2, OR12, OR21, radius, waypoints, point::x, and point::y.
void nav_periodic_task | ( | void | ) |
Navigation main: call to the code generated from the XML flight plan.
Definition at line 450 of file nav.c.
Referenced by autopilot_periodic(), and navigation_task().
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.
distance of carrot (in meter)
Definition at line 393 of file nav.c.
References CARROT, fly_to_xy(), HORIZONTAL_MODE_ROUTE, Max, stateGetPositionEnu_f(), TRUE, EnuCoor_f::x, and EnuCoor_f::y.
Referenced by mission_nav_path(), mission_nav_segment(), nav_bungee_takeoff_run(), nav_eight(), nav_flower_run(), nav_line_osam_run(), nav_oval(), nav_points(), nav_spiral_run(), nav_survey_disc_run(), nav_survey_losange_carto(), nav_survey_poly_osam_run(), nav_survey_rectangle(), nav_survey_zamboni_run(), and snav_route().
|
static |
Definition at line 423 of file nav.c.
References flight_altitude, nav_altitude, and v_ctl_altitude_setpoint.
Referenced by nav_home(), and nav_periodic_task().
void nav_without_gps | ( | void | ) |
Failsafe navigation without position estimation.
Just set attitude and throttle to FAILSAFE values to prevent the plane from crashing.
Definition at line 565 of file nav.c.
References h_ctl_roll_setpoint, lateral_mode, LATERAL_MODE_ROLL, MAX_PPRZ, TRIM_UPPRZ, v_ctl_mode, and V_CTL_MODE_AUTO_THROTTLE.
Referenced by navigation_task().
float desired_x |
Definition at line 318 of file nav.c.
Referenced by cam_segment_periodic(), formation_flight(), and potential_task().
float desired_y |
Definition at line 318 of file nav.c.
Referenced by cam_segment_periodic(), formation_flight(), and potential_task().
|
static |
float flight_altitude |
Dynamically adjustable, reset to nav_altitude when it is changing.
Definition at line 73 of file nav.c.
Referenced by formation_flight(), and nav_set_altitude().
uint8_t horizontal_mode |
Definition at line 69 of file nav.c.
Referenced by guidance_h_run(), mission_nav_circle(), mission_nav_path(), mission_nav_segment(), mission_nav_wp(), nav_survey_poly_run(), nav_survey_rectangle_rotorcraft_run(), and nav_survey_rectangle_rotorcraft_setup().
|
static |
float last_x |
Definition at line 43 of file nav.c.
Referenced by nav_init_stage(), and nav_survey_polygon_run().
float last_y |
Definition at line 43 of file nav.c.
Referenced by nav_init_stage(), and nav_survey_polygon_run().
float nav_altitude = GROUND_ALT + MIN_HEIGHT_CARROT |
Definition at line 317 of file nav.c.
Referenced by formation_flight(), nav_set_altitude(), start_formation(), stop_formation(), and tcas_periodic_task_4Hz().
float nav_circle_radius |
Definition at line 67 of file nav.c.
Referenced by flight_benchmark_periodic().
float nav_circle_trigo_qdr |
Definition at line 54 of file nav.c.
Referenced by nav_circle_XY().
float nav_circle_x |
Definition at line 67 of file nav.c.
Referenced by flight_benchmark_periodic().
float nav_circle_y |
Definition at line 67 of file nav.c.
Referenced by flight_benchmark_periodic().
float nav_climb |
Definition at line 55 of file nav.c.
Referenced by guidance_v_run().
bool_t nav_in_circle = FALSE |
Definition at line 65 of file nav.c.
Referenced by nav_survey_rectangle().
bool_t nav_in_segment = FALSE |
Definition at line 66 of file nav.c.
Referenced by nav_survey_rectangle().
|
static |
uint8_t nav_oval_count |
Navigation along a figure O.
One side leg is defined by waypoints [p1] and [p2]. The navigation goes through 4 states: OC1 (half circle next to [p1]), OR21 (route [p2] to [p1], OC2 (half circle next to [p2]) and OR12 (opposite leg).
Initial state is the route along the desired segment (OC2).
float nav_pitch |
with INT32_ANGLE_FRAC
Definition at line 320 of file nav.c.
Referenced by attitude_loop(), guidance_h_run(), v_ctl_climb_auto_throttle_loop(), v_ctl_climb_loop(), and v_ctl_set_pitch().
float nav_radius |
Definition at line 55 of file nav.c.
Referenced by nav_compute_baseleg(), and nav_flower_run().
float nav_segment_x_1 |
Definition at line 68 of file nav.c.
Referenced by flight_benchmark_periodic().
float nav_segment_x_2 |
Definition at line 68 of file nav.c.
Referenced by flight_benchmark_periodic().
float nav_segment_y_1 |
Definition at line 68 of file nav.c.
Referenced by flight_benchmark_periodic().
float nav_segment_y_2 |
Definition at line 68 of file nav.c.
Referenced by flight_benchmark_periodic().
float nav_shift |
Definition at line 55 of file nav.c.
Referenced by nav_circle_XY().
bool_t nav_survey_active |
Definition at line 87 of file nav.c.
Referenced by nav_survey_rectangle(), nav_survey_rectangle_rotorcraft_run(), and send_survey().
float nav_survey_east |
Definition at line 86 of file nav.c.
Referenced by nav_survey_rectangle(), and nav_survey_rectangle_init().
float nav_survey_north |
Definition at line 86 of file nav.c.
Referenced by nav_survey_rectangle(), and nav_survey_rectangle_init().
float nav_survey_shift |
Definition at line 85 of file nav.c.
Referenced by nav_survey_disc_run(), nav_survey_disc_setup(), nav_survey_rectangle(), and nav_survey_rectangle_init().
float nav_survey_south |
Definition at line 86 of file nav.c.
Referenced by nav_survey_rectangle(), and nav_survey_rectangle_init().
float nav_survey_west |
Definition at line 86 of file nav.c.
Referenced by nav_survey_rectangle(), and nav_survey_rectangle_init().
pprz_t nav_throttle_setpoint |
Definition at line 319 of file nav.c.
Referenced by attitude_loop().
enum oval_status oval_status |
|
static |
Definition at line 204 of file nav.c.
Referenced by send_ppm(), sim_init(), sim_monitor_task(), sim_nav_task(), sim_periodic_task(), and sim_sys_time_task().