Skip to content

Latest commit

 

History

History
68 lines (53 loc) · 4.5 KB

swerve-module-configuration.md

File metadata and controls

68 lines (53 loc) · 4.5 KB

Swerve Module Configuration

Swerve Module Configuration (module/x.json)

The swerve module configuration configures unique properties of each swerve module. It maps 1:1 with ModuleJson which is used to create SwerveModuleConfiguration. This configuration file interacts directly with swerve kinematics.

{% hint style="warning" %} IF your angle motors spin out of control then you may need to invert them in inverted {% endhint %}

{% hint style="warning" %} IF your drive motors spin uncontrollably you may have the drive motor set to be the angle motor via the ID's. Be sure to check them! {% endhint %}

Fields

NameUnitsRequiredDescription
driveMotor ControllerYDrive motor device configuration.
angleMotor ControllerYAngle motor device configuration.
encoderAbsolute EncoderYAbsolute encoder device configuration.
invertedMotorConfigYInversion state of each motor as a boolean.
absoluteEncoderOffsetDegreesYAbsolute encoder offset from 0 in degrees. May need to be a negative number.
absoluteEncoderInvertedBoolNInversion state of the Absolute Encoder.
locationLocationYThe location of the swerve module from the center of the robot in inches. +x is torwards the robot front, and +y is torwards robot left.
conversionFactorsConversion Factor Composition
Overrides the value in physicalproperties.json if present and not equal to 0.
NOVERRIDE Conversion factors applied to the motor controller for the onboard PID, used to override this setting in swervedrive.json
useCosineCompensatorBoolNDisabled cosine compensation which scales the velocity of modules which are not completely aligned with desired angles by the cosine of the difference between the angles.

MotorConfig

Name Units Required Description
drive Value Y Drive motor value.
angle Value Y Angle motor value.

Location

Name Units Required Description
front Value Y Inches from robot center to module in forward direction.
left Value Y Inches from robot center to module in left direction.

Example Configuration

{
  "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": false,
  "absoluteEncoderOffset": -50.977,
  "location": {
    "front": 12,
    "left": -12
  }
}