|
|
|
@ -641,29 +641,47 @@ void Mode::land_run_horizontal_control()
@@ -641,29 +641,47 @@ void Mode::land_run_horizontal_control()
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// this variable will be updated if prec land target is in sight and pilot isn't trying to reposition the vehicle
|
|
|
|
|
bool doing_precision_landing = false; |
|
|
|
|
#if PRECISION_LANDING == ENABLED |
|
|
|
|
bool doing_precision_landing = !copter.ap.land_repo_active && copter.precland.target_acquired(); |
|
|
|
|
doing_precision_landing = !copter.ap.land_repo_active && copter.precland.target_acquired(); |
|
|
|
|
// run precision landing
|
|
|
|
|
if (doing_precision_landing) { |
|
|
|
|
Vector2f target_pos, target_vel_rel; |
|
|
|
|
Vector2f target_pos, target_vel; |
|
|
|
|
if (!copter.precland.get_target_position_cm(target_pos)) { |
|
|
|
|
target_pos = inertial_nav.get_position_xy_cm(); |
|
|
|
|
} |
|
|
|
|
if (!copter.precland.get_target_velocity_relative_cms(target_vel_rel)) { |
|
|
|
|
target_vel_rel = -inertial_nav.get_velocity_xy_cms(); |
|
|
|
|
// get the velocity of the target
|
|
|
|
|
copter.precland.get_target_velocity_cms(inertial_nav.get_velocity_xy_cms(), target_vel); |
|
|
|
|
|
|
|
|
|
Vector2f zero; |
|
|
|
|
Vector2p landing_pos = target_pos.topostype(); |
|
|
|
|
// target vel will remain zero if landing target is stationary
|
|
|
|
|
pos_control->input_pos_vel_accel_xy(landing_pos, target_vel, zero); |
|
|
|
|
// run pos controller
|
|
|
|
|
pos_control->update_xy_controller(); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (!doing_precision_landing) { |
|
|
|
|
if (copter.ap.prec_land_active) { |
|
|
|
|
// precland isn't active anymore but was active a while back
|
|
|
|
|
// lets run an init again
|
|
|
|
|
// set target to stopping point
|
|
|
|
|
Vector2f stopping_point; |
|
|
|
|
loiter_nav->get_stopping_point_xy(stopping_point); |
|
|
|
|
loiter_nav->init_target(stopping_point); |
|
|
|
|
} |
|
|
|
|
pos_control->set_pos_target_xy_cm(target_pos.x, target_pos.y); |
|
|
|
|
pos_control->override_vehicle_velocity_xy(-target_vel_rel); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
// process roll, pitch inputs
|
|
|
|
|
loiter_nav->set_pilot_desired_acceleration(target_roll, target_pitch); |
|
|
|
|
|
|
|
|
|
// process roll, pitch inputs
|
|
|
|
|
loiter_nav->set_pilot_desired_acceleration(target_roll, target_pitch); |
|
|
|
|
// run loiter controller
|
|
|
|
|
loiter_nav->update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// run loiter controller
|
|
|
|
|
loiter_nav->update(); |
|
|
|
|
copter.ap.prec_land_active = doing_precision_landing; |
|
|
|
|
|
|
|
|
|
Vector3f thrust_vector = loiter_nav->get_thrust_vector(); |
|
|
|
|
Vector3f thrust_vector = pos_control->get_thrust_vector(); |
|
|
|
|
|
|
|
|
|
if (g2.wp_navalt_min > 0) { |
|
|
|
|
// user has requested an altitude below which navigation
|
|
|
|
|