How do I program Xdrive?

So my team and I decided to use an Xdrive this year. Unfortunately I, the programmer, do not know how to program Xdrive. If anyone is willing to send in tutorials that you have found, or can send in an example of an Xdrive code it would be much appreciated! Thanks in advance.

1 Like

Welcome to the Forums!

Please use the search bar to search for posts. There are many posts related to this topic.

Anyways, here is one of those posts: Holonomic drives 2.0: A video tutorial by Cody - VEX V5 General Discussion / General Forum - VEX Forum


Tank Or Arcade. My team uses a tank, in a weird way so that the sensitivity gets lowered so diagonals are easier. The code is

int ch3 = Controller1.Axis3.position(vex::percent);
int ch4 = Controller1.Axis4.position(vex::percent);
int ch2 = Controller1.Axis2.position(vex::percent);
int ch1 = Controller1.Axis1.position(vex::percent);  
FrontRight.spin(forward, (round((ch2 - ch1) / 4.0) * 4.0), vex::percent);
BackRight.spin(forward, (round((ch2 +ch1) / 4.0) * 4.0), vex::percent);
BackLeft.spin(forward, (round((ch3 - ch4) / 4.0) * 4.0), vex::percent);
FrontLeft.spin(forward, (round((ch3 + ch4) / 4.0) * 4.0), vex::percent);
1 Like

You could try this as well. My team is using it this year and it’s pretty good

    Rfront.setVelocity((Controller1.Axis2.position() - (Controller1.Axis1.position() + Controller1.Axis4.position())), percent);
    Lfront.setVelocity((Controller1.Axis2.position() + (Controller1.Axis1.position() + Controller1.Axis4.position())), percent);
    Rback.setVelocity((Controller1.Axis2.position() + (Controller1.Axis1.position() - Controller1.Axis4.position())), percent);
    Lback.setVelocity((Controller1.Axis2.position() - (Controller1.Axis1.position() - Controller1.Axis4.position())), percent);

x drive code works the same way as mecanum code - you can use any example for mecanum drives.

also, if you want to dive deeper into complex algorithms you can use with a holonomic drive, check this out


Make a very basic chassis with just wheels attached, freely spinning. If it’s already built, ask for the motors to be removed or set to coast with it activated. Push and twist it around on the floor and see what the wheels have to do for each component of motion chosen from; forwards/backwards, sideways, rotation on the spot. Any motion of the vehicle is made up of the sum of those three. You then program each wheel speed as the sum of the things it would have to do for each component of vehicle motion. There’s an arrow on the back of each motor that tells you what direction is positive spin.
Make sure it’s the same type of gearbox in every driving motor unless you’re doing something fancy with torque sharing, but I derive that this would be above your play grade as yet.


I have it figured out. After much trial and error the program has been written. testing is soon to come. Thank you for the help everyone.


nice, i suggest adding something to lower the sensitivity because going diagonals is hard with a x chassis

here is my teams sensitivity lower,
“(round((ch2 - ch1) / 4.0) * 4.0)”

I know this is late but a good way to think of it is 2 drivetrain programs facing 90 degrees off of each other controlling the same wheels.

It’s absolutely the right way to look at it! Definitely worth saying that way. Don’t forget that it’s three independent drivetrains - there’s a yaw/spin-on-the spot component, too :slight_smile:

1 Like

Hi, can this code be used for just an x-drive without a tank?

What do you mean, you mean arcarde drive?

No, Sorry i got it now
Thank you

Is this in VexCode V5 Pro?

yes it is the Vexcode V5pro