|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
53 #define HORIZONTAL_MODE_WAYPOINT 0
54 #define HORIZONTAL_MODE_ROUTE 1
55 #define HORIZONTAL_MODE_CIRCLE 2
56 #define HORIZONTAL_MODE_ATTITUDE 3
57 #define HORIZONTAL_MODE_MANUAL 4
73 #define VERTICAL_MODE_MANUAL 0
74 #define VERTICAL_MODE_CLIMB 1
75 #define VERTICAL_MODE_ALT 2
91 #define GetPosX() (stateGetPositionEnu_f()->x)
92 #define GetPosY() (stateGetPositionEnu_f()->y)
94 #define GetPosAlt() (stateGetPositionEnu_f()->z+state.ned_origin_f.hmsl)
102 #define GetAltRef() (state.ned_origin_f.hmsl)
106 #define NormCourse(x) { \
107 while (x < 0) x += 360; \
108 while (x >= 360) x -= 360; \
144 #define NavStartDetectGround() ({ autopilot.detect_ground_once = true; false; })
145 #define NavDetectGround() nav_detect_ground()
158 #define NavSetManual nav_set_manual
159 #define NavSetFailsafe nav_set_failsafe
162 #define NavSetGroundReferenceHere nav_reset_reference
163 #define NavSetAltitudeReferenceHere nav_reset_alt
165 #define NavSetWaypointHere waypoint_set_here_2d
166 #define NavCopyWaypoint waypoint_copy
167 #define NavCopyWaypointPositionOnly waypoint_position_copy
172 #define NavApproaching(wp, time) nav_approaching_from(&waypoints[wp].enu_i, NULL, time)
173 #define NavApproachingFrom(wp, from, time) nav_approaching_from(&waypoints[wp].enu_i, &waypoints[from].enu_i, time)
177 #define NavCheckWaypointTime(wp, time) nav_check_wp_time(&waypoints[wp].enu_i, time)
203 #define NavVerticalAutoThrottleMode(_pitch) { \
204 nav_pitch = ANGLE_BFP_OF_REAL(_pitch); \
209 #define NavVerticalAutoPitchMode(_throttle) {}
213 #define NavVerticalAltitudeMode(_alt, _pre_climb) { \
214 vertical_mode = VERTICAL_MODE_ALT; \
215 nav_altitude = POS_BFP_OF_REAL(_alt); \
219 #define NavVerticalClimbMode(_climb) { \
220 vertical_mode = VERTICAL_MODE_CLIMB; \
221 nav_climb = SPEED_BFP_OF_REAL(_climb); \
225 #define NavVerticalThrottleMode(_throttle) { \
226 vertical_mode = VERTICAL_MODE_MANUAL; \
227 nav_throttle = _throttle; \
231 #define NavHeading nav_set_heading_rad
233 #define NavAttitude(_roll) { \
234 horizontal_mode = HORIZONTAL_MODE_ATTITUDE; \
235 nav_roll = ANGLE_BFP_OF_REAL(_roll); \
260 #define NavCircleCount() ((float)abs(nav_circle_radians) / INT32_ANGLE_2_PI)
261 #define NavCircleQdr() ({ int32_t qdr = INT32_DEG_OF_RAD(INT32_ANGLE_PI_2 - nav_circle_qdr) >> INT32_ANGLE_FRAC; NormCourse(qdr); qdr; })
263 #define CloseDegAngles(_c1, _c2) ({ int32_t _diff = _c1 - _c2; NormCourse(_diff); 350 < _diff || _diff < 10; })
264 #define CloseRadAngles(_c1, _c2) ({ float _diff = _c1 - _c2; NormRadAngle(_diff); fabsf(_diff) < 0.0177; })
266 #define NavQdrCloseTo(x) CloseDegAngles(((x) >> INT32_ANGLE_FRAC), NavCircleQdr())
267 #define NavCourseCloseTo(x) {}
273 #define Oval(a, b, c) nav_oval((b), (a), (c))
278 #ifdef GUIDANCE_INDI_HYBRID
304 #define NavFollow nav_follow
312 #define nav_IncreaseShift(x) {}
313 #define nav_SetNavRadius(x) {}
314 #define navigation_SetFlightAltitude(x) { \
315 flight_altitude = x; \
316 nav_flight_altitude = POS_BFP_OF_REAL(flight_altitude - state.ned_origin_f.hmsl); \
struct FloatVect3 speed_sp
void nav_set_heading_towards_waypoint(uint8_t wp)
Set heading in the direction of a waypoint.
static void NavSegment(uint8_t wp_start, uint8_t wp_end)
struct FloatVect2 line_vect to_end_vect
struct FloatVect3 nav_get_speed_setpoint(float pos_gain)
function that returns a speed setpoint based on flight plan.
void nav_route(struct EnuCoor_i *wp_start, struct EnuCoor_i *wp_end)
static void NavGotoWaypointHeading(uint8_t wp)
#define HORIZONTAL_MODE_ROUTE
#define HORIZONTAL_MODE_CIRCLE
int32_t nav_flight_altitude
int32_t nav_circle_radians
Status on the current circle.
struct EnuCoor_i navigation_target
void nav_home(void)
Home mode navigation (circle around HOME)
bool nav_detect_ground(void)
void set_exception_flag(uint8_t flag_num)
Paparazzi fixed point math for geodetic calculations.
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
uint8_t nav_oval_count
Navigation along a figure O.
#define POS_FLOAT_OF_BFP(_ai)
uint32_t nav_throttle
direct throttle from 0:MAX_PPRZ, used in VERTICAL_MODE_MANUAL
struct EnuCoor_i navigation_carrot
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
struct FloatVect3 nav_get_speed_sp_from_go(struct EnuCoor_i target, float pos_gain)
Go to a waypoint in the shortest way.
void navigation_update_wp_from_speed(uint8_t wp, struct Int16Vect3 speed_sp, int16_t heading_rate_sp)
void nav_init(void)
Navigation Initialisation.
#define VECT2_DIFF(_c, _a, _b)
void nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
void nav_set_heading_rad(float rad)
Set nav_heading in radians.
float get_dist2_to_point(struct EnuCoor_i *p)
Returns squared horizontal distance to given point.
uint8_t last_wp
Index of last waypoint.
void nav_set_heading_current(void)
Set heading to the current yaw angle.
void nav_set_manual(int32_t roll, int32_t pitch, int32_t yaw)
Set manual roll, pitch and yaw without stabilization.
bool nav_approaching_from(struct EnuCoor_i *wp, struct EnuCoor_i *from, int16_t approaching_time)
Proximity tests on approaching a wp.
float flight_altitude
Dynamically adjustable, reset to nav_altitude when it is changing.
float failsafe_mode_dist2
maximum squared distance to home wp before going to failsafe mode
static void NavCircleWaypoint(uint8_t wp_center, float radius)
float get_dist2_to_waypoint(uint8_t wp_id)
Returns squared horizontal distance to given waypoint.
static void NavGlide(uint8_t start_wp, uint8_t wp)
Nav glide routine.
struct FloatVect3 nav_get_speed_sp_from_line(struct FloatVect2 line_v, struct FloatVect2 to_end_v, struct EnuCoor_i target, float pos_gain)
follow a line.
void nav_set_heading_towards_target(void)
Set heading in the direction of the target.
void autopilot_set_motors_on(bool motors_on)
turn motors on/off, eventually depending of the current mode set kill_throttle accordingly FIXME is i...
float dist2_to_home
squared distance to home waypoint
void nav_reset_alt(void)
Reset the altitude reference to the current GPS alt.
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
void nav_circle(struct EnuCoor_i *wp_center, int32_t radius)
void nav_follow(uint8_t _ac_id, uint32_t distance, uint32_t height)
void nav_oval(uint8_t, uint8_t, float)
Navigation along a figure O.
#define VERTICAL_MODE_ALT
bool nav_is_in_flight(void)
void nav_periodic_task(void)
Navigation main: call to the code generated from the XML flight plan.
static void NavKillThrottle(void)
int32_t nav_heading
with INT32_ANGLE_FRAC
static void NavGotoWaypoint(uint8_t wp)
static void NavResurrect(void)
int32_t nav_pitch
with INT32_ANGLE_FRAC
#define HORIZONTAL_MODE_WAYPOINT
#define POS_BFP_OF_REAL(_af)
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
void nav_set_heading_deg(float deg)
Set nav_heading in degrees.
#define NavVerticalAltitudeMode(_alt, _pre_climb)
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
uint8_t autopilot_get_mode(void)
get autopilot mode
float dist2_to_wp
squared distance to next waypoint
int32_t nav_circle_radius
void nav_set_heading_towards(float x, float y)
Set heading to point towards x,y position in local coordinates.
void nav_set_failsafe(void)
vector in East North Up coordinates
#define VECT3_COPY(_a, _b)