43 #define CARROT_DIST 2.f
52 #ifndef DEFAULT_CIRCLE_RADIUS
53 #define DEFAULT_CIRCLE_RADIUS 6.0f
57 #ifndef ARRIVED_AT_WAYPOINT
58 #define ARRIVED_AT_WAYPOINT 3.0f
62 #ifndef FAILSAFE_MODE_DISTANCE
63 #define FAILSAFE_MODE_DISTANCE (1.2*MAX_DIST_FROM_HOME)
67 #define NAV_MODE_WAYPOINT 0
68 #define NAV_MODE_ROUTE 1
69 #define NAV_MODE_CIRCLE 2
70 #define NAV_MODE_HEADING 3
71 #define NAV_MODE_MANUAL 4
129 #define GetPosX() (stateGetPositionEnu_f()->x)
130 #define GetPosY() (stateGetPositionEnu_f()->y)
132 #define GetPosAlt() (stateGetPositionEnu_f()->z+state.ned_origin_f.hmsl)
140 #define GetAltRef() (state.ned_origin_f.hmsl)
144 #define NormCourse(x) { \
145 while (x < 0) x += 360; \
146 while (x >= 360) x -= 360; \
149 #define NormCourseRad(x) { \
150 while (x < 0) x += 2*M_PI; \
151 while (x >= 2*M_PI) x -= 2*M_PI; \
193 #define NavSetManual(_roll, _pitch, _yaw) _Pragma("GCC error \"Manual mode in flight plan for fixedwing is not available\"")
194 #define NavSetFailsafe nav_set_failsafe
196 #define NavSetGroundReferenceHere nav_reset_reference
197 #define NavSetAltitudeReferenceHere nav_reset_alt
199 #define NavSetWaypointHere waypoint_set_here_2d
200 #define NavCopyWaypoint waypoint_copy
201 #define NavCopyWaypointPositionOnly waypoint_position_copy
206 #define NavCheckWaypointTime(wp, time) nav_check_wp_time(&waypoints[wp].enu_f, time)
214 #define NavAttitude(_roll) { \
215 nav.mode = NAV_MODE_MANUAL; \
217 BoundAbs(nav.turn, 1.f); \
221 #define NavVerticalThrottleMode(_speed) { \
222 nav.speed = _speed; \
223 BoundAbs(nav.speed, 1.f); \
227 #define NavHeading nav_set_heading_rad
299 #define navigation_IncreaseShift(x) { if (x==0) nav.shift = 0; else nav.shift += x; }
301 #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; }
305 #define NavFollow nav_follow(_id, _dist, _height) {}
311 #define NavGlide(_start_wp, _wp) {}
312 #define NavVerticalAutoThrottleMode(_pitch) {}
313 #define NavVerticalAutoPitchMode(_throttle) {}
314 #define NavVerticalAltitudeMode(_alt, _pre_climb) {}
315 #define NavVerticalClimbMode(_climb) {}
static bool nav_approaching(struct EnuCoor_f *wp, struct EnuCoor_f *from, float approaching_time)
void nav_set_heading_rad(float rad)
Set nav_heading in radians.
static void NavResurrect(void)
float dist2_to_home
squared distance to home waypoint
uint8_t last_wp
Index of last waypoint.
struct RoverNavigation nav
vector in East North Up coordinates Units: meters
#define VECT3_COPY(_a, _b)
void nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
struct EnuCoor_f target
final target
static bool NavApproaching(uint8_t wp, float approaching_time)
void(* nav_rover_circle)(struct EnuCoor_f *wp_center, float radius)
void nav_circle(struct EnuCoor_i *wp_center, int32_t radius)
void(* nav_rover_goto)(struct EnuCoor_f *wp)
void(* nav_rover_route)(struct EnuCoor_f *wp_start, struct EnuCoor_f *wp_end)
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
void nav_register_goto_wp(nav_rover_goto nav_goto, nav_rover_route nav_route, nav_rover_approaching nav_approaching)
Registering functions.
General Navigation structure.
float speed
speed setpoint
float failsafe_mode_dist2
maximum squared distance to home wp before going to failsafe mode
static void NavSegment(uint8_t wp_start, uint8_t wp_end)
void nav_route(struct EnuCoor_i *wp_start, struct EnuCoor_i *wp_end)
void nav_periodic_task(void)
Navigation main: call to the code generated from the XML flight plan.
Paparazzi floating point math for geodetic calculations.
bool nav_is_in_flight(void)
void nav_set_heading_current(void)
Set heading to the current yaw angle.
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.
bool(* nav_rover_approaching)(struct EnuCoor_f *wp_to, struct EnuCoor_f *wp_from, float approaching_time)
static bool NavApproachingFrom(uint8_t to, uint8_t from, float approaching_time)
float radius
radius setpoint
float get_dist2_to_point(struct EnuCoor_i *p)
Returns squared horizontal distance to given point.
static void NavKillThrottle(void)
static void NavGotoWaypoint(uint8_t wp)
static void nav_goto(struct EnuCoor_f *wp)
Implement basic nav function.
#define NAV_MODE_WAYPOINT
Nav modes.
bool exception_flag[10]
array of flags that might be used in flight plans
void nav_oval(uint8_t, uint8_t, float)
Navigation along a figure O.
float shift
lateral shift (in meters)
void nav_set_heading_towards(float x, float y)
Set heading to point towards x,y position in local coordinates.
float heading
heading setpoint (in radians)
void set_exception_flag(uint8_t flag_num)
float turn
turn rate setpoint
Core autopilot interface common to all firmwares.
void nav_set_manual(int32_t roll, int32_t pitch, int32_t yaw)
Set manual roll, pitch and yaw without stabilization.
void nav_register_oval(nav_rover_oval_init nav_oval_init, nav_rover_oval nav_oval)
static void NavCircleWaypoint(uint8_t wp_center, float radius)
struct EnuCoor_f last_pos
last stage position
void(* nav_rover_oval_init)(void)
API to get/set the generic vehicle states.
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
void nav_home(void)
Home mode navigation (circle around HOME)
nav_rover_circle nav_circle
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...
Common flight_plan functions shared between fixedwing and rotorcraft.
void nav_register_circle(nav_rover_circle nav_circle)
nav_rover_approaching nav_approaching
void nav_set_heading_deg(float deg)
Set nav_heading in degrees.
bool too_far_from_home
too_far flag
void nav_init(void)
Navigation Initialisation.
void nav_set_failsafe(void)
nav_rover_oval_init nav_oval_init
static void Oval(uint8_t wp1, uint8_t wp2, float radius)
struct EnuCoor_f carrot
carrot position
nav_rover_route nav_route
float get_dist2_to_waypoint(uint8_t wp_id)
Returns squared horizontal distance to given waypoint.
void nav_set_heading_towards_target(void)
Set heading in the direction of the target.
void nav_set_heading_towards_waypoint(uint8_t wp)
Set heading in the direction of a waypoint.
uint8_t autopilot_get_mode(void)
get autopilot mode
void(* nav_rover_oval)(struct EnuCoor_f *wp1, struct EnuCoor_f *wp2, float radius)