Quote:
Originally Posted by GeeTwo
Limiting acceleration using encoders would require writing some code to calculate the acceleration from the speed (just the change in speed divided by the elapsed time). I don't know of any libraries to do this, so unless you have some experienced programmers, you probably wouldn't want to attempt it at this late date.
|
I know what we used in previous years, on the cRIO using C++, we had a 2-speed transmission with automatic shifting, based on the speed, but we also used the timer class to prevent us from rapidly shifting from high to low gear within a certain period of time.
Code:
double time = GetTime();
double left_dist = leftSide.GetDistance();
double right_dist = -rightSide.GetDistance();
double left_rate = (left_dist - leftPrevDist) / (time- leftPrevTime);
double right_rate = (right_dist - rightPrevDist) / (time - rightPrevTime);
leftPrevDist = left_dist;
rightPrevDist = right_dist;
leftPrevTime = time;
rightPrevTime = time;
//printf("left: %f, right: %f, Speed! %f\n", left_rate, right_rate, absd((left_rate + right_rate) / 2));
if (!HighGear && absd((left_rate + right_rate) / 2) > 3.7) {
shift.Set(true);
HighGear = true;
} else if (HighGear && absd((left_rate + right_rate) / 2) < 2) {
shift.Set(false);
HighGear = false;
}
That's the relevant portion of what we did in 2011, and 2012. It was placed inside of our main tele-op loop.
The "shift" object was a solenoid, that shifted the pnuematic shifter in the gearbox.
While there probably isn't a library to do that, writing the code for it shouldn't be too difficult. (You could probably just modify that to do what you need it to...)