mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[wpilib] Rename OnboardIMU constants to all caps
This commit is contained in:
@@ -12,8 +12,8 @@ import wpimath
|
||||
class Drivetrain:
|
||||
"""Represents a mecanum drive style drivetrain."""
|
||||
|
||||
kMaxVelocity = 3.0 # 3 meters per second
|
||||
kMaxAngularVelocity = math.pi # 1/2 rotation per second
|
||||
MAX_VELOCITY = 3.0 # 3 meters per second
|
||||
MAX_ANGULAR_VELOCITY = math.pi # 1/2 rotation per second
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.frontLeftMotor = wpilib.PWMSparkMax(1)
|
||||
@@ -36,7 +36,7 @@ class Drivetrain:
|
||||
self.backLeftPIDController = wpimath.PIDController(1, 0, 0)
|
||||
self.backRightPIDController = wpimath.PIDController(1, 0, 0)
|
||||
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.kFlat)
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.FLAT)
|
||||
|
||||
self.kinematics = wpimath.MecanumDriveKinematics(
|
||||
self.frontLeftLocation,
|
||||
@@ -121,7 +121,7 @@ class Drivetrain:
|
||||
self.setVelocities(
|
||||
self.kinematics.toWheelVelocities(
|
||||
chassisVelocities.discretize(periodSeconds)
|
||||
).desaturate(self.kMaxVelocity)
|
||||
).desaturate(self.MAX_VELOCITY)
|
||||
)
|
||||
|
||||
def updateOdometry(self) -> None:
|
||||
|
||||
@@ -35,7 +35,7 @@ class MyRobot(wpilib.TimedRobot):
|
||||
# negative values when we push forward.
|
||||
xVelocity = (
|
||||
-self.xvelocityLimiter.calculate(self.controller.getLeftY())
|
||||
* Drivetrain.kMaxVelocity
|
||||
* Drivetrain.MAX_VELOCITY
|
||||
)
|
||||
|
||||
# Get the y velocity or sideways/strafe velocity. We are inverting this because
|
||||
@@ -43,7 +43,7 @@ class MyRobot(wpilib.TimedRobot):
|
||||
# return positive values when you pull to the right by default.
|
||||
yVelocity = (
|
||||
-self.yvelocityLimiter.calculate(self.controller.getLeftX())
|
||||
* Drivetrain.kMaxVelocity
|
||||
* Drivetrain.MAX_VELOCITY
|
||||
)
|
||||
|
||||
# Get the rate of angular rotation. We are inverting this because we want a
|
||||
@@ -52,7 +52,7 @@ class MyRobot(wpilib.TimedRobot):
|
||||
# the right by default.
|
||||
rot = (
|
||||
-self.rotLimiter.calculate(self.controller.getRightX())
|
||||
* Drivetrain.kMaxAngularVelocity
|
||||
* Drivetrain.MAX_ANGULAR_VELOCITY
|
||||
)
|
||||
|
||||
self.mecanum.drive(xVelocity, yVelocity, rot, fieldRelative, self.getPeriod())
|
||||
|
||||
Reference in New Issue
Block a user