Holonomic drive train code

I have been searching around but i can’t seam to find out how to actually code my x-drive train so i can drive it. A lot of what I found seemed to be outdated as it only worked with cortex. In the end i found code like this

Motor[leftfront] = VexRT[ch3] + VexRT[ch1] + VexRT[ch4];
Motor[rightfront] = VexRT[ch3] - VexRT[ch1] - VexRT[ch4];
Motor[leftrear] = VexRT[ch3] + VexRT[ch1] - VexRT[ch4];
Motor[rightrear]= VexRT[ch3] - VexRT[ch1] + VexRT[ch4];

but after I applied it to both Vex code V5 and RobotC I got this outcome where 2 of the wheels responded properly when i moved the joystick and then the other 2 responded desperately when I pressed different buttons.

I think i have to change a setting in the V5 brain but i couldn’t find any setting change that varied the outcome?

I also don’t know weather to use python or C++ in vex code V5 and how to set up the ‘add devices’ properly. I am supposed to use VEX code V5 right? or is there a different thing to use for this?

I am honestly very clueless but I think relay most of the information I found was outdated so if someone could point me to some new information linked with V5 and VEX code V5 then that would be great!

Make sure you are using your own program and not the built-in “drive” program

I tried that but nothing happened. This is the code I used in vex code v5

myVariable = 0

def when_started1():
global myVariable


drivetrain[left_motor_a] = VexRT[ch3] + VexRT[ch1] + VexRT[ch4];
drivetrain[left_motor_b] = VexRT[ch3] - VexRT[ch1] - VexRT[ch4];
drivetrain[right_motor_a] = VexRT[ch3] + VexRT[ch1] - VexRT[ch4];
drivetrain[right_motor_b]= VexRT[ch3] - VexRT[ch1] + VexRT[ch4];

See something wrong with it? My v5 brain thinks there is something wrong with line 28 even tho my code only has 12 lines

These are ROBOTC commands, not V5 Python or C++commands.
Firstly, which programming language would you like to use?


Python preferably but I really don’t mind as long as it works.

You should see a bunch of error messages. They might have suggested changes to make them work.

Pros or vexcode?
i can help you out with both

Thanks, but I don’t see any error messages in Vex code v5

I am using the standard VEX code v5. It would be great if you could help me!

Text or blocks
I can’t help with blocks sorry
Lmk if it’s text tho

Text in python but C++ is good two. I assume its just a few stranded lines of code right? like the same code can be copied and pasted for everyone?

The basics of the Python code will be something like this, but this is just a rough guide, not something to copy and paste.


while true:
    leftFront.set_velocity(controller_1.axis1.position() + controller_1.axis2.position() + controller_1.axis3.position(), PERCENT)
    #then your other 3 motor commands here

So at the start, you are spinning all the motors forward. The velocity of these motors is then set within the loop. A negative velocity will make them go backwards.

1 Like

Thanks! But is didn’t work… This is what I used

VEXcode Project x-drve.v5python (1.7 KB)

I hope you can find the issue!
So sorry if this is a burden two you.

2021-03-08 (2) 2021-03-08 (1)

I believe your issue is that you have the wrong axes for driving forward and turning. You had axis 1 to move it forward, but that should be axis 2. Axis 2 was turning your robot, but you want axis 1 to do that.
Using Blocks for Controller Buttons / Joysticks in VEXcode V5 – Knowledge  Base
By switching the axes, like I’ve done here, you should be able to control your robot.
VEXcode Project x-drve.v5python (1.8 KB)


Thanks! but it didn’t work…

I think now that code you gave me must be right!
So there must be a problem with the setup/controls with the brain or controller because when I press run code, nothing happens when I move any of the controller buttons.

some of the wheels move at random tho when I go into drive robot (not in the code)

I can only assume at this point that I am making some rookie mistake in the setup.
Does anybody know what could be wrong?

The drive code won’t help you, it’s only for clawbots. Try making a program that spins each wheel forwards one after another for 1 rotation. That would allow you to see if any are spinning the wrong way, and let you know to reverse that motor in it’s setup


Thanks, all the wheels are moving in the right direction.

The problem is that nothing happens when I move the controller. This is the code have so far,

x-drve Official.v5python (1.9 KB)

In the code you have attached, you are never telling the motors to spin. Setting the velocity doesn’t actually move them, it just tells the motors how fast to go when they are going to move.
You also need a loop to continually update the velocity based on the current controller axis positions.

Take a look at the attached to see the basics. I am not sure if this will work as such, but it will run at least.x-drve Official.v5python (2.0 KB)


I had tremendous help from these wonderful people, back in October. The code they gave me was a little of a rough draft, however, because everyone’s robot is different. This should be the base, but you might have to change some signs around to make it work the way you want. NOTE: This is arcade, which I think is what you want.

Edit: Forgot the Link lol.

1 Like

Thanks but I don’t know how to tell the motors to spin when I move my controller and I also don’t know how to loop the code.

I also fear there is a problem with the ‘while true’ command at the top because i tried running basic code below it and nothing happened where as when I ran that same code above it it worked.

This code also means nothing to me


I want to be able to drive the robot with the controller. I already made sure the motors where set right.

Could you just add a loop to it and tell the motors to spin like you said I needed to do because honestly I have know clue how to use python. x-drve Official.v5python

I will be forever grateful to you if you can get it to work!
Thank you so much!