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
  • Getting Started
  • Documentation
  • Tuning PID
  • YAGSL Checklist
  • Communication
  • Module example configuration
  • Example pidfproperties.json
  • Example physicalproperties.json

Was this helpful?

Edit on GitHub
  1. Devices
  2. Motor Controllers

SparkFlex

PreviousSparkMAXNextTalonFX

Last updated 4 months ago

Was this helpful?

This page refers to the REV Spark Flex while attached to a BRUSHLESS MOTOR (REV Vortex's) .

Getting Started

import com.revrobotics.CANSparkFlex;
import com.revrobotics.CANSparkLowLevel.MotorType;


new CANSparkFlex(, MotorType.kBrushless);

Documentation

The Spark Flex allows you to test the motor controller PID, run the motor at a set percentage, and update the firmware all from the REV Hardware Client. Installation of the REV Hardware client is required to use the SparkFlex for YAGSL.

The Spark Flex must be disconnected from the CAN bus on startup to run via the REV Hardware Client!

Tuning PID

To tune the PID of the Spark Flex you need to open up the REV Hardware Client select the Spark Flex then open the telemetry tab and set it to position control while messing with the parameters in the lefthand pane.

YAGSL Checklist

Communication

The Spark Flex is only capable of communicating via CAN and may see some exciting new features soon with CAN FD support!

Module example configuration

The following example is one for a module configuration file, e.g. frontleft.json, frontright.json, backleft.json, and backright.json.

{
  "drive": {
    "type": ,
    "id": ,
    "canbus": 
  },
  "angle": {
    "type": ,
    "id": ,
    "canbus": 
  },
  "encoder": {
    "type": "cancoder",
    "id": 11,
    "canbus": null
  },
  "inverted": {
    "drive": ,
    "angle": 
  },
  "absoluteEncoderOffset": -18.281,
  "location": {
    "front": -12,
    "left": -12
  }
}

Example pidfproperties.json

{
  "drive": {
    "p": ,
    "i": ,
    "d": ,
    "f": ,
    "iz": 0
  },
  "angle": {
    "p": ,
    "i": ,
    "d": ,
    "f": ,
    "iz": 0
  }
}

Example physicalproperties.json

{
  "conversionFactor": {
    "drive": ,
    "angle": 
  },
  "currentLimit": {
    "drive": ,
    "angle": 
  },
  "rampRate": {
    "drive": ,
    "angle": 
  },
  "wheelGripCoefficientOfFriction": 1.19,
  "optimalVoltage": 12
}

An small example program to create a object is as follows.

CANSparkFlex
Introducing the Next Generation of SPARK & NEO
Logo
NEO Vortex Brushless MotorREV Robotics
Logo
SPARK Flex Motor ControllerREV Robotics
Logo
InstallationREV Hardware Client
REV Hardware Client Installation guide + download
Make it Spin!REV ION Brushless
Make it spin using the REV Hardware Client
Telemetry TabREV Hardware Client
Logo
Logo
Logo