|
|
|
@ -243,7 +243,7 @@ output_yaw_with_hold(boolean hold)
@@ -243,7 +243,7 @@ output_yaw_with_hold(boolean hold)
|
|
|
|
|
yaw_error = constrain(yaw_error, -4000, 4000); // limit error to 60 degees |
|
|
|
|
|
|
|
|
|
// Apply PID and save the new angle back to RC_Channel |
|
|
|
|
g.rc_4.servo_out = g.pid_yaw.get_pid(yaw_error, delta_ms_fast_loop, 1.0); // .4 * 4000 = 1600 |
|
|
|
|
g.rc_4.servo_out = g.pid_yaw.get_pi(yaw_error, delta_ms_fast_loop, 1.0); // .4 * 4000 = 1600 |
|
|
|
|
|
|
|
|
|
// add in yaw dampener |
|
|
|
|
g.rc_4.servo_out -= constrain(dampener, -1600, 1600); |
|
|
|
@ -277,19 +277,15 @@ output_yaw_with_hold(boolean hold)
@@ -277,19 +277,15 @@ output_yaw_with_hold(boolean hold)
|
|
|
|
|
void |
|
|
|
|
output_yaw_with_hold(boolean hold) |
|
|
|
|
{ |
|
|
|
|
long rate = degrees(omega.z) * 100; // 3rad = 17188 , 6rad = 34377 |
|
|
|
|
rate = constrain(rate, -36000, 36000); // limit to something fun! |
|
|
|
|
int dampener = rate * g.pid_yaw.kD(); // 34377 * .175 = 6000 |
|
|
|
|
|
|
|
|
|
// re-define nav_yaw if we have stick input |
|
|
|
|
if(g.rc_4.control_in != 0){ |
|
|
|
|
// set nav_yaw + or - the current location |
|
|
|
|
nav_yaw = (long)g.rc_4.control_in + dcm.yaw_sensor; |
|
|
|
|
|
|
|
|
|
// we need to wrap our value so we can be 0 to 360 (*100) |
|
|
|
|
nav_yaw = wrap_360(nav_yaw); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// we need to wrap our value so we can be 0 to 360 (*100) |
|
|
|
|
nav_yaw = wrap_360(nav_yaw); |
|
|
|
|
|
|
|
|
|
// how far off is nav_yaw from our current yaw? |
|
|
|
|
yaw_error = nav_yaw - dcm.yaw_sensor; |
|
|
|
|
|
|
|
|
@ -297,13 +293,13 @@ output_yaw_with_hold(boolean hold)
@@ -297,13 +293,13 @@ output_yaw_with_hold(boolean hold)
|
|
|
|
|
yaw_error = wrap_180(yaw_error); |
|
|
|
|
|
|
|
|
|
// limit the error we're feeding to the PID |
|
|
|
|
yaw_error = constrain(yaw_error, -4000, 4000); // limit error to 60 degees |
|
|
|
|
yaw_error = constrain(yaw_error, -3500, 3500); // limit error to 60 degees |
|
|
|
|
|
|
|
|
|
// Apply PID and save the new angle back to RC_Channel |
|
|
|
|
g.rc_4.servo_out = g.pid_yaw.get_pid(yaw_error, delta_ms_fast_loop, 1.0); // .4 * 4000 = 1600 |
|
|
|
|
g.rc_4.servo_out = g.pid_yaw.get_pi(yaw_error, delta_ms_fast_loop, 1.0); // .4 * 4000 = 1600 |
|
|
|
|
|
|
|
|
|
// add in yaw dampener |
|
|
|
|
g.rc_4.servo_out -= constrain(dampener, -1600, 1600); |
|
|
|
|
yaw_debug = YAW_HOLD; //0 |
|
|
|
|
g.rc_4.servo_out -= degrees(omega.z) * 100 * g.pid_yaw.kD(); |
|
|
|
|
yaw_error = constrain(yaw_error, -2500, 2500); // limit error to 60 degees |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|