mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 13:55:40 +08:00
*** empty log message ***
This commit is contained in:
+11
-16
@@ -105,7 +105,6 @@ float nav_glide_pitch_trim;
|
|||||||
|
|
||||||
static bool_t approaching(uint8_t, float) __attribute__ ((unused));
|
static bool_t approaching(uint8_t, float) __attribute__ ((unused));
|
||||||
static inline void fly_to_xy(float x, float y);
|
static inline void fly_to_xy(float x, float y);
|
||||||
static void fly_to(uint8_t wp) __attribute__ ((unused));
|
|
||||||
static void nav_route_xy(float last_wp_x, float last_wp_y, float wp_x, float wp_y);
|
static void nav_route_xy(float last_wp_x, float last_wp_y, float wp_x, float wp_y);
|
||||||
|
|
||||||
#define MIN_DX ((int16_t)(MAX_PPRZ * 0.05))
|
#define MIN_DX ((int16_t)(MAX_PPRZ * 0.05))
|
||||||
@@ -153,10 +152,16 @@ static inline void nav_circle_XY(float x, float y, float radius) {
|
|||||||
nav_circle_radius = radius;
|
nav_circle_radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NavCircle(wp, radius) \
|
|
||||||
|
#define NavGotoWaypoint(_wp) { \
|
||||||
|
horizontal_mode = HORIZONTAL_MODE_WAYPOINT; \
|
||||||
|
fly_to_xy(waypoints[_wp].x, waypoints[_wp].y); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NavCircleWaypoint(wp, radius) \
|
||||||
nav_circle_XY(waypoints[wp].x, waypoints[wp].y, radius)
|
nav_circle_XY(waypoints[wp].x, waypoints[wp].y, radius)
|
||||||
|
|
||||||
#define NavRoute(_start, _end) \
|
#define NavSegment(_start, _end) \
|
||||||
nav_route_xy(waypoints[_start].x, waypoints[_start].y, waypoints[_end].x, waypoints[_end].y)
|
nav_route_xy(waypoints[_start].x, waypoints[_start].y, waypoints[_end].x, waypoints[_end].y)
|
||||||
|
|
||||||
#define NavSurveyRectangleInit(_wp1, _wp2, _grid) nav_survey_rectangle_init(_wp1, _wp2, _grid)
|
#define NavSurveyRectangleInit(_wp1, _wp2, _grid) nav_survey_rectangle_init(_wp1, _wp2, _grid)
|
||||||
@@ -305,7 +310,7 @@ static inline void nav_survey_rectangle(uint8_t wp1, uint8_t wp2) {
|
|||||||
}
|
}
|
||||||
} else { /* U-turn */
|
} else { /* U-turn */
|
||||||
if (NavCircleCount() < 0.45) {
|
if (NavCircleCount() < 0.45) {
|
||||||
NavCircle(0, survey_radius);
|
NavCircleWaypoint(0, survey_radius);
|
||||||
} else {
|
} else {
|
||||||
/* U-turn finished, back on a segment */
|
/* U-turn finished, back on a segment */
|
||||||
survey_uturn = FALSE;
|
survey_uturn = FALSE;
|
||||||
@@ -375,9 +380,6 @@ static unit_t nav_update_waypoints_alt( void ) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MIN_DIST2_WP (15.*15.)
|
|
||||||
|
|
||||||
|
|
||||||
int32_t nav_utm_east0 = NAV_UTM_EAST0;
|
int32_t nav_utm_east0 = NAV_UTM_EAST0;
|
||||||
int32_t nav_utm_north0 = NAV_UTM_NORTH0;
|
int32_t nav_utm_north0 = NAV_UTM_NORTH0;
|
||||||
uint8_t nav_utm_zone0 = NAV_UTM_ZONE0;
|
uint8_t nav_utm_zone0 = NAV_UTM_ZONE0;
|
||||||
@@ -432,13 +434,6 @@ static inline void fly_to_xy(float x, float y) {
|
|||||||
h_ctl_course_setpoint = M_PI/2.-atan2(y - estimator_y, x - estimator_x);
|
h_ctl_course_setpoint = M_PI/2.-atan2(y - estimator_y, x - estimator_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** static void fly_to(uint8_t wp)
|
|
||||||
* \brief Just call \a fly_to_xy with x and y of current waypoint.
|
|
||||||
*/
|
|
||||||
static void fly_to(uint8_t wp) {
|
|
||||||
horizontal_mode = HORIZONTAL_MODE_WAYPOINT;
|
|
||||||
fly_to_xy(waypoints[wp].x, waypoints[wp].y);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nav_route_xy(float last_wp_x, float last_wp_y, float wp_x, float wp_y) {
|
static void nav_route_xy(float last_wp_x, float last_wp_y, float wp_x, float wp_y) {
|
||||||
float leg_x = wp_x - last_wp_x;
|
float leg_x = wp_x - last_wp_x;
|
||||||
@@ -484,7 +479,7 @@ static inline void compute_dist2_to_home(void) {
|
|||||||
/** \brief Occurs when it switchs in Home mode.
|
/** \brief Occurs when it switchs in Home mode.
|
||||||
*/
|
*/
|
||||||
void nav_home(void) {
|
void nav_home(void) {
|
||||||
NavCircle(WP_HOME, FAILSAFE_HOME_RADIUS);
|
NavCircleWaypoint(WP_HOME, FAILSAFE_HOME_RADIUS);
|
||||||
/** Nominal speed */
|
/** Nominal speed */
|
||||||
nav_pitch = 0.;
|
nav_pitch = 0.;
|
||||||
v_ctl_mode = V_CTL_MODE_AUTO_ALT;
|
v_ctl_mode = V_CTL_MODE_AUTO_ALT;
|
||||||
@@ -610,7 +605,7 @@ void nav_eight(uint8_t target, uint8_t c1, float radius) {
|
|||||||
|
|
||||||
switch (eight_status) {
|
switch (eight_status) {
|
||||||
case C1 :
|
case C1 :
|
||||||
NavCircle(c1, radius);
|
NavCircleWaypoint(c1, radius);
|
||||||
if (NavQdrCloseTo(DegOfRad(qdr_out)-10)) {
|
if (NavQdrCloseTo(DegOfRad(qdr_out)-10)) {
|
||||||
eight_status = R12;
|
eight_status = R12;
|
||||||
InitStage();
|
InitStage();
|
||||||
|
|||||||
+4
-2
@@ -45,6 +45,10 @@ struct point {
|
|||||||
float a;
|
float a;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define WaypointX(_wp) (waypoints[_wp].x)
|
||||||
|
#define WaypointY(_wp) (waypoints[_wp].y)
|
||||||
|
#define WaypointAlt(_wp) (waypoints[_wp].a)
|
||||||
|
|
||||||
extern float cur_pos_x;
|
extern float cur_pos_x;
|
||||||
extern float cur_pos_y;
|
extern float cur_pos_y;
|
||||||
extern uint8_t nav_stage, nav_block;
|
extern uint8_t nav_stage, nav_block;
|
||||||
@@ -57,8 +61,6 @@ extern uint8_t nav_utm_zone0;
|
|||||||
extern const uint8_t nb_waypoint;
|
extern const uint8_t nb_waypoint;
|
||||||
extern struct point waypoints[]; /** size == nb_waypoint + 1 */
|
extern struct point waypoints[]; /** size == nb_waypoint + 1 */
|
||||||
|
|
||||||
#define WaypointAlt(_wp) (waypoints[_wp].a)
|
|
||||||
|
|
||||||
extern float desired_x, desired_y, altitude_shift, nav_altitude, flight_altitude, nav_glide_pitch_trim;
|
extern float desired_x, desired_y, altitude_shift, nav_altitude, flight_altitude, nav_glide_pitch_trim;
|
||||||
|
|
||||||
extern pprz_t nav_throttle_setpoint;
|
extern pprz_t nav_throttle_setpoint;
|
||||||
|
|||||||
+6
-19
@@ -38,23 +38,10 @@ type state = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let earth_radius = 6378388.
|
|
||||||
|
|
||||||
let lat0 = ref 0.
|
|
||||||
let lon0 = ref 0.
|
|
||||||
let alt0 = ref 0.
|
|
||||||
|
|
||||||
let set_ref = fun wgs84 alt ->
|
|
||||||
lat0 := wgs84.posn_lat;
|
|
||||||
lon0 := wgs84.posn_long;
|
|
||||||
alt0 := alt
|
|
||||||
|
|
||||||
let climb_noise = fun c -> c +. Random.float 1.
|
let climb_noise = fun c -> c +. Random.float 1.
|
||||||
|
|
||||||
|
|
||||||
|
let state = fun pos0 alt0 ->
|
||||||
|
|
||||||
let state = fun () ->
|
|
||||||
let last_x = ref 0. and last_y = ref 0.
|
let last_x = ref 0. and last_y = ref 0.
|
||||||
and last_t = ref 0. and last_z = ref 0. in
|
and last_t = ref 0. and last_z = ref 0. in
|
||||||
|
|
||||||
@@ -66,9 +53,9 @@ let state = fun () ->
|
|||||||
and course = norm_angle (pi/.2. -. atan2 dy dx)
|
and course = norm_angle (pi/.2. -. atan2 dy dx)
|
||||||
and climb = (z -. !last_z) /. dt in
|
and climb = (z -. !last_z) /. dt in
|
||||||
|
|
||||||
(** FIXME, should be utm -> geo *)
|
let utm0 = utm_of WGS84 !pos0 in
|
||||||
let lat = !lat0 +. y /. earth_radius
|
let utm = utm_add utm0 (x, y) in
|
||||||
and long = !lon0 +. x /.earth_radius /. cos !lat0
|
let wgs84 = of_utm WGS84 utm
|
||||||
and alt = !alt0 +. z in
|
and alt = !alt0 +. z in
|
||||||
|
|
||||||
last_x := x;
|
last_x := x;
|
||||||
@@ -76,10 +63,10 @@ let state = fun () ->
|
|||||||
last_z := z;
|
last_z := z;
|
||||||
last_t := t;
|
last_t := t;
|
||||||
|
|
||||||
let course = if course < 0. then course +. 2. *. pi else course in (* ???? *)
|
let course = if course < 0. then course +. 2. *. pi else course in
|
||||||
|
|
||||||
{
|
{
|
||||||
wgs84 = { posn_lat=lat;posn_long=long };
|
wgs84 = wgs84;
|
||||||
alt = alt;
|
alt = alt;
|
||||||
time = t;
|
time = t;
|
||||||
climb = climb_noise climb;
|
climb = climb_noise climb;
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ type state = {
|
|||||||
gspeed : float;
|
gspeed : float;
|
||||||
course : float; (** North = 0 *)
|
course : float; (** North = 0 *)
|
||||||
}
|
}
|
||||||
val state : unit -> (float * float * float -> float -> state)
|
val state : Latlong.geographic ref -> float ref -> (float * float * float -> float -> state)
|
||||||
(** [state ()] Returns a function which must be called with
|
(** [state pos0 alt0] Returns a function which must be called with
|
||||||
an updated position [xyz] and time [t] *)
|
an updated position [xyz] and time [t] *)
|
||||||
|
|
||||||
val set_ref : Latlong.geographic -> float -> unit
|
|
||||||
|
|||||||
+1
-2
@@ -107,7 +107,7 @@ module Make(AircraftItl : AIRCRAFT_ITL) = struct
|
|||||||
|
|
||||||
let gps_period = 0.25 in
|
let gps_period = 0.25 in
|
||||||
|
|
||||||
let compute_gps_state = Gps.state () in
|
let compute_gps_state = Gps.state pos0 alt0 in
|
||||||
|
|
||||||
let initial_state = FM.init (pi/.2. -. qfu/.180.*.pi) in
|
let initial_state = FM.init (pi/.2. -. qfu/.180.*.pi) in
|
||||||
|
|
||||||
@@ -203,7 +203,6 @@ module Make(AircraftItl : AIRCRAFT_ITL) = struct
|
|||||||
in
|
in
|
||||||
|
|
||||||
let boot = fun () ->
|
let boot = fun () ->
|
||||||
Gps.set_ref !pos0 !alt0;
|
|
||||||
Aircraft.boot (time_scale:>value);
|
Aircraft.boot (time_scale:>value);
|
||||||
Stdlib.timer ~scale:time_scale fm_period fm_task;
|
Stdlib.timer ~scale:time_scale fm_period fm_task;
|
||||||
Stdlib.timer ~scale:time_scale ir_period ir_task;
|
Stdlib.timer ~scale:time_scale ir_period ir_task;
|
||||||
|
|||||||
@@ -206,13 +206,13 @@ let output_hmode x wp last_wp =
|
|||||||
"route" ->
|
"route" ->
|
||||||
if last_wp = "last_wp" then
|
if last_wp = "last_wp" then
|
||||||
fprintf stderr "WARNING: Deprecated use of 'route' using last waypoint in %s\n"(Xml.to_string x);
|
fprintf stderr "WARNING: Deprecated use of 'route' using last waypoint in %s\n"(Xml.to_string x);
|
||||||
lprintf "NavRoute(%s, %s);\n" last_wp wp
|
lprintf "NavSegment(%s, %s);\n" last_wp wp
|
||||||
| "direct" -> lprintf "fly_to(%s);\n" wp
|
| "direct" -> lprintf "NavGotoWaypoint(%s);\n" wp
|
||||||
| x -> failwith (sprintf "Unknown hmode '%s'" x)
|
| x -> failwith (sprintf "Unknown hmode '%s'" x)
|
||||||
end;
|
end;
|
||||||
hmode
|
hmode
|
||||||
with
|
with
|
||||||
ExtXml.Error _ -> lprintf "fly_to(%s);\n" wp; "direct" (* Default behaviour *)
|
ExtXml.Error _ -> lprintf "NavGotoWaypoint(%s);\n" wp; "direct" (* Default behaviour *)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ let rec print_stage = fun index_of_waypoints x ->
|
|||||||
ignore (output_vmode x wp "");
|
ignore (output_vmode x wp "");
|
||||||
with
|
with
|
||||||
Xml2h.Error _ ->
|
Xml2h.Error _ ->
|
||||||
lprintf "fly_to_xy(last_x, last_y);\n";
|
lprintf "NavGotoXY(last_x, last_y);\n";
|
||||||
ignore(output_vmode x "" "")
|
ignore(output_vmode x "" "")
|
||||||
end;
|
end;
|
||||||
lprintf "return;\n"
|
lprintf "return;\n"
|
||||||
@@ -381,7 +381,7 @@ let rec print_stage = fun index_of_waypoints x ->
|
|||||||
let wp = get_index_waypoint (ExtXml.attrib x "wp") index_of_waypoints in
|
let wp = get_index_waypoint (ExtXml.attrib x "wp") index_of_waypoints in
|
||||||
let r = parsed_attrib x "radius" in
|
let r = parsed_attrib x "radius" in
|
||||||
let _vmode = output_vmode x wp "" in
|
let _vmode = output_vmode x wp "" in
|
||||||
lprintf "NavCircle(%s, %s);\n" wp r;
|
lprintf "NavCircleWaypoint(%s, %s);\n" wp r;
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
let c = parsed_attrib x "until" in
|
let c = parsed_attrib x "until" in
|
||||||
|
|||||||
Reference in New Issue
Block a user