Paparazzi UAS
v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
|
Fixedwing Navigation library. More...
#include "std.h"
#include "paparazzi.h"
#include "state.h"
#include "subsystems/navigation/nav_survey_rectangle.h"
#include "subsystems/navigation/common_flight_plan.h"
#include "subsystems/navigation/common_nav.h"
Go to the source code of this file.
Macros | |
#define | NAV_GRAVITY 9.806 |
#define | Square(_x) ((_x)*(_x)) |
#define | DistanceSquare(p1_x, p1_y, p2_x, p2_y) (Square(p1_x-p2_x)+Square(p1_y-p2_y)) |
#define | NAV_MODE_ROLL 1 |
#define | NAV_MODE_COURSE 2 |
#define | HORIZONTAL_MODE_WAYPOINT 0 |
#define | HORIZONTAL_MODE_ROUTE 1 |
#define | HORIZONTAL_MODE_CIRCLE 2 |
#define | NavGotoWaypoint(_wp) |
#define | Eight(a, b, c) nav_eight((a), (b), (c)) |
#define | Oval(a, b, c) nav_oval((b), (a), (c)) |
#define | NavCircleWaypoint(wp, radius) nav_circle_XY(waypoints[wp].x, waypoints[wp].y, radius) |
#define | NormCourse(x) |
Normalize a degree angle between 0 and 359. More... | |
#define | NavCircleCountNoRewind() (nav_circle_radians_no_rewind / (2*M_PI)) |
#define | NavCircleCount() (fabs(nav_circle_radians) / (2*M_PI)) |
#define | NavCircleQdr() ({ float qdr = DegOfRad(M_PI_2 - nav_circle_trigo_qdr); NormCourse(qdr); qdr; }) |
#define | CloseDegAngles(_c1, _c2) ({ float _diff = _c1 - _c2; NormCourse(_diff); 350 < _diff || _diff < 10; }) |
#define | NavQdrCloseTo(x) CloseDegAngles(x, NavCircleQdr()) |
True if x (in degrees) is close to the current QDR (less than 10 degrees) More... | |
#define | NavCourseCloseTo(x) CloseDegAngles(x, DegOfRad(stateGetHorizontalSpeedDir_f())) |
#define | NavSegment(_start, _end) nav_route_xy(waypoints[_start].x, waypoints[_start].y, waypoints[_end].x, waypoints[_end].y) |
#define | NavApproaching(wp, time) nav_approaching_xy(waypoints[wp].x, waypoints[wp].y, last_x, last_y, time) |
#define | NavApproachingFrom(wp, from, time) nav_approaching_xy(waypoints[wp].x, waypoints[wp].y, waypoints[from].x, waypoints[from].y, time) |
#define | NavVerticalAutoThrottleMode(_pitch) |
Set the climb control to auto-throttle with the specified pitch pre-command. More... | |
#define | NavVerticalAutoPitchMode(_throttle) |
Set the climb control to auto-pitch with the specified throttle pre-command. More... | |
#define | NavVerticalAltitudeMode(_alt, _pre_climb) |
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command. More... | |
#define | NavVerticalClimbMode(_climb) |
Set the vertical mode to climb control with the specified climb setpoint. More... | |
#define | NavVerticalThrottleMode(_throttle) |
Set the vertical mode to fixed throttle with the specified setpoint. More... | |
#define | NavHeading(_course) |
#define | NavAttitude(_roll) |
#define | nav_IncreaseShift(x) { if (x==0) nav_shift = 0; else nav_shift += x; } |
#define | nav_SetNavRadius(x) { if (x==1) nav_radius = DEFAULT_CIRCLE_RADIUS; else if (x==-1) nav_radius = -DEFAULT_CIRCLE_RADIUS; else nav_radius = x; } |
#define | NavKillThrottle() { kill_throttle = 1; } |
#define | GetPosX() (stateGetPositionEnu_f()->x) |
#define | GetPosY() (stateGetPositionEnu_f()->y) |
#define | GetPosAlt() (stateGetPositionUtm_f()->alt) |
#define | GetAltRef() (ground_alt) |
Enumerations | |
enum | oval_status { OR12, OC2, OR21, OC1 } |
Functions | |
void | fly_to_xy (float x, float y) |
Computes desired_x, desired_y and desired_course. More... | |
void | nav_eight_init (void) |
void | nav_eight (uint8_t, uint8_t, float) |
Navigation along a figure 8. More... | |
void | nav_oval_init (void) |
void | nav_oval (uint8_t, uint8_t, float) |
void | nav_periodic_task (void) |
Navigation main: call to the code generated from the XML flight plan. More... | |
void | nav_home (void) |
Home mode navigation (circle around HOME) More... | |
void | nav_init (void) |
Periodic telemetry. More... | |
void | nav_without_gps (void) |
Failsafe navigation without position estimation. More... | |
void | nav_circle_XY (float x, float y, float radius) |
Angle from center to mobile. 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... | |
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... | |
Fixedwing Navigation library.
This collection of macros and functions is used by the C code generated from the XML flight plan.
Definition in file nav.h.
#define CloseDegAngles | ( | _c1, | |
_c2 | |||
) | ({ float _diff = _c1 - _c2; NormCourse(_diff); 350 < _diff || _diff < 10; }) |
Definition at line 46 of file nav.h.
Referenced by nav_circle_XY().
#define GetAltRef | ( | ) | (ground_alt) |
#define GetPosAlt | ( | ) | (stateGetPositionUtm_f()->alt) |
Definition at line 203 of file nav.h.
Referenced by max7456_periodic().
#define GetPosX | ( | ) | (stateGetPositionEnu_f()->x) |
#define GetPosY | ( | ) | (stateGetPositionEnu_f()->y) |
#define HORIZONTAL_MODE_CIRCLE 2 |
Definition at line 80 of file nav.h.
Referenced by mission_nav_circle(), nav_circle(), and nav_circle_XY().
#define HORIZONTAL_MODE_ROUTE 1 |
Definition at line 79 of file nav.h.
Referenced by mission_nav_path(), mission_nav_segment(), nav_route(), nav_route_xy(), nav_survey_poly_run(), nav_survey_rectangle_rotorcraft_run(), and nav_survey_rectangle_rotorcraft_setup().
#define HORIZONTAL_MODE_WAYPOINT 0 |
Definition at line 78 of file nav.h.
Referenced by mission_nav_wp(), nav_home(), nav_init(), and nav_init_stage().
#define NAV_GRAVITY 9.806 |
Definition at line 44 of file nav.h.
Referenced by nav_circle_XY().
#define NAV_MODE_COURSE 2 |
Definition at line 74 of file nav.h.
Referenced by fly_to_xy(), nav_circle_XY(), and nav_init().
#define nav_SetNavRadius | ( | x | ) | { if (x==1) nav_radius = DEFAULT_CIRCLE_RADIUS; else if (x==-1) nav_radius = -DEFAULT_CIRCLE_RADIUS; else nav_radius = x; } |
#define NavApproaching | ( | wp, | |
time | |||
) | nav_approaching_xy(waypoints[wp].x, waypoints[wp].y, last_x, last_y, time) |
Definition at line 146 of file nav.h.
Referenced by nav_anemotaxis().
#define NavApproachingFrom | ( | wp, | |
from, | |||
time | |||
) | nav_approaching_xy(waypoints[wp].x, waypoints[wp].y, waypoints[from].x, waypoints[from].y, time) |
Definition at line 147 of file nav.h.
Referenced by nav_line_border_run(), nav_line_run(), and nav_vertical_raster_run().
#define NavAttitude | ( | _roll | ) |
Definition at line 189 of file nav.h.
Referenced by nav_catapult_run().
#define NavCircleCount | ( | ) | (fabs(nav_circle_radians) / (2*M_PI)) |
Definition at line 130 of file nav.h.
Referenced by nav_line_osam_run(), and nav_survey_poly_osam_run().
#define NavCircleCountNoRewind | ( | ) | (nav_circle_radians_no_rewind / (2*M_PI)) |
Definition at line 129 of file nav.h.
Referenced by nav_survey_poly_osam_run().
#define NavCircleQdr | ( | ) | ({ float qdr = DegOfRad(M_PI_2 - nav_circle_trigo_qdr); NormCourse(qdr); qdr; }) |
#define NavCircleWaypoint | ( | wp, | |
radius | |||
) | nav_circle_XY(waypoints[wp].x, waypoints[wp].y, radius) |
Definition at line 119 of file nav.h.
Referenced by nav_anemotaxis(), nav_chemotaxis(), nav_eight(), nav_home(), nav_survey_losange_carto(), and nav_survey_rectangle().
#define NavCourseCloseTo | ( | x | ) | CloseDegAngles(x, DegOfRad(stateGetHorizontalSpeedDir_f())) |
Definition at line 138 of file nav.h.
Referenced by nav_survey_polygon_run(), nav_survey_rectangle(), and nav_survey_zamboni_run().
#define NavGotoWaypoint | ( | _wp | ) |
#define NavHeading | ( | _course | ) |
#define NavKillThrottle | ( | ) | { kill_throttle = 1; } |
#define NavQdrCloseTo | ( | x | ) | CloseDegAngles(x, NavCircleQdr()) |
True if x (in degrees) is close to the current QDR (less than 10 degrees)
Definition at line 136 of file nav.h.
Referenced by nav_anemotaxis(), nav_eight(), nav_line_border_run(), nav_line_osam_run(), nav_line_run(), nav_oval(), nav_survey_disc_run(), nav_survey_poly_osam_run(), nav_vertical_raster_run(), snav_circle1(), and snav_circle2().
#define NavSegment | ( | _start, | |
_end | |||
) | nav_route_xy(waypoints[_start].x, waypoints[_start].y, waypoints[_end].x, waypoints[_end].y) |
Definition at line 142 of file nav.h.
Referenced by gls_run(), nav_anemotaxis(), nav_line_border_run(), nav_line_run(), and nav_vertical_raster_run().
#define NavVerticalAltitudeMode | ( | _alt, | |
_pre_climb | |||
) |
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
Definition at line 166 of file nav.h.
Referenced by gls_run(), mission_nav_circle(), mission_nav_path(), mission_nav_segment(), mission_nav_wp(), nav_catapult_run(), nav_flower_run(), nav_follow(), nav_line_border_run(), nav_line_osam_run(), nav_line_run(), nav_spiral_run(), nav_survey_disc_run(), nav_survey_poly_osam_run(), nav_survey_poly_setup(), nav_survey_polygon_run(), nav_survey_polygon_setup(), nav_survey_rectangle(), nav_survey_rectangle_rotorcraft_setup(), nav_survey_zamboni_run(), nav_survey_zamboni_setup(), nav_vertical_raster_run(), snav_circle1(), snav_circle2(), snav_on_time(), and snav_route().
#define NavVerticalAutoPitchMode | ( | _throttle | ) |
Set the climb control to auto-pitch with the specified throttle pre-command.
#define NavVerticalAutoThrottleMode | ( | _pitch | ) |
Set the climb control to auto-throttle with the specified pitch pre-command.
Definition at line 152 of file nav.h.
Referenced by formation_flight(), gls_run(), mission_nav_circle(), mission_nav_path(), mission_nav_segment(), mission_nav_wp(), nav_bungee_takeoff_run(), nav_catapult_run(), nav_flower_run(), nav_follow(), nav_line_border_run(), nav_line_osam_run(), nav_line_run(), nav_spiral_run(), nav_survey_disc_run(), nav_survey_poly_osam_run(), nav_survey_polygon_run(), nav_survey_polygon_setup(), nav_survey_rectangle(), nav_survey_zamboni_run(), nav_survey_zamboni_setup(), nav_vertical_raster_run(), potential_task(), snav_circle1(), snav_circle2(), snav_on_time(), and snav_route().
#define NavVerticalClimbMode | ( | _climb | ) |
Set the vertical mode to climb control with the specified climb setpoint.
Definition at line 173 of file nav.h.
Referenced by potential_task().
#define NavVerticalThrottleMode | ( | _throttle | ) |
Set the vertical mode to fixed throttle with the specified setpoint.
Definition at line 179 of file nav.h.
Referenced by nav_bungee_takeoff_run(), nav_catapult_highrate_module(), and nav_catapult_run().
#define NormCourse | ( | x | ) |
#define Square | ( | _x | ) | ((_x)*(_x)) |
Definition at line 45 of file nav.h.
Referenced by monitor_task(), and nav_circle_XY().
enum oval_status |
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 | ||
) |
Angle from center to mobile.
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.
void nav_home | ( | void | ) |
void nav_init | ( | void | ) |
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 | ) |
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().
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 cur_pos_x |
float cur_pos_y |
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().
float flight_altitude |
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_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().
bool_t nav_in_circle |
Definition at line 65 of file nav.c.
Referenced by nav_survey_rectangle(), and nav_survey_rectangle_rotorcraft_run().
bool_t nav_in_segment |
Definition at line 66 of file nav.c.
Referenced by nav_survey_rectangle(), and nav_survey_rectangle_rotorcraft_run().
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_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().
float nav_survey_east |
Definition at line 86 of file nav.c.
Referenced by nav_survey_rectangle(), nav_survey_rectangle_init(), nav_survey_rectangle_rotorcraft_run(), and nav_survey_rectangle_rotorcraft_setup().
float nav_survey_north |
Definition at line 86 of file nav.c.
Referenced by nav_survey_rectangle(), nav_survey_rectangle_init(), nav_survey_rectangle_rotorcraft_run(), and nav_survey_rectangle_rotorcraft_setup().
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(), nav_survey_rectangle_init(), and nav_survey_rectangle_rotorcraft_run().
float nav_survey_south |
Definition at line 86 of file nav.c.
Referenced by nav_survey_rectangle(), nav_survey_rectangle_init(), nav_survey_rectangle_rotorcraft_run(), and nav_survey_rectangle_rotorcraft_setup().
float nav_survey_west |
Definition at line 86 of file nav.c.
Referenced by nav_survey_rectangle(), nav_survey_rectangle_init(), nav_survey_rectangle_rotorcraft_run(), and nav_survey_rectangle_rotorcraft_setup().
pprz_t nav_throttle_setpoint |
Definition at line 319 of file nav.c.
Referenced by attitude_loop().