Joystick or Code Strange Behavior -- Rotation Bound to X axis however Y axis on joystick causes Rotation

So over the past couple of days we have seen a worsening problem. We are running SDS Mk4i and have had very little problem to date. We have based our code of of 364. Here is our git repository: 5804 Charged Up

We have initialized our joysticks:

/* Controllers /
public final XboxController driver1 = new XboxController(0);
private final Joystick buttonBoard = new Joystick(1); //maybe 2 idk fix the ports
private final Joystick driver2 = new Joystick(2);
Trigger exampleTrigger = new Trigger(() → driver1.getLeftTriggerAxis() > 0.5
);
/
Drive Controls */
private final int translationAxis = XboxController.Axis.kLeftY.value;
private final int strafeAxis = XboxController.Axis.kLeftX.value;
private final int rotationAxis = XboxController.Axis.kRightX.value;

and then set our default Command here

s_Swerve.setDefaultCommand(
new TeleopSwerve(
s_Swerve,
() → -driver1.getRawAxis(translationAxis),
() → -driver1.getRawAxis(strafeAxis),
() → -driver1.getRawAxis(rotationAxis),
() → back1.getAsBoolean(),
() → driver1.getLeftTriggerAxis()
)
);

As you can see we are binding the strafe to the right stick x axis on the xbox controller. However over the past few days a worsening problem has started to pop up. Even though we are mapped to the x axis, when in teleop the x axis will not cause a rotation. (We had good and normal behavior prior to a couple of days ago). Instead we found that the Y axis on the right stick is now causing the rotation. (This was a random behavior that has now become more persistent.) When looking at the joystick on the driver station, moving the X axis on the joystick is seen by the driver station as the x axis and same for the y axis. Even when power cycling robot, deploying code and rebooting computer the error continues. The suddenly it is ok.

We did an experiment when we bound the right stick y axis to the rotation command. When we did this neither the x or y axis would cause the rotation.

We have also changed joysticks with no luck.

Has anyone seen any behavior like this? One thing that we did do when this started is we wrote some code for the dpad to control the swerve drive in a fine tuning way. This was done around the time the behavior started.

Any help would be appreciated.

I’ve been having a similar problem on the Logitech F310 controllers. We have a tank drive, with truing on the right X stick. Its been switching to the right Y stick, and I have not been able to find a cause or solution…

Are you aware of CommandXboxController / leftTrigger() and rightTrigger() not triggering - #50 by StarbuckBarista

1 Like

Thanks–It looks like we could be having the same issue. We will test to see if rescan “fixes” the problem.