How to code split arcade

Does anyone know how to code split arcade in pros? If so can you paste your code or explain how?

Here is an example of a split arcade control scheme, The way it works is by getting the values of the left joysticks Y axis and the right joysticks X axis then turning them into integers. By adding the X axis integer to the Y axis integer, we can get the power for the left side of the drive. By instead subtracting the X from the Y we can get the right side power. this method works for as many motors on each side as you want, but I chose to use a 4 motor drive as it is the most common.

void opcontrol() {
while (true) {

int power = pros::E_CONTROLLER_ANALOG_LEFT_Y;
int turn = pros::E_CONTROLLER_ANALOG_RIGHT_X;

int Left = power + turn;
int Right = power - turn;

fl.move(Left);
bl.move(Left);
fr.move(Right);
br.move(Right);
}

	pros::delay(20);
}
4 Likes

It should really be controller_get_analog() function:

int power = controller_get_analog(E_CONTROLLER_MASTER, E_CONTROLLER_ANALOG_LEFT_Y);
int turn = controller_get_analog(E_CONTROLLER_MASTER, E_CONTROLLER_ANALOG_RIGHT_X);

int Left = power + turn;
int Right = power - turn;

fl.move(Left);
bl.move(Left);
fr.move(Right);
br.move(Right);

weilin’s right, i use mecanum, so you have to code in a seperate strafing function, but yeah you need to use controller_get_analog()

1 Like