Browse Source

Plane: added local reached_loiter_target()

this distinguishes between VTOL and fixed wing loiter targets
master
Andrew Tridgell 9 years ago
parent
commit
691d4b6ca7
  1. 2
      ArduPlane/ArduPlane.cpp
  2. 1
      ArduPlane/Plane.h
  3. 4
      ArduPlane/altitude.cpp
  4. 9
      ArduPlane/commands_logic.cpp
  5. 15
      ArduPlane/navigation.cpp

2
ArduPlane/ArduPlane.cpp

@ -761,7 +761,7 @@ void Plane::update_navigation()
break; break;
} else if (g.rtl_autoland == 1 && } else if (g.rtl_autoland == 1 &&
!auto_state.checked_for_autoland && !auto_state.checked_for_autoland &&
nav_controller->reached_loiter_target() && reached_loiter_target() &&
labs(altitude_error_cm) < 1000) { labs(altitude_error_cm) < 1000) {
// we've reached the RTL point, see if we have a landing sequence // we've reached the RTL point, see if we have a landing sequence
jump_to_landing_sequence(); jump_to_landing_sequence();

1
ArduPlane/Plane.h

@ -892,6 +892,7 @@ private:
void update_cruise(); void update_cruise();
void update_fbwb_speed_height(void); void update_fbwb_speed_height(void);
void setup_turn_angle(void); void setup_turn_angle(void);
bool reached_loiter_target(void);
bool print_buffer(char *&buf, uint16_t &buf_size, const char *fmt, ...); bool print_buffer(char *&buf, uint16_t &buf_size, const char *fmt, ...);
uint16_t create_mixer(char *buf, uint16_t buf_size, const char *filename); uint16_t create_mixer(char *buf, uint16_t buf_size, const char *filename);
bool setup_failsafe_mixing(void); bool setup_failsafe_mixing(void);

4
ArduPlane/altitude.cpp

@ -37,7 +37,7 @@ void Plane::adjust_altitude_target()
} else if (flight_stage == AP_SpdHgtControl::FLIGHT_LAND_APPROACH || } else if (flight_stage == AP_SpdHgtControl::FLIGHT_LAND_APPROACH ||
flight_stage == AP_SpdHgtControl::FLIGHT_LAND_PREFLARE) { flight_stage == AP_SpdHgtControl::FLIGHT_LAND_PREFLARE) {
setup_landing_glide_slope(); setup_landing_glide_slope();
} else if (nav_controller->reached_loiter_target()) { } else if (reached_loiter_target()) {
// once we reach a loiter target then lock to the final // once we reach a loiter target then lock to the final
// altitude target // altitude target
set_target_altitude_location(next_WP_loc); set_target_altitude_location(next_WP_loc);
@ -490,7 +490,7 @@ float Plane::lookahead_adjustment(void)
// there is no target waypoint in FBWB, so use yaw as an approximation // there is no target waypoint in FBWB, so use yaw as an approximation
bearing_cd = ahrs.yaw_sensor; bearing_cd = ahrs.yaw_sensor;
distance = g.terrain_lookahead; distance = g.terrain_lookahead;
} else if (!nav_controller->reached_loiter_target()) { } else if (!reached_loiter_target()) {
bearing_cd = nav_controller->target_bearing_cd(); bearing_cd = nav_controller->target_bearing_cd();
distance = constrain_float(auto_state.wp_distance, 0, g.terrain_lookahead); distance = constrain_float(auto_state.wp_distance, 0, g.terrain_lookahead);
} else { } else {

9
ArduPlane/commands_logic.cpp

@ -618,7 +618,7 @@ bool Plane::verify_loiter_time()
update_loiter(0); update_loiter(0);
if (loiter.start_time_ms == 0) { if (loiter.start_time_ms == 0) {
if (nav_controller->reached_loiter_target() && loiter.sum_cd > 1) { if (reached_loiter_target() && loiter.sum_cd > 1) {
// we've reached the target, start the timer // we've reached the target, start the timer
loiter.start_time_ms = millis(); loiter.start_time_ms = millis();
} }
@ -702,7 +702,7 @@ bool Plane::verify_RTL()
} }
update_loiter(abs(g.rtl_radius)); update_loiter(abs(g.rtl_radius));
if (auto_state.wp_distance <= (uint32_t)MAX(g.waypoint_radius,0) || if (auto_state.wp_distance <= (uint32_t)MAX(g.waypoint_radius,0) ||
nav_controller->reached_loiter_target()) { reached_loiter_target()) {
gcs_send_text(MAV_SEVERITY_INFO,"Reached HOME"); gcs_send_text(MAV_SEVERITY_INFO,"Reached HOME");
return true; return true;
} else { } else {
@ -975,6 +975,11 @@ void Plane::exit_mission_callback()
bool Plane::verify_loiter_heading(bool init) bool Plane::verify_loiter_heading(bool init)
{ {
if (quadplane.in_vtol_auto()) {
// skip heading verify if in VTOL auto
return true;
}
//Get the lat/lon of next Nav waypoint after this one: //Get the lat/lon of next Nav waypoint after this one:
AP_Mission::Mission_Command next_nav_cmd; AP_Mission::Mission_Command next_nav_cmd;
if (! mission.get_next_nav_cmd(mission.get_current_nav_index() + 1, if (! mission.get_next_nav_cmd(mission.get_current_nav_index() + 1,

15
ArduPlane/navigation.cpp

@ -34,7 +34,7 @@ void Plane::loiter_angle_update(void)
{ {
int32_t target_bearing_cd = nav_controller->target_bearing_cd(); int32_t target_bearing_cd = nav_controller->target_bearing_cd();
int32_t loiter_delta_cd; int32_t loiter_delta_cd;
if (loiter.sum_cd == 0 && !nav_controller->reached_loiter_target()) { if (loiter.sum_cd == 0 && !reached_loiter_target()) {
// we don't start summing until we are doing the real loiter // we don't start summing until we are doing the real loiter
loiter_delta_cd = 0; loiter_delta_cd = 0;
} else if (loiter.sum_cd == 0) { } else if (loiter.sum_cd == 0) {
@ -188,7 +188,7 @@ void Plane::update_loiter(uint16_t radius)
} }
if (loiter.start_time_ms == 0) { if (loiter.start_time_ms == 0) {
if (nav_controller->reached_loiter_target() || if (reached_loiter_target() ||
auto_state.wp_proportion > 1) { auto_state.wp_proportion > 1) {
// we've reached the target, start the timer // we've reached the target, start the timer
loiter.start_time_ms = millis(); loiter.start_time_ms = millis();
@ -291,3 +291,14 @@ void Plane::setup_turn_angle(void)
} }
} }
/*
see if we have reached our loiter target
*/
bool Plane::reached_loiter_target(void)
{
if (quadplane.in_vtol_auto()) {
return auto_state.wp_distance < 3;
}
return nav_controller->reached_loiter_target();
}

Loading…
Cancel
Save