 |
Paparazzi UAS
v6.1.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
46 #ifndef NAVIGATION_FREQUENCY
47 #define NAVIGATION_FREQUENCY 20
50 #define NAV_GRAVITY 9.806
51 #define Square(_x) ((_x)*(_x))
52 #define DistanceSquare(p1_x, p1_y, p2_x, p2_y) (Square(p1_x-p2_x)+Square(p1_y-p2_y))
54 #define PowerVoltage() (ap_electrical.vsupply)
55 #define RcRoll(travel) (imcu_get_radio(RADIO_ROLL) * (float)travel /(float)MAX_PPRZ)
85 #define NAV_MODE_ROLL 1
86 #define NAV_MODE_COURSE 2
90 #define HORIZONTAL_MODE_WAYPOINT 0
91 #define HORIZONTAL_MODE_ROUTE 1
92 #define HORIZONTAL_MODE_CIRCLE 2
96 #define NavGotoWaypoint(_wp) { \
97 horizontal_mode = HORIZONTAL_MODE_WAYPOINT; \
98 fly_to_xy(waypoints[_wp].x, waypoints[_wp].y); \
104 #define Eight(a, b, c) nav_eight((a), (b), (c))
109 #define Oval(a, b, c) nav_oval((b), (a), (c))
135 #define RCLost() bit_is_set(imcu_get_status(), STATUS_RADIO_REALLY_LOST)
138 #define NavFollow(_ac_id, _distance, _height) nav_follow(_ac_id, _distance, _height)
141 #define NavGlide(_start_wp, _wp) nav_glide(_start_wp, _wp)
143 #define NavCircleWaypoint(wp, radius) \
144 nav_circle_XY(waypoints[wp].x, waypoints[wp].y, radius)
147 #define NormCourse(x) { \
148 uint8_t dont_loop_forever = 0; \
149 while (x < 0 && ++dont_loop_forever) x += 360; \
150 while (x >= 360 && ++dont_loop_forever) x -= 360; \
153 #define NavCircleCountNoRewind() (nav_circle_radians_no_rewind / (2*M_PI))
154 #define NavCircleCount() (fabs(nav_circle_radians) / (2*M_PI))
155 #define NavCircleQdr() ({ float qdr = DegOfRad(M_PI_2 - nav_circle_trigo_qdr); NormCourse(qdr); qdr; })
157 #define CloseDegAngles(_c1, _c2) ({ float _diff = _c1 - _c2; NormCourse(_diff); 350 < _diff || _diff < 10; })
160 #define NavQdrCloseTo(x) CloseDegAngles(x, NavCircleQdr())
162 #define NavCourseCloseTo(x) CloseDegAngles(x, DegOfRad(stateGetHorizontalSpeedDir_f()))
165 extern void nav_route_xy(
float last_wp_x,
float last_wp_y,
float wp_x,
float wp_y);
166 #define NavSegment(_start, _end) \
167 nav_route_xy(waypoints[_start].x, waypoints[_start].y, waypoints[_end].x, waypoints[_end].y)
170 #define NavApproaching(wp, time) nav_approaching_xy(waypoints[wp].x, waypoints[wp].y, last_x, last_y, time)
171 #define NavApproachingFrom(wp, from, time) nav_approaching_xy(waypoints[wp].x, waypoints[wp].y, waypoints[from].x, waypoints[from].y, time)
176 #define NavVerticalAutoThrottleMode(_pitch) { \
177 v_ctl_climb_mode = V_CTL_CLIMB_MODE_AUTO_THROTTLE; \
178 nav_pitch = _pitch; \
183 #define NavVerticalAutoPitchMode(_throttle) { \
184 v_ctl_climb_mode = V_CTL_CLIMB_MODE_AUTO_PITCH; \
185 nav_throttle_setpoint = _throttle; \
190 #define NavVerticalAltitudeMode(_alt, _pre_climb) { \
191 v_ctl_mode = V_CTL_MODE_AUTO_ALT; \
192 nav_altitude = _alt; \
193 v_ctl_altitude_pre_climb = _pre_climb; \
197 #define NavVerticalClimbMode(_climb) { \
198 v_ctl_mode = V_CTL_MODE_AUTO_CLIMB; \
199 v_ctl_climb_setpoint = _climb; \
203 #define NavVerticalThrottleMode(_throttle) { \
204 v_ctl_mode = V_CTL_MODE_AUTO_THROTTLE; \
205 nav_throttle_setpoint = _throttle; \
208 #define NavHeading(_course) { \
209 lateral_mode = LATERAL_MODE_COURSE; \
210 h_ctl_course_setpoint = _course; \
213 #define NavAttitude(_roll) { \
214 lateral_mode = LATERAL_MODE_ROLL; \
215 if(autopilot_get_mode() != AP_MODE_AUTO1) \
216 {h_ctl_roll_setpoint = _roll;} \
219 #define NavSetManual(_roll, _pitch, _yaw) _Pragma("GCC error \"Manual mode in flight plan for fixedwing is not available\"")
222 #define nav_IncreaseShift(x) { if (x==0) nav_shift = 0; else nav_shift += x; }
224 #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; }
226 #define NavKillThrottle() { autopilot_set_kill_throttle(true); }
229 #define GetPosX() (stateGetPositionEnu_f()->x)
230 #define GetPosY() (stateGetPositionEnu_f()->y)
232 #define GetPosAlt() (stateGetPositionUtm_f()->alt)
234 #define GetPosHeight() (stateGetPositionEnu_f()->z)
242 #define GetAltRef() (ground_alt)
245 #define SEND_NAVIGATION(_trans, _dev) { \
246 uint8_t _circle_count = NavCircleCount(); \
247 struct EnuCoor_f* pos = stateGetPositionEnu_f(); \
248 float dist_wp = sqrtf(dist2_to_wp); \
249 float dist_home = sqrtf(dist2_to_home); \
250 uint8_t kill = (uint8_t)autopilot.kill_throttle; \
251 pprz_msg_send_NAVIGATION(_trans, _dev, AC_ID, &nav_block, &nav_stage, &(pos->x), &(pos->y), &dist_wp, &dist_home, &autopilot.flight_time, &block_time, &stage_time, &kill, &_circle_count, &nav_oval_count); \
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
void nav_init(void)
Navigation Initialisation.
float nav_ground_speed_setpoint
float nav_ground_speed_pgain
void nav_oval(uint8_t, uint8_t, float)
Navigation along a figure O.
float nav_circle_radians
Status on the current circle.
float nav_pitch
with INT32_ANGLE_FRAC
void nav_compute_final_from_glide(uint8_t wp_af, uint8_t wp_td, float glide)
float flight_altitude
Dynamically adjustable, reset to nav_altitude when it is changing.
void nav_home(void)
Home mode navigation (circle around HOME)
uint8_t nav_oval_count
Navigation along a figure O.
void nav_eight(uint8_t, uint8_t, float)
Navigation along a figure 8.
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.
pprz_t nav_throttle_setpoint
void nav_follow(uint8_t _ac_id, float _distance, float _height)
void nav_without_gps(void)
Failsafe navigation without position estimation.
uint8_t last_wp
Index of last waypoint.
float nav_circle_trigo_qdr
bool 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.
void DownlinkSendWpNr(uint8_t _wp)
void nav_glide(uint8_t start_wp, uint8_t wp)
float nav_glide_pitch_trim
void nav_periodic_task(void)
Navigation main: call to the code generated from the XML flight plan.
void nav_eight_init(void)
float nav_circle_radians_no_rewind
void nav_compute_baseleg(uint8_t wp_af, uint8_t wp_td, uint8_t wp_baseleg, float radius)
void fly_to_xy(float x, float y)
Computes desired_x, desired_y and desired_course.
void nav_circle_XY(float x, float y, float radius)
Angle from center to mobile.