Struggling to Code Mecanum Wheels

We are using V5 Blocks and have recently switched over to mecanum wheels after 2 competitions. We are currently mainly struggling with the strafing part. We know the motions for strafing left and right but our code isn’t working. Screenshot (100) If you can help please reply.

Right now your code goes
If button pressed, make the drive spin, wait until button pressed, then stop. Since the button will be pressed to move it, pressing the button will also make it coast so therefore your code doesn’t do anything.

In your when started loop, make a while true loop and use if, else if, and else statements to see when the controller is being pressed and move the drive based on that.

If button right pressed: strafe
Else if button left pressed: strafe the other way
Else: coast the drive

2 Likes

Screenshot (102)

Is this better?

No, first of all, your right strafing code won’t run correctly (because it only takes place when the left button is pressed.)

However, you also have no way of strafing slowly, which I’d imagine you wish to do.

1 Like

Screenshot (103)

Here I tried again. Still doesn’t work

I think you have to put the if statements in a forever loop.
I think you also have to use an if then else statement and put the if statement in the else part
29 PM
It should look something like this (ignore the inside)

1 Like

I just posted how to do X-Arcade Drive here:

It is not coded for Blocks, VCtext, or PROS. It is just the equations and tables to get a feel for what is going on.

If you don’t care about full range joystick operation you can use the base equations. Where the inputs are the joystick values for that axis. If blocks works with +/- 127 ranges for joystick and motor then these are good. If not you need to scale input to output.
LF = VSpeed + HSpeed + Yaw
LR = VSpeed - HSpeed + Yaw
RF = VSpeed - Hspeed - Yaw
RR = VSpeed + HSpeed - Yaw

3 Likes

wdym @rpm

@Avonderweidt w.r.t. what?

1 Like

the code isant for joysticks

sorry sorry posted to wrong forum. Thought this was the sticky joystick forum.

Your if statememts checking if the buttons aren’t pressed won’t do anything, since they will only be checked when the button is pressed. Also, the code under the statements checking the opposite button will only execute if both buttons are pressed. I think the problem might lie in the fact that you are using event blocks. Try using sensing blocks in the main forever loop.

2 Likes

I see that the code is not for joysticks. I just thought you didn’t know how to program x-arcade so it works with joysticks. I’m not sure why you want a button to control strafing but if you want to try using joysticks here some block code. The equation for MotorRF looks different b/c Block implements it like V - (H+Y). Also notice the order of operations for MotorRR.

image

9 Likes

i found the problem first off i should have looked over my teammates code 2ndly nothing will happen because i have the drive train speed set to joy con position any sugestions?

here was the solution Screenshot (109)
i needed a while loop

2 Likes