Controllers reverse in autonomous and teleop

We have been struggling with an odd issue. We have found that the motor controllers seem to switch whether positive is forward or reverse depending on whether the robot is in autonomous or teleop mode. We refer to this as the “run-over-Emily” feature (I won’t explain how it came to have that name other than to comment that it was a good thing Emily studies dance and has good reflexes). We would like to understand how and why this is happening and whether it is documented. And of course, whether it is even a thing or if we are just doing something wrong. Has anyone else noticed this problem?

And how do you think the motor controllers would even know if they are receiving commands during Autonomous versus during Teleop?
Only your code can do that.

I’d recommend posting your robot code, it may be an issue of an axis being sent wrong or something. Not to mention if your running omni or mecanum it can be really complicated.

If you mean the value that you pass to your motor controllers seems to be inverted, I’d take a look the values you’re receiving from your joystick. If I remember correctly, forward on a joystick tends to be a negative number. Therefore, your robot is most likely setup so that a negative command to the drive system is actually forward. This could cause you to believe that sending a positive value in autonomous should go forward but actually sends you backwards.

Are you perhaps running SRXs in different modes (e.g. percent output vs closed loop speed) in teleop vs auto? Some of the motor inversion methods only act on certain modes.

In any case, posting your code or a link to your code repository would help cut the guesswork.

This.

Also, put the robot up on blocks, run both modes, and watch the colors of the LED’s on the motor controllers. One color means it’s getting a forward command, another means it’s getting a reverse command. If the colors are different teleop vs. Auto, it means that something upstream is sending different commands to the controller based on whether it’s teleop or auto.

That “something upstream” is very likely something unique to your team, and therefor most likely the user code. For it to be anything that impacts multiple teams would have caused a lot more folks to be posting on this forum about it :slight_smile:

The gamepad axes send -1 when pushed all the way forward and +1 when pulled all the way back. Meanwhile, we tend to think of + as forwards and - as reverse (especially when writing autonomous code). If you have set “inverted” on your controller classes so that when they get the - from OI in teleop the motors go forwards, then in auto when you send + (intending to go forwards) they will of course go backwards.

The cleanest solution we have come up with for this problem is to reverse the sign in OI so that when the joystick is pushed forwards OI returns a positive number. That way our DriveTrain subsystem always works in the “+ means forwards” frame of reference.


    public double getRightSpeed() {
        double speed = -getSpeedFromAxis(driverGamepad, ButtonNumbers.RIGHT_AXIS);
.
.
.    }

We use tank drive, but the same concept would apply to arcade.