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:
No comments:
Post a Comment