YAGSL
  • Welcome to Yet Another Swerve Document
    • Resources
  • Overview
    • What we do
    • Our Features
      • Telemetry
      • Simulation
      • Lock Pose
      • Max Speed
      • Chassis Speed Discretization
      • Vision Odometry
      • Heading Correction
      • Auto-centering Modules
      • Offset Offloading
      • Cosine Compensation
      • Module Auto-synchronization
      • Angular Velocity Compensation
    • Changelog
    • Java API
    • Example Code
    • Config Generator
    • 💸Donations
    • 👕Merch
    • Discord
  • Fundamentals
    • Swerve Drive
    • Swerve Modules
  • Bringing up swerve
    • Preface
    • Swerve Information
    • Check your gyroscope
    • Check your motors
    • Creating your first configuration
  • Configuring YAGSL
    • Getting to know your robot
      • Gear Ratio
    • Dependency Installation
    • Configuration
      • Swerve Drive Configuration
      • Physical Properties Configuration
      • PIDF Properties Configuration
        • PIDF
      • Swerve Module Configuration
      • Controller Properties Configuration
      • Device Configuration
    • Code Setup
    • Standard Conversion Factors
    • How to tune PIDF
    • When to invert?
    • Flowcharts
    • The eight steps
    • Swerve Drive Drift
    • SparkMAX Common Problems
    • Verifying your Module Locations
    • Tuning out Drift
  • Devices
    • Gyroscope
      • NavX
      • Pigeon
      • Pigeon 2.0
      • ADXRS450
      • ADIS16448
      • ADIS16470
    • Motor Controllers
      • SparkMAX
      • SparkFlex
      • TalonFX
    • Absolute Encoders
  • Analytics and Debugging
    • FRC Web Components
    • Advantage Scope
  • Product Guides
    • Java API
    • PathPlanner
    • ❌Tuning PID with REV Hardware Client
    • ❌Drive Code
  • Legacy Documentation
Powered by GitBook
On this page
  • Make sure you know what module is what!
  • Orient your swerve modules correctly!
  • Configuration Directory
  • JSON Files
  • What does the swerve directory need to look like?
  • Migrating Old Configuration Files

Was this helpful?

Edit on GitHub
  1. Configuring YAGSL

Configuration

PreviousDependency InstallationNextSwerve Drive Configuration

Last updated 3 months ago

Was this helpful?

Tuning Webpage

YAGSL maintains a somewhat complete configuration tool to aid you in creating configuration files from scratch here.

From this webpage you should be able to download all files and place them into your deploy directory to use for .

We also maintain a repository for known working configurations here!

Make sure you know what module is what!

If not your modules could end up like this!.

This happens when you input module locations incorrectly due to where the gyroscope is oriented on the robot or you have the device configurations in the wrong module locations in the configuration files. If this happens to you, you HAVE misconfigured your modules.

How to swap module configurations

For the examples we label with numbers as to be less confused, however when changing module files around we assign the numbers to the respective initial module configuration names. For the example above we have as follows

  1. frontleft.json

  2. frontright.json

  3. backleft.json

  4. backright.json

Swapping frontleft.json with backleft.json

frontleft.json
{
  "drive": {
    "type": "sparkmax",
    "id": 4,
    "canbus": null
  },
  "angle": {
    "type": "sparkmax",
    "id": 3,
    "canbus": null
  },
  "encoder": {
    "type": "cancoder",
    "id": 9,
    "canbus": null
  },
  "inverted": {
    "drive": false,
    "angle": false
  },
  "absoluteEncoderOffset": -114.609,
  "location": {
    "front": 12,
    "left": 12
  }
}
backleft.json
{
  "drive": {
    "type": "sparkmax",
    "id": 7,
    "canbus": null
  },
  "angle": {
    "type": "sparkmax",
    "id": 8,
    "canbus": null
  },
  "encoder": {
    "type": "cancoder",
    "id": 12,
    "canbus": null
  },
  "inverted": {
    "drive": false,
    "angle": false
  },
  "absoluteEncoderOffset": 6.504,
  "location": {
    "front": -12,
    "left": 12
  }
}

Swap the highlighted lines and you have swapped the module configurations correctly.

The easy way

  1. Change the location negations to the desired module side.

  2. Rename the files without overwriting eachother.

Example configuration challenge

Challenge

Here is a challenge for you, how can you solve this misconfiguration?

Solution

Steps:

  1. Invert 4 and 2.

  2. Swap 1 and 4.

This may help you in your endeavors!

Orient your swerve modules correctly!

To correctly get the absoluteEncoderOffset your swerve modules must be facing this way while reading the values.

Configuration Directory

JSON Files

What does the swerve directory need to look like?

└── swerve
    ├── controllerproperties.json
    ├── modules
    │   ├── backleft.json
    │   ├── backright.json
    │   ├── frontleft.json
    │   ├── frontright.json
    │   ├── physicalproperties.json
    │   └── pidfproperties.json
    └── swervedrive.json

Migrating Old Configuration Files

  1. Delete wheelDiamter, gearRatio, encoderPulsePerRotation from physicalproperties.json

  2. Add optimalVoltage to physicalproperties.json

  3. Delete maxSpeed and optimalVoltage from swervedrive.json

  4. IF a swerve module doesn't have the same drive motor or steering motor as the rest of the swerve drive you MUST specify a conversionFactor for BOTH the drive and steering motor in the modules configuration JSON file. IF one of the motors is the same as the rest of the swerve drive and you want to use that conversionFactor, set the conversionFactor in the module JSON configuration to 0.

  5. You MUST specify the maximum speed when creating a SwerveDrive through new SwerveParser(directory).createSwerveDrive(maximumSpeed);

  6. IF you do not want to set conversionFactor in swervedrive.json. You can pass it into the constructor as a parameter like this

double DriveConversionFactor = SwerveMath.calculateMetersPerRotation(Units.inchesToMeters(WHEEL_DIAMETER), GEAR_RATIO, ENCODER_RESOLUTION);
double SteeringConversionFactor = SwerveMath.calculateDegreesPerSteeringRotation(GEAR_RATIO, ENCODER_RESOLUTION);
new SwerveParser(directory).createSwerveDrive(maximumSpeed, SteeringConversionFactor, DriveConversionFactor);

JSON stands for "JavaScript Object Notation" it is a popular format for configuration, and string data representation. Learn more

The swerve directory for generating a swerve drive must look like this. Assuming you have defined your swerve modules as "modules": [ "frontleft.json", "frontright.json", "backleft.json", "backright.json"] in .

The modules folder, , , , and files are necessary to build the swerve drive. Each one has specific fields which correspond to an attribute of the swerve drive, some physical and some abstract.

here
swervedrive.json
controllerproperties.json
physicalproperties.json
pidfproperties.json
swervedrive.json
new SwerveParser(new File(Filesystem.getDeployDirectory(),"swerve")
.createSwerveDrive(Units.feetToMeters(4.5));
YAGSL Tuning Webpage
GitHub - BroncBotz3481/YAGSL-Configs: Known working YAGSL Configs for COTS swerve modules.GitHub
Logo
42KB
SwerveDiagram.docx
Modules flipped around, spinning CCW+
While rotating right
Translating right