This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from FRC-1721/pivot/commands_template
Pivot/commands template
- Loading branch information
Showing
23 changed files
with
1,091 additions
and
1,786 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Copyright (c) FIRST and other WPILib contributors. | ||
# Open Source Software; you can modify and/or share it under the terms of | ||
# the WPILib BSD license file in the root directory of this project. | ||
|
||
""" | ||
The constants module is a convenience place for teams to hold robot-wide | ||
numerical or boolean constants. Don't use this for any other purpose! | ||
""" | ||
|
||
|
||
import math | ||
|
||
from wpimath import units | ||
from wpimath.geometry import Translation2d | ||
from wpimath.kinematics import SwerveDrive4Kinematics | ||
from wpimath.trajectory import TrapezoidProfileRadians | ||
|
||
from rev import CANSparkMax | ||
|
||
|
||
class NeoMotorConstants: | ||
kFreeSpeedRpm = 5676 | ||
|
||
|
||
class DriveConstants: | ||
# Driving Parameters - Note that these are not the maximum capable speeds of | ||
# the robot, rather the allowed maximum speeds | ||
kMaxSpeedMetersPerSecond = 4.8 | ||
kMaxAngularSpeed = math.tau # radians per second | ||
|
||
kDirectionSlewRate = 1.2 # radians per second | ||
kMagnitudeSlewRate = 1.8 # percent per second (1 = 100%) | ||
kRotationalSlewRate = 2.0 # percent per second (1 = 100%) | ||
|
||
# Chassis configuration | ||
kTrackWidth = units.inchesToMeters(20.3937) | ||
# Distance between centers of right and left wheels on robot | ||
kWheelBase = units.inchesToMeters(20.25) | ||
|
||
# Distance between front and back wheels on robot | ||
kModulePositions = [ | ||
Translation2d(kWheelBase / 2, kTrackWidth / 2), | ||
Translation2d(kWheelBase / 2, -kTrackWidth / 2), | ||
Translation2d(-kWheelBase / 2, kTrackWidth / 2), | ||
Translation2d(-kWheelBase / 2, -kTrackWidth / 2), | ||
] | ||
kDriveKinematics = SwerveDrive4Kinematics(*kModulePositions) | ||
|
||
# Angular offsets of the modules relative to the chassis in radians | ||
kFrontLeftChassisAngularOffset = 0 | ||
kFrontRightChassisAngularOffset = 0 | ||
kBackLeftChassisAngularOffset = 0 | ||
kBackRightChassisAngularOffset = 0 | ||
|
||
# SPARK MAX CAN IDs | ||
kFrontLeftDrivingCanId = 5 | ||
kRearLeftDrivingCanId = 7 | ||
kFrontRightDrivingCanId = 1 | ||
kRearRightDrivingCanId = 3 | ||
|
||
kFrontLeftTurningCanId = 6 | ||
kRearLeftTurningCanId = 8 | ||
kFrontRightTurningCanId = 2 | ||
kRearRightTurningCanId = 4 | ||
|
||
kGyroReversed = False | ||
|
||
|
||
class ModuleConstants: | ||
# The MAXSwerve module can be configured with one of three pinion gears: 12T, 13T, or 14T. | ||
# This changes the drive speed of the module (a pinion gear with more teeth will result in a | ||
# robot that drives faster). | ||
kDrivingMotorPinionTeeth = 17 | ||
|
||
# Invert the turning encoder, since the output shaft rotates in the opposite direction of | ||
# the steering motor in the MAXSwerve Module. | ||
kTurningEncoderInverted = True | ||
|
||
# Calculations required for driving motor conversion factors and feed forward | ||
kDrivingMotorFreeSpeedRps = NeoMotorConstants.kFreeSpeedRpm / 60 | ||
kWheelDiameterMeters = 0.09525 | ||
kWheelCircumferenceMeters = kWheelDiameterMeters * math.pi | ||
# 45 teeth on the wheel's bevel gear, 22 teeth on the first-stage spur gear, 15 teeth on the bevel pinion | ||
kDrivingMotorReduction = (60 * 34) / (kDrivingMotorPinionTeeth * 15) | ||
kDriveWheelFreeSpeedRps = ( | ||
kDrivingMotorFreeSpeedRps * kWheelCircumferenceMeters | ||
) / kDrivingMotorReduction | ||
|
||
kDrivingEncoderPositionFactor = ( | ||
kWheelDiameterMeters * math.pi | ||
) / kDrivingMotorReduction # meters | ||
kDrivingEncoderVelocityFactor = ( | ||
(kWheelDiameterMeters * math.pi) / kDrivingMotorReduction | ||
) / 60.0 # meters per second | ||
|
||
kTurningEncoderPositionFactor = math.tau # radian | ||
kTurningEncoderVelocityFactor = math.tau / 60.0 # radians per second | ||
|
||
kTurningEncoderPositionPIDMinInput = 0 # radian | ||
kTurningEncoderPositionPIDMaxInput = kTurningEncoderPositionFactor # radian | ||
|
||
kDrivingP = 0.04 | ||
kDrivingI = 0 | ||
kDrivingD = 0 | ||
kDrivingFF = 1 / kDriveWheelFreeSpeedRps | ||
kDrivingMinOutput = -1 | ||
kDrivingMaxOutput = 1 | ||
|
||
kTurningP = 1 | ||
kTurningI = 0 | ||
kTurningD = 0.1 | ||
kTurningFF = 0 | ||
kTurningMinOutput = -1 | ||
kTurningMaxOutput = 1 | ||
|
||
kDrivingMotorIdleMode = CANSparkMax.IdleMode.kBrake | ||
kTurningMotorIdleMode = CANSparkMax.IdleMode.kBrake | ||
|
||
kDrivingMotorCurrentLimit = 50 # amp | ||
kTurningMotorCurrentLimit = 20 # amp | ||
|
||
|
||
class OIConstants: | ||
kDriverControllerPort = 0 | ||
kDriveDeadband = 0.075 | ||
|
||
|
||
class AutoConstants: | ||
kMaxSpeedMetersPerSecond = 3 | ||
kMaxAccelerationMetersPerSecondSquared = 3 | ||
kMaxAngularSpeedRadiansPerSecond = math.pi | ||
kMaxAngularSpeedRadiansPerSecondSquared = math.pi | ||
|
||
kPXController = 1 | ||
kPYController = 1 | ||
kPThetaController = 1 | ||
|
||
# Constraint for the motion profiled robot angle controller | ||
kThetaControllerConstraints = TrapezoidProfileRadians.Constraints( | ||
kMaxAngularSpeedRadiansPerSecond, kMaxAngularSpeedRadiansPerSecondSquared | ||
) |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.