4 Motor Arcade Drive Coding Help

Our team is currently trying to code a 4 motor arcade Drive, using the V5 motors on Vex Coding Studio. I have tried an arcade code in the past however I believe that the problem with it was that it was way too sensitive. For example when pushing the joystick forward, if the position of the joystick was just barely to the right or left, some of the motors would not go forwards. I don’t know if this will help or not but the front two wheels are hooked up to a 3 to 1 chain and the back two wheels are directly hooked up to the two motors.

Can someone show me an example of a arcade drive program that doesn’t run into the problem I had before? (p.s. I need ask you questions about the code like what things do, what I need to replace in the code, etc.)

If your problem is sensitivity you could add a dead zone, basically what you do is say if(joystick1.value()>10||joystick2.value()>10||joystick3.value()>10||joystick4.value()>10)
{
Drive code
}
Else
{
Set all motors to 0
}
This’ll make it so you have too move the joystick more to activate the drive code, put all the joystick values in abs aswell :slight_smile:

1 Like

By joystick I mean the axis

Ah, do you want to do it on one joystick or two? (As in one for forward/back and one for turn, or one that does both)

Having the front two wheels on a 3 to 1 chain and the back wheels direct drive will cause different wheel speeds and your drive motors will fight each other, unless I misread something. I never coded arcade but It seems like tank control, but using one vertical and one horizontal axis.
You should be able to set the velocity of the motors to the value of the joystick axis in question. For a turn, say you set the velocity of the left motor to the value of axis 4, and the right motor to its negative value, you should have a right turn.

And yes, you should set a deadzone on your joystick to reduce hypersensitivity. You don’t want it attempting to move if you accidently push the joystick 1% forward.

For left motors
Motor1.spin(directionType::fwd, forwardAxis-horizontalAxis, percentUnits::pct)
Motor2.spin(directionType::fwd, forwardAxis-horizontalAxis, percentUnits::pct)

For right
Motor3.spin(directionType::fwd, forwardAxis+horizontalAxis, percentUnits::pct)
Motor4.spin(directionType::fwd, forwardAxis+horizontalAxis, percentUnits::pct)

(You might need to swap the - and + or the direction tye depending on how it’s set up)

3 Likes

Did you search for “arcade”. You can find the equations that way. You want to use full range equations or you’ll saturated the motor power values quickly when turning. Like @224x said you also need a deadline which is implemented by …psuedo code…

If abs(joy-axis-x) > 12 {
  Motor.x=joy-axis-x
}

Here is an X-drive example that works for normal arcade if you remove the 9 lines of code for rotation (axis1).
https://www.robotmesh.com/studio/5be40c90c8f17a1f5796fd35

also you can find good code examples on robotmesh
ed: formatted psuedo code and added link to robotmesh (b/c i’m now using a pc and not a phone)

4 Likes

You can’t use commas to compare several conditions. Try replacing the commas with || (two straight lines, not two letter I or lowercase ls)instead, which is the or operator.

2 Likes

I’d also make those values absolute valued

2 Likes

Do motorname.spin.(directionType::fwd, all the stuff u have in (), velocityUnits::pct) for each

2 Likes

How do I change the speed of them? 32 PM

you can add deadzones or make it a cubic function (set the drive speed equal to ((axisValue/100)^3)*100)

deadzone:
if (axisValue>deadzoneVal){
arcadeCode()}
else{
motorStop()}

1 Like

I don’t think I quite understand what you are saying with the cubic function… Could you elaborate further on this?