wpilibsuite/wpilib-ws-robot-romi

Right motor inversion doesn't work

sciencewhiz opened this issue · 2 comments

As reported in wpilibsuite/frc-docs#1571, the right motor isn't inverted on the Romi. Note that I haven't tested this, but looking through the firmware it looks to be true.

Here it calls the RomiMotor call to flight the right motor.

motors.flipRightMotor(true);

However, the RomiMotor class isn't actually used to write the values to the motor. Instead the Servo class is used here:
pwms[i].write(map(rPiLink.buffer.extIoValues[i], -400, 400, 0, 180));

Thus the inversion would need to be implemented before the call to the Servo class in order for it to be used.

This may have been masked previously since DifferentialDrive inverted automatically, but that was removed for 2022.

Closing this. The servo class is only used if any of the 5 available GPIO pins are configured as PWM outputs. The motors are controlled via the RomiMotor class:

motors.setSpeeds(rPiLink.buffer.leftMotor, rPiLink.buffer.rightMotor);

Thus if both motors are given the exact same value, they should spin in opposing directions

To close the loop. The right motor is inverted on the Romi 32U4 board, so this uninverts it to act more like a typical FRC robot that is wired red to red. Thus software inversion is necessary, and the previous comment on frc-docs was wrong about not needing to invert the right motor.