diff --git a/sw/airborne/common_nav.h b/sw/airborne/common_nav.h index ffc478217f..83aaa2f953 100644 --- a/sw/airborne/common_nav.h +++ b/sw/airborne/common_nav.h @@ -3,6 +3,7 @@ #include "std.h" +extern float max_dist_from_home; extern float dist2_to_home; extern float dist2_to_wp; extern bool_t too_far_from_home; @@ -17,6 +18,16 @@ struct point { #define WaypointY(_wp) (waypoints[_wp].y) #define WaypointAlt(_wp) (waypoints[_wp].a) +#define MoveWaypoint(_id, _ux, _uy, _a) { \ + if (_id < nb_waypoint) { \ + waypoints[_id].x = _ux - nav_utm_east0; \ + waypoints[_id].y = _uy - nav_utm_north0; \ + BoundAbs(waypoints[_id].x, max_dist_from_home); \ + BoundAbs(waypoints[_id].y, max_dist_from_home); \ + waypoints[_id].a = _a; \ + } \ +} + extern const uint8_t nb_waypoint; extern struct point waypoints[]; /** size == nb_waypoint, waypoint 0 is a dummy waypoint */ diff --git a/sw/airborne/nav.h b/sw/airborne/nav.h index 0ec82feac6..757cf1204c 100644 --- a/sw/airborne/nav.h +++ b/sw/airborne/nav.h @@ -66,16 +66,6 @@ extern uint8_t horizontal_mode; #define HORIZONTAL_MODE_ROUTE 1 #define HORIZONTAL_MODE_CIRCLE 2 -#define MoveWaypoint(_id, _ux, _uy, _a) { \ - if (_id < nb_waypoint) { \ - waypoints[_id].x = _ux - nav_utm_east0; \ - waypoints[_id].y = _uy - nav_utm_north0; \ - Bound(waypoints[_id].x, -MAX_DIST_FROM_HOME, MAX_DIST_FROM_HOME); \ - Bound(waypoints[_id].y, -MAX_DIST_FROM_HOME, MAX_DIST_FROM_HOME); \ - waypoints[_id].a = _a; \ - } \ -} - extern void nav_eight_init( void ); extern void nav_eight(uint8_t, uint8_t, float); #define Eight(a, b, c) nav_eight((a), (b), (c))