How to add strafing to an arcade drive

I have a X-Drive arcade driven program and would like to be able to add strafing to axis 4 on the controller. Axis 3 drive forward and backward and axis 1 turn the robot left or right.

Below is the program for driving and turning

while (true) {
LeftFront.spin(directionType::fwd, (Controller1.Axis3.value() + Controller1.Axis1.value())/2, velocityUnits::pct);
RightFront.spin(directionType::fwd, (Controller1.Axis3.value() - Controller1.Axis1.value())/2, velocityUnits::pct);
LeftBack.spin(directionType::fwd, (Controller1.Axis3.value() + Controller1.Axis1.value())/2, velocityUnits::pct);
RightBack.spin(directionType::rev, (Controller1.Axis3.value() - Controller1.Axis1.value())/2, velocityUnits::pct);

task::sleep(20);
}

If someone could help me add strafing to axis 4, it would be much appreciated.

You should just have to add Controller1.Axis4.value()) with its respective positive or negative before the +/- Controller1.Axis1.value())/2. If you still have problems I’ll paste my code so you can reference it.

This should help a lot. It explains a lot about holonomic drives and it literally provides the exact code.

1 Like

I think I know how to do that, but can you put on your code that I can see to make sure I’m doing it correct.

So I added axis 4, and the motor names turned red.

LeftFront.spin(directionType::fwd, (Controller1.Axis3.value() + Controller1.Axis4.value()) + Controller1.Axis1.value())/2, velocityUnits::pct);
RightFront.spin(directionType::fwd, (Controller1.Axis3.value() + Controller1.Axis4.value()) - Controller1.Axis1.value())/2, velocityUnits::pct);
LeftBack.spin(directionType::fwd, (Controller1.Axis3.value() + Controller1.Axis4.value()) + Controller1.Axis1.value())/2, velocityUnits::pct);
RightBack.spin(directionType::rev, (Controller1.Axis3.value() + Controller1.Axis4.value()) - Controller1.Axis1.value())/2, velocityUnits::pct);

When you put your cursor over the motor, what does it say?

It looks like you didn’t get rid of of the closing parenthesis after Controller1.Axis4.value() in each of the lines.

It says it requires 3 arguments but only 2 were provided.

Oh, that fixed it
Thank you