mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Rename OnboardIMU constants to all caps
This commit is contained in:
@@ -37,7 +37,7 @@ class Drivetrain:
|
||||
self.leftEncoder = wpilib.Encoder(0, 1)
|
||||
self.rightEncoder = wpilib.Encoder(2, 3)
|
||||
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.kFlat)
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.FLAT)
|
||||
|
||||
self.leftPIDController = wpimath.PIDController(1.0, 0.0, 0.0)
|
||||
self.rightPIDController = wpimath.PIDController(1.0, 0.0, 0.0)
|
||||
|
||||
@@ -33,7 +33,7 @@ class Drivetrain:
|
||||
self.leftEncoder = wpilib.Encoder(0, 1)
|
||||
self.rightEncoder = wpilib.Encoder(2, 3)
|
||||
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.kFlat)
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.FLAT)
|
||||
|
||||
self.leftPIDController = wpimath.PIDController(1, 0, 0)
|
||||
self.rightPIDController = wpimath.PIDController(1, 0, 0)
|
||||
|
||||
@@ -20,7 +20,7 @@ class MyRobot(wpilib.TimedRobot):
|
||||
|
||||
kLeftMotorPort = 0
|
||||
kRightMotorPort = 1
|
||||
kIMUMountOrientation = wpilib.OnboardIMU.MountOrientation.kFlat
|
||||
kIMUMountOrientation = wpilib.OnboardIMU.MountOrientation.FLAT
|
||||
kJoystickPort = 0
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -19,7 +19,7 @@ class MyRobot(wpilib.TimedRobot):
|
||||
kRearLeftChannel = 1
|
||||
kFrontRightChannel = 2
|
||||
kRearRightChannel = 3
|
||||
kIMUMountOrientation = wpilib.OnboardIMU.MountOrientation.kFlat
|
||||
kIMUMountOrientation = wpilib.OnboardIMU.MountOrientation.FLAT
|
||||
kJoystickPort = 0
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
||||
@@ -16,8 +16,8 @@ from exampleglobalmeasurementsensor import ExampleGlobalMeasurementSensor
|
||||
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)
|
||||
@@ -40,7 +40,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,
|
||||
@@ -146,7 +146,7 @@ class Drivetrain:
|
||||
self.setVelocities(
|
||||
self.kinematics.toWheelVelocities(
|
||||
chassisVelocities.discretize(period)
|
||||
).desaturate(self.kMaxVelocity)
|
||||
).desaturate(self.MAX_VELOCITY)
|
||||
)
|
||||
|
||||
def updateOdometry(self) -> None:
|
||||
|
||||
@@ -34,19 +34,19 @@ class MyRobot(wpilib.TimedRobot):
|
||||
# Get the x velocity. We are inverting this because Xbox controllers return
|
||||
# negative values when we push forward.
|
||||
xVelocity = -self.xvelocityLimiter.calculate(self.controller.getLeftY())
|
||||
xVelocity *= Drivetrain.kMaxVelocity
|
||||
xVelocity *= Drivetrain.MAX_VELOCITY
|
||||
|
||||
# Get the y velocity or sideways/strafe velocity. We are inverting this because
|
||||
# we want a positive value when we pull to the left. Xbox controllers
|
||||
# return positive values when you pull to the right by default.
|
||||
yVelocity = -self.yvelocityLimiter.calculate(self.controller.getLeftX())
|
||||
yVelocity *= Drivetrain.kMaxVelocity
|
||||
yVelocity *= Drivetrain.MAX_VELOCITY
|
||||
|
||||
# Get the rate of angular rotation. We are inverting this because we want a
|
||||
# positive value when we pull to the left (remember, CCW is positive in
|
||||
# mathematics). Xbox controllers return positive values when you pull to
|
||||
# the right by default.
|
||||
rot = -self.rotLimiter.calculate(self.controller.getRightX())
|
||||
rot *= Drivetrain.kMaxAngularVelocity
|
||||
rot *= Drivetrain.MAX_ANGULAR_VELOCITY
|
||||
|
||||
self.mecanum.drive(xVelocity, yVelocity, rot, fieldRelative, self.getPeriod())
|
||||
|
||||
@@ -43,7 +43,7 @@ class Drive(Subsystem):
|
||||
DriveConstants.kRightEncoderReversed,
|
||||
)
|
||||
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.kFlat)
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.FLAT)
|
||||
self.controller = wpimath.ProfiledPIDController(
|
||||
DriveConstants.kTurnP,
|
||||
DriveConstants.kTurnI,
|
||||
|
||||
@@ -35,7 +35,7 @@ class Drivetrain:
|
||||
self.leftPIDController = wpimath.PIDController(8.5, 0, 0)
|
||||
self.rightPIDController = wpimath.PIDController(8.5, 0, 0)
|
||||
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.kFlat)
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.FLAT)
|
||||
|
||||
self.kinematics = wpimath.DifferentialDriveKinematics(self.kTrackwidth)
|
||||
self.odometry = wpimath.DifferentialDriveOdometry(
|
||||
|
||||
@@ -29,7 +29,7 @@ class Drivetrain:
|
||||
self.backLeft = swervemodule.SwerveModule(5, 6, 8, 9, 10, 11)
|
||||
self.backRight = swervemodule.SwerveModule(7, 8, 12, 13, 14, 15)
|
||||
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.kFlat)
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.FLAT)
|
||||
|
||||
self.kinematics = wpimath.SwerveDrive4Kinematics(
|
||||
self.frontLeftLocation,
|
||||
|
||||
@@ -31,7 +31,7 @@ class Drivetrain:
|
||||
self.backLeft = swervemodule.SwerveModule(5, 6, 8, 9, 10, 11)
|
||||
self.backRight = swervemodule.SwerveModule(7, 8, 12, 13, 14, 15)
|
||||
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.kFlat)
|
||||
self.imu = wpilib.OnboardIMU(wpilib.OnboardIMU.MountOrientation.FLAT)
|
||||
|
||||
self.kinematics = wpimath.SwerveDrive4Kinematics(
|
||||
self.frontLeftLocation,
|
||||
|
||||
Reference in New Issue
Block a user