ROBOTC.net forums
http://www.robotc.net/forums/

Mechanum Wheels Programing
http://www.robotc.net/forums/viewtopic.php?f=11&t=7223
Page 1 of 1

Author:  kaleblange [ Fri Nov 08, 2013 5:35 pm ]
Post subject:  Mechanum Wheels Programing

My team is trying to use the mechanum whells on our robot. We need help as we have figured out there is special programing. What is that special programing?

Kaleb Lange
Team 3281
Techstorm
York, PA

Author:  MHTS [ Fri Nov 08, 2013 7:40 pm ]
Post subject:  Re: Mechanum Wheels Programing

An excerpt from our library:
Code:
void DriveMecanumCartesian(
    DRIVE &drive,
    int x,
    int y,
    int rot
    )
{
    if (drive.flags & DRIVEF_FOUR_MOTORS)
    {
        int mag, maxMag, i;
        drive.motorPowers[IDX_FRONT_LEFT] = x + y + rot;
        drive.motorPowers[IDX_FRONT_RIGHT] = -x + y - rot;
        drive.motorPowers[IDX_REAR_LEFT] = -x + y + rot;
        drive.motorPowers[IDX_REAR_RIGHT] = x + y - rot;
        //
        // Normalize
        //
        maxMag = abs(drive.motorPowers[0]);
        for (i = 1; i < MAX_NUM_MOTORS; i++)
        {
            mag = abs(drive.motorPowers[i]);
            if (mag > maxMag)
            {
                maxMag = mag;
            }
        }

        if (maxMag > MOTOR_MAX_VALUE)
        {
            for (i = 0; i < MAX_NUM_MOTORS; i++)
            {
                drive.motorPowers[i] =
                    (drive.motorPowers[i]*MOTOR_MAX_VALUE)/maxMag;
            }
        }
    }
    else
    {
        //
        // Mecanum drive is only possible with 4 motors. For 2 motors, we
        // do arcade drive instead.
        //
        DriveArcade(drive, y, rot);
    }
    drive.flags |= DRIVEF_ON;
}

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/