Академический Документы
Профессиональный Документы
Культура Документы
The all-direction vehicle is equipped with four Mecanum wheels. The cool part of this
vehicle is the flexibility of moving in any direction while keeping itself in a constant
direction. It is achieved with the special structure of Mecanum wheel and their proper
configuration
on
the
vehicle.
You
can
visit
the
websitehttp://www.chiefdelphi.com/media/papers/1836 and
download
the
omndirectional.pdf file to get to know how it works. In general, the speeds of Mecanum
wheel are governed by the equations in the picture.
So, lets build a real one from assembling its framework.
The speed of four Mecanum wheel is dependent on the speed of vehicle, therefore, it
should be precisely controlled to avoid wheel sliding. Encoder motors are used to
achieve this goal.
Step 5: Wiring
An encoder motor driver from Makeblock is able to drive two encoder motors. Two
encoder motor drivers are enough for this vehicle. They are connected to port 1 and
port 2 on the Orion board respectively. Please keep consistent between wiring and
defining ports in your codes.
Step 7: Programming
The speed of four Mecanum wheels are determined by the angular velocity and
speeds in x-axis and y-axis of the vehicle. A Joystick is used to control the speed of
the platform with left stick for, and right stick for.
Plug a Me USB Host module into port 3 of Orion board and then plug a wireless
module into Me USB Host module.
}
void loop()
{
Serial.println("loop:");
//setEachMotorSpeed(100, 50, 50, 100);
if(!joypad.device_online)
{
Serial.println("Device offline.");
joypad.probeDevice();
delay(1000);
}
else
{
int len = joypad.host_recv();
parseJoystick(joypad.RECV_BUFFER);
delay(5);
}
//delay(500);
}
debug joystick
// int i = 0;
// for(i = 0; i < 7; i++)
// {
//
Serial.print(buf[i]);
//
Serial.print('-');
// }
// Serial.println(buf[7]);
// delay(10);
//
switch (buf[5])
{
case 1:
linearSpeed += 5;
if (linearSpeed > maxLinearSpeed)
{
linearSpeed = maxLinearSpeed;
}
break;
case 2:
angularSpeed += 5;
if (angularSpeed > maxAngularSpeed)
{
angularSpeed = maxAngularSpeed;
}
break;
case 4:
linearSpeed -= 5;
if (linearSpeed < minLinearSpeed)
{
linearSpeed = minLinearSpeed;
}
break;
case 8:
angularSpeed -= 5;
if (angularSpeed < minAngularSpeed)
{
angularSpeed = minAngularSpeed;
}
break;
default:
break;
-linearSpeed / 2, 0);
break;
default:
mecanumRun(0, 0, 0);
break;
}
}
}
void mecanumRun(float xSpeed, float ySpeed, float aSpeed)
{
float speed1 = ySpeed - xSpeed + aSpeed;
float speed2 = ySpeed + xSpeed - aSpeed;
float speed3 = ySpeed - xSpeed - aSpeed;
float speed4 = ySpeed + xSpeed + aSpeed;
float max = speed1;
if (max < speed2)
max = speed2;
max = speed3;
max = speed4;