Quote:
Originally Posted by Robototes2412
Can someone please post the java scource code for the holonomicDrive Function?
|
The code is posted below, but anyone with Java can simply look at the source code by opening the project that comes with the distribution:
Code:
public void holonomicDrive(double magnitude, double direction, double rotation) {
double frontLeftSpeed, rearLeftSpeed, frontRightSpeed, rearRightSpeed;
magnitude = limit(magnitude);
double cosD = Math.cos((direction + 45.0) * 3.14159 / 180.0);
double sinD = Math.cos((direction - 45.0) * 3.14159 / 180.0);
frontLeftSpeed = limit((sinD * magnitude + rotation));
rearLeftSpeed = limit((cosD * magnitude + rotation));
frontRightSpeed = limit((cosD * magnitude - rotation));
rearRightSpeed = limit((sinD * magnitude - rotation));
m_frontLeftMotor.set(frontLeftSpeed * m_invertedMotors[MotorType.kFrontLeft_val]);
m_frontRightMotor.set(frontRightSpeed * m_invertedMotors[MotorType.kFrontRight_val]);
m_rearLeftMotor.set(rearLeftSpeed * m_invertedMotors[MotorType.kRearLeft_val]);
m_rearRightMotor.set(rearRightSpeed * m_invertedMotors[MotorType.kRearRight_val]);
}