V5 Errors

I’ve been using PROS for a few months now, and I have just come upon a problem. Whenever I upload the code, the program is almost always the same - the wheels respond to the opposite joystick, and they move reversed. I’ve tried everything I can think of…
Here’s the setup code:

void opcontrol() {
Motor ld (1, E_MOTOR_GEARSET_18, true);
Motor rd (10, E_MOTOR_GEARSET_18, false);
Controller controller (E_CONTROLLER_MASTER);

And here’s the actual code:

while (true) {
/* Drive */
ld.set_brake_mode(E_MOTOR_BRAKE_HOLD);
rd.set_brake_mode(E_MOTOR_BRAKE_HOLD);
while(1){
if(controller.get_analog(E_CONTROLLER_ANALOG_RIGHT_Y)){
rd.move(controller.get_analog(E_CONTROLLER_ANALOG_RIGHT_Y));
}
else if(controller.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)){
ld.move(controller.get_analog(E_CONTROLLER_ANALOG_LEFT_Y));
}
else{
ld.move_velocity(0);
rd.move_velocity(0);
}
}
}
}

Would be great if anyone could help!

I would suggest the possibility of trying this (I may be wrong, as this is coded from memory):

rightY = controller.get_analog(E_CONTROLLER_ANALOG_RIGHT_Y);
leftY = controller.get_analog(E_CONTROLLER_ANALOG_LEFT_Y);

if(abs(rightY) < 10){
rd = 0;
rd.set_brake_mode(E_MOTOR_BRAKE_HOLD);
}
else{
rd = rightY;
}

if(abs(leftY) < 10){
ld = 0;
ld.set_brake_mode(E_MOTOR_BRAKE_HOLD);
}
else{
ld = leftY;
}

If the motors are going the opposite direction, in the setup, adding a “true” will reverse the motor:

pros::Motor right_wheels (11, true); // This reverses the motor

If they are responding to the opposite joystick, then you likely got wiring mixed up, so I would suggest swapping the ports for the rd and ld in the config.

1 Like