FRC Paradigm Shift #1259
Documentation for the 2021 Robot
DriveConstants Namespace Reference

Variables

constexpr int kNumSwerveModules = 4
 
constexpr meter_t kTrackWidth = 23.5_in
 Distance between centers of left and right wheels on robot. More...
 
constexpr meter_t kWheelBase = 23.5_in
 Distance between centers of front and back wheels on robot. More...
 
constexpr bool kGyroReversed = false
 
constexpr double kFrontLeftOffset = 2689.0
 
constexpr double kFrontRightOffset = 205.0
 
constexpr double kRearRightOffset = 1858.0
 
constexpr double kRearLeftOffset = 983.0
 
constexpr double kPulseWidthToZeroOne = 4096.0
 
constexpr double kPulseWidthToRadians = 2.0 * wpi::math::pi / kPulseWidthToZeroOne
 
Teleop Drive Constraints
constexpr auto kDriveSpeed = meters_per_second_t(3.5)
 
constexpr auto kDriveAngularSpeed = radians_per_second_t(wpi::math::pi * 2.0)
 
CAN bus IDs

CAN IDs for swerve modules

constexpr int kCanifierID = 0
 CANifier CAN ID (for absolute encoder PWM inputs) More...
 
constexpr int kFrontLeftDriveMotorPort = 1
 Front Left Drive CAN ID (TalonFX) More...
 
constexpr int kFrontLeftTurningMotorPort = 2
 Front Left Turn CAN ID (SparkMAX) More...
 
constexpr int kFrontRightDriveMotorPort = 3
 Front Right Drive CAN ID (TalonFX) More...
 
constexpr int kFrontRightTurningMotorPort = 4
 Front Right Turn CAN ID (SparkMAX) More...
 
constexpr int kRearRightDriveMotorPort = 5
 Rear Right Drive CAN ID (TalonFX) More...
 
constexpr int kRearRightTurningMotorPort = 6
 Rear Right Turn CAN ID (SparkMAX) More...
 
constexpr int kRearLeftDriveMotorPort = 7
 Rear Left Drive CAN ID (TalonFX) More...
 
constexpr int kRearLeftTurningMotorPort = 8
 
Canifier PWM channels

PWM channels for the canifier

constexpr CANifier::PWMChannel kFrontLeftPWM = CANifier::PWMChannel::PWMChannel0
 
constexpr CANifier::PWMChannel kFrontRightPWM = CANifier::PWMChannel::PWMChannel2
 
constexpr CANifier::PWMChannel kRearRightPWM = CANifier::PWMChannel::PWMChannel1
 
constexpr CANifier::PWMChannel kRearLeftPWM = CANifier::PWMChannel::PWMChannel3
 
Drive wheel reversal (inverting) flags

To keep the swerve module bevel gear facing inwards we need to reverse the right side

constexpr bool kFrontLeftDriveMotorReversed = true
 
constexpr bool kRearLeftDriveMotorReversed = true
 
constexpr bool kFrontRightDriveMotorReversed = false
 
constexpr bool kRearRightDriveMotorReversed = false
 
Robot RotationDrive PID Controller

Rotation PID Controller for Rotation Drive, converts between radians angle error to radians per second turn

constexpr double kRotationDriveP = 1
 
constexpr double kRotationDriveI = 0
 
constexpr double kRotationDriveIMaxRange = 0
 
constexpr double kRotationDriveD = 0.025
 
constexpr double kRotationDriveMaxSpeed = 3.5
 Max speed for control. More...
 
constexpr double kRotationDriveDirectionLimit = 3
 Speeds higher than value will prevent robot from changing directions for a turn. More...
 
constexpr double kRotationDriveTolerance = 0.07
 Tolerance for turning. More...
 

Variable Documentation

constexpr int DriveConstants::kNumSwerveModules = 4

Definition at line 28 of file Constants.h.

constexpr meter_t DriveConstants::kTrackWidth = 23.5_in

Distance between centers of left and right wheels on robot.

Definition at line 31 of file Constants.h.

constexpr meter_t DriveConstants::kWheelBase = 23.5_in

Distance between centers of front and back wheels on robot.

Definition at line 33 of file Constants.h.

constexpr auto DriveConstants::kDriveSpeed = meters_per_second_t(3.5)

Definition at line 36 of file Constants.h.

constexpr auto DriveConstants::kDriveAngularSpeed = radians_per_second_t(wpi::math::pi * 2.0)

Definition at line 37 of file Constants.h.

