added separate reset for rate based nav. This allows Wind and throttle Iterms to avoid being cleared when moving between nav modes.


git-svn-id: https://arducopter.googlecode.com/svn/trunk@3257 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
jasonshort 2011-09-05 01:30:31 +00:00
parent 453c474481
commit 135dfd1fd4
3 changed files with 14 additions and 11 deletions

View File

@ -147,18 +147,23 @@ get_rate_yaw(long target_rate)
// Zeros out navigation Integrators if we are changing mode, have passed a waypoint, etc. // Zeros out navigation Integrators if we are changing mode, have passed a waypoint, etc.
// Keeps outdated data out of our calculations // Keeps outdated data out of our calculations
static void reset_nav_I(void) static void reset_hold_I(void)
{ {
g.pi_loiter_lat.reset_I(); g.pi_loiter_lat.reset_I();
g.pi_loiter_lat.reset_I(); g.pi_loiter_lat.reset_I();
g.pi_nav_lat.reset_I();
g.pi_nav_lon.reset_I();
g.pi_crosstrack.reset_I(); g.pi_crosstrack.reset_I();
g.pi_throttle.reset_I(); g.pi_throttle.reset_I();
} }
// Zeros out navigation Integrators if we are changing mode, have passed a waypoint, etc.
// Keeps outdated data out of our calculations
static void reset_nav_I(void)
{
g.pi_nav_lat.reset_I();
g.pi_nav_lon.reset_I();
}
/************************************************************* /*************************************************************
throttle control throttle control

View File

@ -33,9 +33,6 @@ static void failsafe_off_event()
// -------------------------------------------------------- // --------------------------------------------------------
reset_control_switch(); reset_control_switch();
// Reset control integrators
// ---------------------
//reset_nav_I();
}else if (g.throttle_fs_action == 1){ }else if (g.throttle_fs_action == 1){
// We're back in radio contact // We're back in radio contact

View File

@ -363,6 +363,7 @@ static void set_mode(byte mode)
// most modes do not calculate crosstrack correction // most modes do not calculate crosstrack correction
xtrack_enabled = false; xtrack_enabled = false;
reset_nav_I();
switch(control_mode) switch(control_mode)
{ {
@ -370,21 +371,21 @@ static void set_mode(byte mode)
yaw_mode = YAW_ACRO; yaw_mode = YAW_ACRO;
roll_pitch_mode = ROLL_PITCH_ACRO; roll_pitch_mode = ROLL_PITCH_ACRO;
throttle_mode = THROTTLE_MANUAL; throttle_mode = THROTTLE_MANUAL;
reset_nav_I(); reset_hold_I();
break; break;
case STABILIZE: case STABILIZE:
yaw_mode = YAW_HOLD; yaw_mode = YAW_HOLD;
roll_pitch_mode = ROLL_PITCH_STABLE; roll_pitch_mode = ROLL_PITCH_STABLE;
throttle_mode = THROTTLE_MANUAL; throttle_mode = THROTTLE_MANUAL;
reset_nav_I(); reset_hold_I();
break; break;
case SIMPLE: case SIMPLE:
yaw_mode = SIMPLE_YAW; yaw_mode = SIMPLE_YAW;
roll_pitch_mode = SIMPLE_RP; roll_pitch_mode = SIMPLE_RP;
throttle_mode = SIMPLE_THR; throttle_mode = SIMPLE_THR;
reset_nav_I(); reset_hold_I();
break; break;
case ALT_HOLD: case ALT_HOLD:
@ -396,7 +397,7 @@ static void set_mode(byte mode)
break; break;
case AUTO: case AUTO:
reset_nav_I(); reset_hold_I();
yaw_mode = AUTO_YAW; yaw_mode = AUTO_YAW;
roll_pitch_mode = AUTO_RP; roll_pitch_mode = AUTO_RP;
throttle_mode = AUTO_THR; throttle_mode = AUTO_THR;