View Single Post
  #3   Spotlight this post!  
Unread 16-02-2010, 17:10
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 590
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Programming Mecanum

Quote:
Originally Posted by Robototes2412 View Post
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]);
    }
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote