# How to code x drive autonomous

We are having trouble with our autonomous. So we need help coding it in blocks

Would you mind sharing the code you already have and also saying the exact problem that you have? We canâ€™t help if we donâ€™t know whatâ€™s wrong.

I have an example in text that you can translate.

Weâ€™re doing an X-Drive right now so Iâ€™d be happy to help.

1 Like

Were honestly just so confused that we really donâ€™t have any code so we just need to know the basic of what to do

At least start by searching the forum and watching some of the old tutorials.

5 Likes

You could also use myblocks (if using block) to make it easier

1 Like

After you learn how holonomic drives work after watching the videos from the other post jpearman recommended, I would first make functions to make the code more compact instead of coding each motor all the time. You would do this by going to â€śmy blocksâ€ť and then clicking â€śMake a Blockâ€ť. You should probably rename â€śblock nameâ€ť to whatever the code does. Then you add a parameter for the block by clicking â€śAdd an inputâ€ť. You should also say what it does in the name.

For example:

Note: This is code for mecanum wheels, but it is the same principle.

Now, you can use that parameter as an input, whenever you use it as a variable. Everything using this parameter will change if you use this function again.

For example: If I use this â€śForwardâ€ť function, and put 100 as a value, it would run everything under the â€śdefine (Foward (Distance))â€ť block in the first picture and replace every â€śDistanceâ€ť parameter with 100.

Hope this helps.

1 Like

I donâ€™t have much experience with x-drive, but I have learned that it is much easier to code more complicated things like this in C++, also itâ€™s a good thing to learn early.

Well, you know how X-Drive moves, right? Well, you can tell each motor to move a specific direction to move a certain distance.

For example,
-Move towards roller
-Spin Roller
-Move forward pick up one disc
(END)

Just make each task get performed with each motor.

Okay after looking at this I think i understand so we will try it and see if it works

1 Like

Honestly thank you so much bro I had no idea how to go about programming my X drive auton and you just helped so much I will create a code for my bot tonight and test it tomorrow you just made my life so much easier