constexpr int DriveConstants::kCanifierID = 0

CANifier CAN ID (for absolute encoder PWM inputs)

Definition at line 42 of file Constants.h.

constexpr int DriveConstants::kFrontLeftDriveMotorPort = 1

Front Left Drive CAN ID (TalonFX)

Definition at line 44 of file Constants.h.

constexpr int DriveConstants::kFrontLeftTurningMotorPort = 2

Front Left Turn CAN ID (SparkMAX)

Definition at line 45 of file Constants.h.

constexpr int DriveConstants::kFrontRightDriveMotorPort = 3

Front Right Drive CAN ID (TalonFX)

Definition at line 47 of file Constants.h.

constexpr int DriveConstants::kFrontRightTurningMotorPort = 4

Front Right Turn CAN ID (SparkMAX)

Definition at line 48 of file Constants.h.

constexpr int DriveConstants::kRearRightDriveMotorPort = 5

Rear Right Drive CAN ID (TalonFX)

Definition at line 50 of file Constants.h.

constexpr int DriveConstants::kRearRightTurningMotorPort = 6

Rear Right Turn CAN ID (SparkMAX)

Definition at line 51 of file Constants.h.

constexpr int DriveConstants::kRearLeftDriveMotorPort = 7

Rear Left Drive CAN ID (TalonFX)

Definition at line 53 of file Constants.h.

constexpr int DriveConstants::kRearLeftTurningMotorPort = 8

Rear Left Turn CAN ID (SparkMAX)

Definition at line 54 of file Constants.h.

constexpr CANifier::PWMChannel DriveConstants::kFrontLeftPWM = CANifier::PWMChannel::PWMChannel0

Definition at line 60 of file Constants.h.

constexpr CANifier::PWMChannel DriveConstants::kFrontRightPWM = CANifier::PWMChannel::PWMChannel2

Definition at line 61 of file Constants.h.

constexpr CANifier::PWMChannel DriveConstants::kRearRightPWM = CANifier::PWMChannel::PWMChannel1

Definition at line 62 of file Constants.h.

constexpr CANifier::PWMChannel DriveConstants::kRearLeftPWM = CANifier::PWMChannel::PWMChannel3

Definition at line 63 of file Constants.h.

constexpr bool DriveConstants::kFrontLeftDriveMotorReversed = true

Definition at line 69 of file Constants.h.

constexpr bool DriveConstants::kRearLeftDriveMotorReversed = true

Definition at line 70 of file Constants.h.

constexpr bool DriveConstants::kFrontRightDriveMotorReversed = false

Definition at line 71 of file Constants.h.

constexpr bool DriveConstants::kRearRightDriveMotorReversed = false

Definition at line 72 of file Constants.h.

constexpr bool DriveConstants::kGyroReversed = false

Definition at line 75 of file Constants.h.

constexpr double DriveConstants::kFrontLeftOffset = 2689.0

Definition at line 88 of file Constants.h.

constexpr double DriveConstants::kFrontRightOffset = 205.0

Definition at line 89 of file Constants.h.

constexpr double DriveConstants::kRearRightOffset = 1858.0

Definition at line 90 of file Constants.h.

constexpr double DriveConstants::kRearLeftOffset = 983.0

Definition at line 91 of file Constants.h.

constexpr double DriveConstants::kPulseWidthToZeroOne = 4096.0

Definition at line 98 of file Constants.h.

constexpr double DriveConstants::kPulseWidthToRadians = 2.0 * wpi::math::pi / kPulseWidthToZeroOne

Definition at line 99 of file Constants.h.

constexpr double DriveConstants::kRotationDriveP = 1

Definition at line 104 of file Constants.h.

constexpr double DriveConstants::kRotationDriveI = 0

Definition at line 105 of file Constants.h.

constexpr double DriveConstants::kRotationDriveIMaxRange = 0

Definition at line 106 of file Constants.h.

constexpr double DriveConstants::kRotationDriveD = 0.025

Definition at line 107 of file Constants.h.

constexpr double DriveConstants::kRotationDriveMaxSpeed = 3.5

Max speed for control.

Definition at line 109 of file Constants.h.

constexpr double DriveConstants::kRotationDriveDirectionLimit = 3

Speeds higher than value will prevent robot from changing directions for a turn.

Definition at line 111 of file Constants.h.

constexpr double DriveConstants::kRotationDriveTolerance = 0.07

Tolerance for turning.

Definition at line 113 of file Constants.h.