|
Re: Swerve vs. Mecanum Programming
Without getting into detailed equations, the mathematical principles of fully holonomic omni/mecanum drives are relatively simple and can be approached this way:
Each wheel has a direction vector along which it can transmit force in either direction. For a mecanum this is at 45 degrees to the plane of the wheel, parallel to the axle of the roller contacting the ground. For an omni it's along the flat plane of the wheel. No force is or can be transmitted except along this vector.
To get the wheel speeds necessary for any desired motion, you need to compute the projection of the motion vector onto each wheel's direction vector. For mecanums there's an additional constant to correct for the 45 degree angle. This can be done with dot products and no trigonometry.
For simple directional motion, regardless of direction, that's all there is to it. To handle rotation, the motion vectors are tangent to a circle about the center of rotation, projected on the same wheel vectors, and scaled by relative radius. For rotation about the center of a normally configured robot, these end up the same for each wheel. Rotation about other points or for odd wheel configurations is a bit more complex but conceptually the same. You can rotate and move simultaneously by solving the wheel speeds for each separately, then adding the motion and rotation components for each wheel to get its final drive speed.
This approach lends itself well to a two stick motion/rotation or single stick/twist control setup, and the vector math shouldn't take more than a couple of dozen lines of Java or C. It handles any motion physically possible with the robot. The motor drive functions needed for swerve drives, especially for complex motions, are considerably more complicated.
It should be noted that there are simpler but still useful ways to employ mecanum/omni wheels short of full holonomic, and other ways to program swerves short of the "almost holonomic" of which they're capable.
|