43 #define CARROT_DIST 2.f
47 #ifndef NAVIGATION_FREQUENCY
48 #if PERIODIC_FREQUENCY == 512
49 #define NAVIGATION_FREQUENCY 16
51 #define NAVIGATION_FREQUENCY 20
57 #ifndef DEFAULT_CIRCLE_RADIUS
58 #define DEFAULT_CIRCLE_RADIUS 6.0f
62 #ifndef ARRIVED_AT_WAYPOINT
63 #define ARRIVED_AT_WAYPOINT 3.0f
67 #ifndef FAILSAFE_MODE_DISTANCE
68 #define FAILSAFE_MODE_DISTANCE (1.2*MAX_DIST_FROM_HOME)
72 #define NAV_MODE_WAYPOINT 0
73 #define NAV_MODE_ROUTE 1
74 #define NAV_MODE_CIRCLE 2
75 #define NAV_MODE_HEADING 3
76 #define NAV_MODE_MANUAL 4
134 #define GetPosX() (stateGetPositionEnu_f()->x)
136 #define GetPosY() (stateGetPositionEnu_f()->y)
138 #define GetPosAlt() (stateGetPositionEnu_f()->z+state.ned_origin_f.hmsl)
140 #define GetPosHeight() (stateGetPositionEnu_f()->z)
147 #define GetAltRef() (state.ned_origin_f.hmsl)
151 #define NormCourse(x) { \
152 while (x < 0) x += 360; \
153 while (x >= 360) x -= 360; \
156 #define NormCourseRad(x) { \
157 while (x < 0) x += 2*M_PI; \
158 while (x >= 2*M_PI) x -= 2*M_PI; \
200 #define NavSetFailsafe nav_set_failsafe
202 #define NavSetGroundReferenceHere nav_reset_reference
203 #define NavSetAltitudeReferenceHere nav_reset_alt
205 #define NavSetWaypointHere waypoint_set_here_2d
206 #define NavCopyWaypoint waypoint_copy
207 #define NavCopyWaypointPositionOnly waypoint_position_copy
212 #define NavCheckWaypointTime(wp, time) nav_check_wp_time(&waypoints[wp].enu_f, time)
220 #define NavAttitude(_roll) { \
221 nav.mode = NAV_MODE_MANUAL; \
223 BoundAbs(nav.turn, 1.f); \
227 #define NavVerticalThrottleMode(_speed) { \
228 nav.speed = _speed; \
229 BoundAbs(nav.speed, 1.f); \
233 #define NavHeading nav_set_heading_rad
235 #define NavSetMaxSpeed(_speed) {}
306 #define navigation_IncreaseShift(x) { if (x==0) nav.shift = 0; else nav.shift += x; }
308 #define navigation_SetNavRadius(x) { if (x==1) nav.radius = DEFAULT_CIRCLE_RADIUS; else if (x==-1) nav.radius = -DEFAULT_CIRCLE_RADIUS; else nav.radius = x; }
312 #define NavFollow nav_follow(_id, _dist, _height) {}
318 #define NavGlide(_start_wp, _wp) {}
319 #define NavVerticalAutoThrottleMode(_pitch) {}
320 #define NavVerticalAutoPitchMode(_throttle) {}
321 #define NavVerticalAltitudeMode(_alt, _pre_climb) {}
322 #define NavVerticalClimbMode(_climb) {}
uint8_t autopilot_get_mode(void)
get autopilot mode
bool autopilot_set_motors_on(bool motors_on)
turn motors on/off, eventually depending of the current mode set kill_throttle accordingly FIXME is i...
Core autopilot interface common to all firmwares.
Common flight_plan functions shared between fixedwing and rotorcraft.
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
#define VECT3_COPY(_a, _b)
void nav_oval(uint8_t p1, uint8_t p2, float radius)
static void nav_goto(struct EnuCoor_f *wp)
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)
Paparazzi floating point math for geodetic calculations.
vector in East North Up coordinates Units: meters
void nav_home(void)
Home mode navigation (circle around HOME)
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_reset_alt(void)
Reset the altitude reference to the current GPS alt.
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)
Register functions.
navigation_approaching nav_approaching
void nav_parse_BLOCK(uint8_t *buf)
navigation_circle nav_circle
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.
navigation_oval_init nav_oval_init
void nav_set_heading_rad(float rad)
heading utility functions
void nav_set_heading_deg(float deg)
Set nav_heading in degrees.
navigation_route nav_route
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.
struct EnuCoor_f target
final target position (in meters)
void nav_set_failsafe(void)
float failsafe_mode_dist2
maximum squared distance to home wp before going to failsafe mode
float turn
turn rate setpoint
void(* nav_rover_oval_init)(void)
static void NavGotoWaypoint(uint8_t wp)
struct EnuCoor_f carrot
carrot position
float shift
lateral shift (in meters)
static void Oval(uint8_t wp1, uint8_t wp2, float radius)
float speed
speed setpoint
float dist2_to_home
squared distance to home waypoint
nav_rover_route nav_route
struct EnuCoor_f target
final target
bool too_far_from_home
too_far flag
void(* nav_rover_goto)(struct EnuCoor_f *wp)
void(* nav_rover_circle)(struct EnuCoor_f *wp_center, float radius)
static bool NavApproachingFrom(uint8_t to, uint8_t from, float approaching_time)
void nav_set_manual(float speed, float turn)
struct EnuCoor_f last_pos
last stage position
nav_rover_circle nav_circle
static void NavSegment(uint8_t wp_start, uint8_t wp_end)
static void nav_oval_init(void)
float heading
heading setpoint (in radians)
static void NavKillThrottle(void)
#define NAV_MODE_WAYPOINT
Nav modes.
static void NavResurrect(void)
nav_rover_oval_init nav_oval_init
static void NavCircleWaypoint(uint8_t wp_center, float radius)
void(* nav_rover_route)(struct EnuCoor_f *wp_start, struct EnuCoor_f *wp_end)
void(* nav_rover_oval)(struct EnuCoor_f *wp1, struct EnuCoor_f *wp2, float radius)
nav_rover_approaching nav_approaching
bool(* nav_rover_approaching)(struct EnuCoor_f *wp_to, struct EnuCoor_f *wp_from, float approaching_time)
bool exception_flag[10]
array of flags that might be used in flight plans
static bool NavApproaching(uint8_t wp, float approaching_time)
void set_exception_flag(uint8_t flag_num)
float radius
radius setpoint
General Navigation structure.
API to get/set the generic vehicle states.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.