{% hint style="danger" %} Make sure your CAN ID's are unique! There is a known issue where if the CAN ID of your REV Power Distribution Hub is the same as the CAN ID of the SparkMAX it will cause the SparkMAX to not move the motor! {% endhint %}
There is no easier way to screw up configuring a swerve drive (or any other kind of drive system) than putting the wrong channel number, CAN ID, or even CAN bus (if your device is on a CANivore) for a component whether it is the drive motor, angle motor, absolute encoder, or gyroscope. Some components don't have ID's like NavX's and instead have a few different type
's which define the connection method (navx_spi
, navx_usb
, navx_i2c
) these just have to be known beforehand.
I strongly suggest you find the information from the getting-to-know-your-robotsheet before you start configuring your robot.
The left and right are physical left and right.
When you spin your motor while the robot is disabled you will notice swerve/modules/.../Raw Angle Encoder
(angle/steering/azimuth relative encoder) and swerve/modules/.../Raw Absolute Encoder
(absolute encoder) . Both of these should increase while the motor is spun counter clockwise. For more information see here.
{% content-ref url="../configuring-yagsl/when-to-invert.md" %} when-to-invert.md {% endcontent-ref %}
Conversion factors are applied to your motor convert from native units (usually rotations) to degrees for steering/azimuth/angle motors, and meters for drive motors. Conversion factors are only relevant to motor controllers, except if there is an absolute encoder attached to your motor controller.
The absolute encoder offset is what allows your swerve module to maintain the wheel orientation between power offs. It is vital to a functioning swerve drive.
- Line up all wheels so that the bevels are facing to the left like this.
- Deploy your code.
- DO NOT ENABLE YOUR ROBOT!
- Open shuffleboard.
<figure><img src="../.gitbook/assets/shuffleboard_open_tab.png" alt=""><figcaption></figcaption></figure>
<figure><img src="../.gitbook/assets/ShuffleboardAbsoluteEncoderHighlight.png" alt=""><figcaption><p>swerve/modules/... view in Shuffleboard</p></figcaption></figure>
- Take note of the
swerve/modules/.../Raw Absolute Encoder
value's and use them forabsoluteEncoderOffset
in the module JSONs.
{% hint style="warning" %}
When you align using the MAXSwerveModules and find the absoluteEncoderOffset
for each module you may need to +/-90
from the absoluteEncoderOffset
to correct the module position. The absoluteEncoderInverted
must also be true
in every module configuration as well.
{
"drive": {
"type": "sparkmax",
"id": 12,
"canbus": null
},
"angle": {
"type": "sparkmax",
"id": 11,
"canbus": null
},
"encoder": {
"type": "attached",
"id": 0,
"canbus": null
},
"inverted": {
"drive": false,
"angle": false
},
"absoluteEncoderInverted": true,
"absoluteEncoderOffset": -90,
"location": {
"front": 12,
"left": -12
}
}
{% endhint %}