How to have clean strafing

Currently i have a drive function which consists of 3 PID loops, one for x, one for y and one for orientation. (i also have position tracking). But even after having 3 PID loops, i am still having trouble getting the strafing to be clean, By that I mean, for it to be strafing smoothly and in a straight line. And i know it isnt a build problem since it strafes in a smooth line in opcontrol.

So does anyone have any ideas and or suggestions for me to make my strafing as clean and accurate as possible?

1 Like

Could you post your code? A video of the robot would also be helpful, so we can see the issue. If the strafing is clean in driver but not in auto, I’d suspect there’s an issue in your code.

1 Like

I am unable to post a video rn but here is the code

https://paste.ubuntu.com/p/2MSFJTQKyT/

1 Like

Strafing via 3 PID controllers isn’t really clean, as you said. However, using mecanum/x-drive math (google it) you can write a function that accepts a direction and a power and it distributes that power across the wheels so that the robot strafes in the proper direction.

That way, you just need two PID controllers (distance and heading). The distance controller is based on the distance to the point, and you just point the output of the pid controller towards the target point using holonomic math (which is pretty simple btw).

3 Likes

do you mean something like this ?

1 Like

Yep, that explains exactly what math you need to use.

1 Like

ok cool thanks i will have a look through

I was looking through it, and that is for joysticks, could it also be adapted for auto?

I’m not going to tell you how to do it, I just said that it’s possible and suggested you do some research. That paper explains the math behind a holonomic drive, if you read closely and understand it you should be able to figure out how to apply it to both auton and driving (there is little use for driving btw).

1 Like

ok got it thanks for the help

I’m just going to ask if you search the vexform for holonomic or x-drive. There is a non-trivial amount of discussion about this.

1 Like