more clean up

This commit is contained in:
Jimmy Johnson
2016-03-27 12:10:57 +02:00
committed by Lorenz Meier
parent 515882ac0e
commit dfc2d9b5e0
5 changed files with 8 additions and 10 deletions
@@ -770,8 +770,7 @@ bool set_nav_state(struct vehicle_status_s *status, const bool data_link_loss_en
if (status->engine_failure) { if (status->engine_failure) {
status->nav_state = vehicle_status_s::NAVIGATION_STATE_AUTO_LANDENGFAIL; status->nav_state = vehicle_status_s::NAVIGATION_STATE_AUTO_LANDENGFAIL;
} else if ((!status->condition_global_position_valid || } else if (!status->condition_global_position_valid) {
!status->condition_home_position_valid)) {
status->failsafe = true; status->failsafe = true;
if (status->condition_local_position_valid) { if (status->condition_local_position_valid) {
@@ -720,7 +720,6 @@ MulticopterPositionControl::reset_pos_sp()
// we have logic in the main function which chooses the velocity setpoint such that the attitude setpoint is // we have logic in the main function which chooses the velocity setpoint such that the attitude setpoint is
// continuous when switching into velocity controlled mode, therefore, we don't need to bother about resetting // continuous when switching into velocity controlled mode, therefore, we don't need to bother about resetting
// position in a special way. In position control mode the position will be reset anyway until the vehicle has reduced speed. // position in a special way. In position control mode the position will be reset anyway until the vehicle has reduced speed.
_pos_sp(0) = _pos(0); _pos_sp(0) = _pos(0);
_pos_sp(1) = _pos(1); _pos_sp(1) = _pos(1);
} }
@@ -1387,7 +1386,8 @@ MulticopterPositionControl::task_main()
/* make sure velocity setpoint is saturated in xy*/ /* make sure velocity setpoint is saturated in xy*/
float vel_norm_xy = sqrtf(_vel_sp(0) * _vel_sp(0) + _vel_sp(1) * _vel_sp(1)); float vel_norm_xy = sqrtf(_vel_sp(0) * _vel_sp(0) + _vel_sp(1) * _vel_sp(1));
if (_pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_FOLLOW_TARGET) { if (_pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_FOLLOW_TARGET &&
_pos_sp_triplet.current.velocity_valid) {
_vel_sp(0) = _pos_sp_triplet.current.vx; _vel_sp(0) = _pos_sp_triplet.current.vx;
_vel_sp(1) = _pos_sp_triplet.current.vy; _vel_sp(1) = _pos_sp_triplet.current.vy;
} else if (vel_norm_xy > _params.vel_max(0)) { } else if (vel_norm_xy > _params.vel_max(0)) {
+3 -3
View File
@@ -60,7 +60,7 @@ FollowTarget::FollowTarget(Navigator *navigator, const char *name) :
MissionBlock(navigator, name), MissionBlock(navigator, name),
_navigator(navigator), _navigator(navigator),
_param_min_alt(this, "MIS_TAKEOFF_ALT", false), _param_min_alt(this, "MIS_TAKEOFF_ALT", false),
_follow_target_state(ACSEND), _follow_target_state(ASCEND),
_follow_target_sub(-1), _follow_target_sub(-1),
_step_time_in_ms(0.0f), _step_time_in_ms(0.0f),
_previous_target_gps_pos_valid(false), _previous_target_gps_pos_valid(false),
@@ -85,7 +85,7 @@ void
FollowTarget::on_inactive() FollowTarget::on_inactive()
{ {
_previous_target_gps_pos_valid = false; _previous_target_gps_pos_valid = false;
_follow_target_state = ACSEND; _follow_target_state = ASCEND;
} }
void void
@@ -151,7 +151,7 @@ FollowTarget::on_active() {
} }
break; break;
} }
case ACSEND: case ASCEND:
{ {
// ascend to the minimum altitude // ascend to the minimum altitude
+1 -1
View File
@@ -66,7 +66,7 @@ private:
static constexpr float FF_K = .15f; static constexpr float FF_K = .15f;
enum FollowTargetState { enum FollowTargetState {
ACSEND, ASCEND,
TRACK_POSITION, TRACK_POSITION,
TRACK_VELOCITY, TRACK_VELOCITY,
TARGET_TIMEOUT TARGET_TIMEOUT
+1 -2
View File
@@ -228,7 +228,6 @@ MissionBlock::is_mission_item_reached()
/* Once the waypoint and yaw setpoint have been reached we can start the loiter time countdown */ /* Once the waypoint and yaw setpoint have been reached we can start the loiter time countdown */
if (_waypoint_position_reached && _waypoint_yaw_reached) { if (_waypoint_position_reached && _waypoint_yaw_reached) {
return true;
if (_time_first_inside_orbit == 0) { if (_time_first_inside_orbit == 0) {
_time_first_inside_orbit = now; _time_first_inside_orbit = now;
@@ -239,7 +238,7 @@ MissionBlock::is_mission_item_reached()
} }
/* check if the MAV was long enough inside the waypoint orbit */ /* check if the MAV was long enough inside the waypoint orbit */
if ((now - _time_first_inside_orbit >= (hrt_abstime)_mission_item.time_inside * 1e6f)) { if (now - _time_first_inside_orbit >= (hrt_abstime)_mission_item.time_inside * 1e6f) {
return true; return true;
} }
} }