fixed position tracking overshoot

This commit is contained in:
Jimmy Johnson
2016-03-27 12:10:57 +02:00
committed by Lorenz Meier
parent 142884bcd8
commit 3aaad68c76
5 changed files with 61 additions and 31 deletions
+15 -8
View File
@@ -101,8 +101,7 @@ void FollowTarget::pause()
{
math::Vector<3> vel(0, 0, 0);
_current_vel(0) = 0;
_current_vel(1) = 0;
_current_vel.zero();
set_loiter_item(&_mission_item, _param_min_alt.get());
@@ -172,14 +171,11 @@ void FollowTarget::on_active()
void FollowTarget::track_target_position()
{
set_follow_target_item(&_mission_item, _param_min_alt.get(), _current_target_motion, NAN);
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
// keep the current velocity updated
_current_vel(0) = _navigator->get_global_position()->vel_n;
_current_vel(1) = _navigator->get_global_position()->vel_e;
_current_vel = _target_vel;
}
void FollowTarget::track_target_velocity()
@@ -249,8 +245,7 @@ void FollowTarget::update_target_velocity()
// calculate distance the target has moved
map_projection_project(&target_ref, _current_target_motion.lat, _current_target_motion.lon, &(target_position(0)),
&(target_position(1)));
map_projection_project(&target_ref, _current_target_motion.lat, _current_target_motion.lon, &(target_position(0)), &(target_position(1)));
// update the average velocity of the target based on the position
@@ -279,6 +274,18 @@ void FollowTarget::update_position_sp(math::Vector<3> & vel)
pos_sp_triplet->previous.valid = true;
pos_sp_triplet->previous = pos_sp_triplet->current;
mission_item_to_position_setpoint(&_mission_item, &pos_sp_triplet->current);
switch(_follow_target_state) {
case TRACK_POSITION:
pos_sp_triplet->current.type = position_setpoint_s::SETPOINT_TYPE_FOLLOW_TARGET;
break;
case TRACK_VELOCITY:
pos_sp_triplet->current.type = position_setpoint_s::SETPOINT_TYPE_VELOCITY;
break;
default:
break;
}
pos_sp_triplet->current.vx = vel(0);
pos_sp_triplet->current.vy = vel(1);
pos_sp_triplet->current.velocity_valid = true;
+1 -1
View File
@@ -60,7 +60,7 @@ public:
private:
static constexpr int TARGET_TIMEOUT_S = 10;
static constexpr int TARGET_TIMEOUT_S = 5;
static constexpr int TARGET_ACCEPTANCE_RADIUS_M = 5;
static constexpr int INTERPOLATION_PNTS = 20;
static constexpr float FF_K = .15f;
+2 -2
View File
@@ -374,9 +374,9 @@ MissionBlock::mission_item_to_position_setpoint(const struct mission_item_s *ite
if(_navigator->get_vstatus()->is_vtol && _param_vtol_wv_loiter.get()){
sp->disable_mc_yaw_control = true;
}
break;
break;// get rid of this
case NAV_CMD_FOLLOW_TARGET:
sp->type = position_setpoint_s::SETPOINT_TYPE_FOLLOW_TARGET;
sp->type = position_setpoint_s::SETPOINT_TYPE_VELOCITY;
break;
default: