Here's the latest version of the "crab" method. Right now I'm thinking that if this works, we should use it for autonomous too. Except, since there aren't any gamepad controllers in the autonomous mode, the first thing to do there will be to translate the desired angles and speeds into their corresponding x & y vectors (3 total) and pass that on to this method. That.just.might.work.
Of course there will be some interesting relationships to figure out for autonomous, but this maybe gets us started.
FWIW, I ran this on a laptop (using Netbeans IDE) after writing it. Pulled a couple bugs out of it in the process. Probably there are a couple others, but we're closer than we were.
public static botMotors crab(Gamepad cx)
{
botMotors m = new botMotors();
float maxDrive;
float tempMax;
// Sum the vectors and hope for the best :-)
/ turn=left.x, fwd=left.y, crab=right.x
m.leftFront = cx.left_stick_x + cx.left_stick_y + cx.right_stick_x;
m.rightFront = -cx.left_stick_x + cx.left_stick_y - cx.right_stick_x;
m.leftRear = cx.left_stick_x + cx.left_stick_y - cx.right_stick_x;
m.rightRear = -cx.left_stick_x + cx.left_stick_y + cx.right_stick_x;
keep things proportional when the sum of any x or y > 1
tempMax = Math.max(Math.abs(m.leftFront), Math.abs(m.rightFront));
maxDrive = Math.max(Math.abs(m.leftRear), Math.abs(m.rightRear));
maxDrive = Math.max(tempMax, maxDrive);
maxDrive = (maxDrive > MOTORMAX) ? maxDrive : MOTORMAX;
// scale and clip the front motors, then the aft
m.leftFront = m.leftFront/maxDrive;
m.leftFront = Range.clip(m.leftFront, MOTORMIN, MOTORMAX);
m.rightFront = m.rightFront/maxDrive;
m.rightFront = Range.clip(m.rightFront, MOTORMIN, MOTORMAX);
m.leftRear = m.leftRear/maxDrive;
m.leftRear = Range.clip(m.leftRear, MOTORMIN, MOTORMAX);
m.rightRear = m.rightRear/maxDrive;
m.rightRear = Range.clip(m.rightRear, MOTORMIN, MOTORMAX);
return m;
}
This is what it looks like when you cycle all three inputs
Play with graphs and it can look like this ... which is meaningless but kind of cool to look at:
Any opinions expressed here are ONLY those of the poster. Other mentors have their own opinions and some of those are going to be different. Otherwise, this is information for Mentors of FTC teams 8578 and 11959 Columbus, Indiana
Subscribe to:
Posts (Atom)
Java Is as Java Does
We would not seek a battle, as we are; Nor, as we are, we say we will not shun it. Henry to Montjoy, Henry V , Shakespeare Last season I ...
-
Only five more months until we can binge watch season five of Robotics, and each year I think about this a little differently and a little ...
-
Ludwig von Beethoven “The thing that gets lost,” he says, “and which I think is important to know, is that programming is nev...
-
I've had among my friends, peers, and professors a number of WWII veterans - mostly American, some Canadian, and some German. Whether i...