View unanswered posts | View active topics It is currently Fri Oct 31, 2014 12:05 am






Reply to topic  [ 2 posts ] 
Mechanum Wheels Programing 
Author Message
Rookie

Joined: Mon May 06, 2013 4:14 pm
Posts: 2
Post 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


Fri Nov 08, 2013 5:35 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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;
}


Fri Nov 08, 2013 7:40 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.