Swerve drive wheel angle when stick is released

We are working on getting a swerve drive system up and running and notice that the swerve modules will rotate to some random angle when the strafing stick is released. That makes sense since there is no joystick angle to calculate. It’s not a huge problem but it would be nice to have the module maintain the same angle from just before the stick reached the zero position.

We tried using a deadband and not updating the angle after entering the deadband but the joystick does not follow a linear path to zero, so it helps a little but without an unacceptably large deadband there is still some rotation when the stick is released. We have been working with a Switch and an Xbox controller.

How have other teams dealt with this? Are other controller less prone to this issue, or do we just accept it?

1 Like

Um yeah pretty much I just added a deadband to mine and it worked very well.

  if(Math.abs(xSpeed) + Math.abs(ySpeed) + Math.abs(rot) < Constants.DriveConstants.swerveThreshold){
  swerveModuleStates[0].speedMetersPerSecond = 0;
  swerveModuleStates[0].angle = lStates[0].angle;
  swerveModuleStates[1].speedMetersPerSecond = 0;
  swerveModuleStates[1].angle = lStates[1].angle;

  swerveModuleStates[2].speedMetersPerSecond = 0;
  swerveModuleStates[2].angle = lStates[2].angle;
  swerveModuleStates[3].speedMetersPerSecond = 0;
  swerveModuleStates[3].angle = lStates[3].angle;

  freezeDrive = true;
}

Here lStates is an array of the previous module states before deadband was triggered.

For what it’s worth we used Logitech controllers, not sure if that makes a difference

Thank you. It looks pretty similar to what we did, although we don’t track the previous angle directly. We use the rotational rate to update a heading setpoint, and control the rotation by heading angle. We just zero the rotational rate, and that keeps the heading setpoint from changing.

We’ll keep playing around with it, and check out the differences between the joysticks.