Quote:
Originally Posted by mikets
The WPI library provides the RobotDrive object that includes a method:
Code:
void RobotDrive::MecanumDrive_Polar(float magnitude, float direction, float rotation)
You can call this method to drive the mechanum wheels. It is using polar coordinate system where you specify the magnitude and direction you want to go. Rotation will specify the heading you want the robot to face.
To calculate the magnitude and direction from joystick reading, you can do:
Code:
MecanumDrive_Polar(joystick->GetMagnitude(), joystick->GetDirectionDegrees(), 0.0);
|
Note that the MecanumDrive_Cartesian is much more suited to driving with a joystick. It was designed to directly pass 3 joystick axes in.
Quote:
|
void MecanumDrive_Cartesian(float x, float y, float rotation, float gyroAngle = 0.0);
|
This also allows you to simply pass in the current reading from a gyro to accomplish field-oriented-control.
-Joe