View Single Post
  #10   Spotlight this post!  
Unread 27-06-2014, 07:53
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Team 254 - 2014 FRC Code

Ok Tom, you're going to have to help me understand some of these negative inertia steps as I really like the idea a lot.

Here you calculate what the negative inertia is between the last turn iteration and the the current one. So if you are turning full left and decide to stop the negInertia is 1 and the old turn value is now 0. Understood so far.
Code:
double negInertia = wheel - oldWheel;
oldWheel = wheel;
Next you determine your negative inertia scaling value based on high or low gear. Understood because you'll be turning faster in a higher gear and the robot is not going to want to slow down as quickly in high gear so more drift meaning a higher scaling value is needed. Still following.
Code:
double negInertiaAccumulator = 0.0;
double negInertiaScalar;
if (isHighGear) {
     negInertiaScalar = 5.0;
     sensitivity = Constants.sensitivityHigh.getDouble();
} else {
     if (wheel * negInertia > 0) {
          negInertiaScalar = 2.5;
      } else {
          if (Math.abs(wheel) > 0.65) {
               negInertiaScalar = 5.0;
          } else {
               negInertiaScalar = 3.0;
          }
      }
      sensitivity = Constants.sensitivityLow.getDouble();
 }
Next you calculate what power you're going to need by multiplying your negative inertia by the scaling value and add this to the accumulator value. Then you add this value to your turn value to counter the inertia. Still following.
Code:
double negInertiaPower = negInertia * negInertiaScalar;
negInertiaAccumulator += negInertiaPower;

wheel = wheel + negInertiaAccumulator;
This is where you lose me. From what I understand from this next bit of code you are increasing/decreasing the inertia accumulator by 1 to get it closer to zero, if it is -1 <= x >= 1 then you set it to 0. This makes sense as you'll want the negative inertia to get smaller as the robot slows down. Where I'm lost is the fact that negInertiaAccumulator is never used again in this method, and it's a local variable so its lost after the method is complete. This means on the next run through of this method all of the negative inertia work is lost and the correction is only done for one iteration. What am I missing?
Code:
if (negInertiaAccumulator > 1) {
      negInertiaAccumulator -= 1;
} else if (negInertiaAccumulator < -1) {
      negInertiaAccumulator += 1;
} else {
      negInertiaAccumulator = 0;
}

Last edited by notmattlythgoe : 27-06-2014 at 07:55.
Reply With Quote