Advanced Programming

Holonomic Drive

When using holonomic drive, one must remember that left/right strafing has to be coded. This can be done taking three values: the vertical axis, horizontal axis, and turning axis. We wi;l refer to the frontleft, frontright, backleft, and backright motors as fl, fr, bl, and br respectively.

  1. Get the values and put them into variables. I’ll use x, y, and z (turning) for my axes.
  2. Reverse the motors, this will make your life easier.
  3. Vertical movment should stay positive for each motor, so let’s give each motor “y”:
    fr: y
    fl: y
    br: y
    bl: y
  4. Figure out how each motor strafes. For Omni, you can get a good idea using this simulator we made (takes a while to load): Omni Simulator. A good idea is to figure out max speed in the right direction. For our wheels’ Mecanum drive, to strafe right at max speed the motor values must be as follows (when using reversed motors! don’t forget this bit! simply setDirection(Direction.REVERSE) will do!):
    fr: +1
    fl: -1
    br: -1
    bl: +1
    Basically, the diagonals must fight each other to strafe. This means that they can’t move forward or backward, so the wheels move side to side. So diagonal pairs are positive and negative respectively to strafe. You must test this if you don’t know the force vectors of the wheels to figure out which configuration is left/right. Based on this and the knowledge that the rightmost point of the joystick x axis is +1, we come to this:
    fr: x
    fl: -x
    br: -x
    bl: x
    And compiling this with our previous conclusion:
    fr: y+x
    fl: y-x
    br: y-x
    bl: y+x
  5. Figure out how to turn. If you reversed correctly, and are using a conventional holonomic drive, this should be when the left and right wheels move in opposite directions – just like tank! Meaning the motors for left/right should be reversed. To rotate right (again, we use right because the rightmost point on the joystick x axis is +1) the left side is positive and right side is negative, as follows:
    fr: -1
    fl: +1
    br: -1
    bl: +1
    And using our joystick values:
    fr: -z
    fl: z
    br: -z
    bl: z
    Compiling with our previous conclusions:
    fr: y+x-z
    fl: y-x+z
    br: y-x-z
    bl: y+x+z
  6. Write the code! Disclaimer: under TeleOp, you’ll find a conversion of our teleop. That won’t match with this even though it’s Mecanum – that’s because turning is reversed!

Skip to toolbar