View Single Post
  #7   Spotlight this post!  
Unread 03-08-2016, 12:55 PM
dougwilliams's Avatar
dougwilliams dougwilliams is offline
Engineer - Controls, Electronics
FRC #2053 (TigerTronics)
Team Role: Mentor
 
Join Date: May 2013
Rookie Year: 2013
Location: Vestal, NY
Posts: 109
dougwilliams is on a distinguished road
Re: navX MXP without PID control

Quote:
Originally Posted by sagrossm View Post
Ok, we've been trying to implement it and it's just been really inconsistent (usually turning too far). Looked online for help and I can only find examples with PID, that's why I made that assumption. So is there anything I can do to make it more accurate and reduce error? This is a button that we have:

if((driveStick.getRawButton(12) == true)) {

if(gyro.getYaw() > -140){
leftFront.set(0.3);
leftRear.set(0.3);
rightFront(-0.3);
rightRear.set(-0.3);
}

else if(gyro.getYaw() <= -140){
leftFront.set(0.0);
leftRear.set(0.0);
rightFront(0.0);
rightRear.set(0.0);
}
}


We take an easy piecewise linear approach when rotating to angle using the NavX yaw as the input. We had a lot of overshoot with pure proportional, so we set angle limits similar to what you are doing and set a speed. If it needs to rotate more than 90 degrees it can be set to rotate at full speed. When it has 45 degrees left to rotate it needs to be scaled down to .4 speed. Once you are within 20 degrees the rotational speed needs to be scaled down to only .2. There is a lot of robot inertia in the spin - and that needs to be accounted for. (All those numbers are made up, but the idea is roughly what we implement).

This way was an easier first step rather than explaining a full PID loop and how to implement that in software. Most students are able to read the code and understand what it's doing.



Also - looking at your code - do the angles work in that scenario? What angle are you trying to rotate to? Maybe to zero - but then when you are less than -140 degrees it stops. That seems backwards to me.

And I think in the NavX 180 and -180 are the same position, and you need t account for that in your math.
Reply With Quote