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.
tlaning
January 12, 2021, 1:43pm
#2
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.
Reserved for Mecanum wheels drivetrain wiki entry
Code examples:
A Holonomic drive is free to move in any direction without having to rotate around its axis.
https://en.wikipedia.org/wiki/Holonomic_(robotics)
One form consists of 3 or 4 omniwheels mounted at angles to each other. It is good for lateral movement, and increases speed and power of turns. However, linear drive speed and power are decreased since some or all of the powered wheels run at angles to the bot’s motion. All wheels m…
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);
74656A
January 13, 2021, 3:14pm
#6
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