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
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!
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? @ERROR101
The basics of the Python code will be something like this, but this is just a rough guide, not something to copy and paste.
leftFront.spin(FORWARD)
rightFront.spin(FORWARD)
leftRear.spin(FORWARD)
rightRear.spin(FORWARD)
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.
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.
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
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.
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.
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!