When to invert?

Swerve Modules and Swerve Drives require some inversions to get working properly. The goal is to get everything to increase counter clockwise positive!

Swerve Motors

When you spin your motor counterclockwise the value in NetworkTables swerve/modules/.../Raw Absolute Encoder and swerve/modules/.../Raw Angle Encoder should both increase.

  • Take note of the swerve/modules/.../Raw Absolute Encoder value's and use them for absoluteEncoderOffset in the module JSONs.

Spin your module counterclockwise

Purple shows the way your bevels should be facing (photo by Team 2876)

The swerve drive should be on it's side or otherwise lifted. Your swerve module bevels must be facing the left like shown. To rotate the swerve modules they must be rotated counterclockwise like shown.

If the swerve/modules/.../Raw Angle Encoder is decreasing...

Invert your angle motor for every module that is decreasing!

{
  "drive": {
    "type": "sparkmax",
    "id": 2,
    "canbus": null
  },
  "angle": {
    "type": "sparkmax",
    "id": 1,
    "canbus": null
  },
  "encoder": {
    "type": "cancoder",
    "id": 10,
    "canbus": null
  },
  "inverted": {
    "drive": false,
    "angle": true
  },
  "absoluteEncoderInverted": false,
  "absoluteEncoderOffset": -50.977,
  "location": {
    "front": 12,
    "left": -12
  }
}

If the swerve/modules/.../Raw Absolute Encoder is decreasing...

Invert the absolute encoder in the module JSON with absoluteEncoderInverted as shown here.

{
  "drive": {
    "type": "sparkmax",
    "id": 2,
    "canbus": null
  },
  "angle": {
    "type": "sparkmax",
    "id": 1,
    "canbus": null
  },
  "encoder": {
    "type": "cancoder",
    "id": 10,
    "canbus": null
  },
  "inverted": {
    "drive": false,
    "angle": false
  },
  "absoluteEncoderInverted": true,
  "absoluteEncoderOffset": -50.977,
  "location": {
    "front": 12,
    "left": -12
  }
}

Spin your wheel counterclockwise

If the swerve/modules/.../Raw Drive Encoder is decreasing...

Invert your drive motor for every module that is decreasing!

{
  "drive": {
    "type": "sparkmax",
    "id": 2,
    "canbus": null
  },
  "angle": {
    "type": "sparkmax",
    "id": 1,
    "canbus": null
  },
  "encoder": {
    "type": "cancoder",
    "id": 10,
    "canbus": null
  },
  "inverted": {
    "drive": true,
    "angle": false
  },
  "absoluteEncoderInverted": false,
  "absoluteEncoderOffset": -50.977,
  "location": {
    "front": 12,
    "left": -12
  }
}

Rotate your robot counterclockwise

ID's relocated in swerve module files

You should notice the Raw IMU Yaw field in your driver dashboard increase. If it doesn't you need to invert your IMU like this.

{
  "imu": {
    ,
    "id": 13,
    "canbus": "canivore"
  },
  "invertedIMU": true,
  "modules": [
    "frontleft.json",
    "frontright.json",
    "backleft.json",
    "backright.json"
  ]
}

Last updated

Was this helpful?