Class LibShooterDescriptor.Builder
- Enclosing class:
- LibShooterDescriptor
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder
(double pivotHeight, double rollerRadius, edu.wpi.first.math.system.plant.DCMotor gearbox, double rollerReduction, int numMotors) Constructs a new Builder. -
Method Summary
Modifier and TypeMethodDescriptionangleRange
(double minDeg, double maxDeg) Sets the vertical angle range for the shooter, in degrees.build()
Builds the ShooterDescriptor instance with the provided parameters.dataSet
(BilinearInterpolator2D angleInterpolator, BilinearInterpolator2D rpmInterpolator) Adds a fully-empirical dataset to the shooter descriptor.dataSet
(BilinearInterpolator2D angleInterpolator, BilinearInterpolator2D rpmInterpolator, edu.wpi.first.math.interpolation.InterpolatingDoubleTreeMap windupTimes) Adds a fully-empirical dataset to the shooter descriptor.flywheel
(double moi, double reduction) Sets the moment of inertia for the flywheel.hopperDelay
(double seconds) Sets the hopper delay, defined as the time it takes the game piece from the hopper to being launched, not including the spin-up time.nominalVoltage
(double value) Sets the nominal battery voltage.rollerMOI
(double value) Sets the moment of inertia for the rollers.setRPMLimits
(double maxRPM) Sets the RPM limits for the shooter.
-
Constructor Details
-
Builder
public Builder(double pivotHeight, double rollerRadius, edu.wpi.first.math.system.plant.DCMotor gearbox, double rollerReduction, int numMotors) Constructs a new Builder.- Parameters:
pivotHeight
- The height of the pivot point relative to the ground in meters.rollerRadius
- The radius of the rollers in meters.gearbox
- The DC motor gearbox for the driving motors.rollerReduction
- The reduction ratio of the rollers, where >1 is a reduction.numMotors
- The number of motors driving the shooter rollers.
-
-
Method Details
-
rollerMOI
Sets the moment of inertia for the rollers.- Parameters:
value
- The moment of inertia in kg*m^2.- Returns:
- The builder instance for chaining.
-
angleRange
Sets the vertical angle range for the shooter, in degrees.- Parameters:
minDeg
- The minimum angle in degrees.maxDeg
- The maximum angle in degrees.- Returns:
- The builder instance for chaining.
-
flywheel
Sets the moment of inertia for the flywheel. Do not use if a flywheel is not attached.- Parameters:
moi
- The moment of inertia in kg*m^2.reduction
- The reduction ratio from the flywheel to the shooter.- Returns:
- The builder instance for chaining.
-
hopperDelay
Sets the hopper delay, defined as the time it takes the game piece from the hopper to being launched, not including the spin-up time.- Parameters:
seconds
- The delay.- Returns:
- The builder instance for chaining.
-
dataSet
public LibShooterDescriptor.Builder dataSet(BilinearInterpolator2D angleInterpolator, BilinearInterpolator2D rpmInterpolator, edu.wpi.first.math.interpolation.InterpolatingDoubleTreeMap windupTimes) Adds a fully-empirical dataset to the shooter descriptor.Example arrays:
// Sorted Arrays double[] horizontalDistances = { 2.0, 3.0, 4.0, 5.0 }; // meters double[] heightDiffs = { -0.5, 0.0, +0.5, +1.0 }; // meters, relative to ground double[][] angleGrid = { // -----------------> HeightDiff (-0.5 -> +1.0) { 45, 40, 35, 30 }, // at d=2.0 { 42, 38, 33, 28 }, // at d=3.0 { 39, 35, 31, 27 }, // at d=4.0 { 37, 33, 29, 25 }, // at d=5.0 }; double[][] rpmGrid = { // -----------------> HeightDiff (-0.5 -> +1.0) { 4500, 4000, 3500, 3000 }, // at d=2.0 { 4200, 3800, 3300, 2800 }, // at d=3.0 { 3900, 3500, 3100, 2700 }, // at d=4.0 { 3700, 3300, 2900, 2500 }, // at d=5.0 } // Build windup-time map from 0->4500 RPM InterpolatingDoubleTreeMap windupTimes = new InterpolatingDoubleTreeMap(); // Always include the (0,0) point: windupTimes.put(0.0, 0.0); windupTimes.put(2500.0, 0.02703); windupTimes.put(2700.0, 0.02919); windupTimes.put(2800.0, 0.03027); windupTimes.put(2900.0, 0.03135); windupTimes.put(3000.0, 0.03244); windupTimes.put(3100.0, 0.03352); windupTimes.put(3300.0, 0.03568); windupTimes.put(3500.0, 0.03784); windupTimes.put(3700.0, 0.04000); windupTimes.put(3800.0, 0.04108); windupTimes.put(3900.0, 0.04217); windupTimes.put(4000.0, 0.04325); windupTimes.put(4200.0, 0.04541); windupTimes.put(4500.0, 0.04865);
Notes:
- The emprical data must be measured from the shooter's pivot point, not the barrel.
- The grids must be sorted in ascending order.
- The wind-up times must have the data point (0, 0).
- The data should be large enough to avoid extrapolation due to out-of-bounds data, which may lead to significant inacuracies.
- The RPM speeds use the roller RPMs.
- Parameters:
angleInterpolator
- The bilinear interpolator for the angles, as described above.rpmInterpolator
- The bilinear interpolator for the RPMs, as described above.windupTimes
- The time it takes the motors to spin up to the given RPM from 0 RPM.- Returns:
- The builder instance for chaining.
-
dataSet
public LibShooterDescriptor.Builder dataSet(BilinearInterpolator2D angleInterpolator, BilinearInterpolator2D rpmInterpolator) Adds a fully-empirical dataset to the shooter descriptor. Assumes the wind-up times are negligible.Example arrays:
// Sorted Arrays double[] horizontalDistances = { 2.0, 3.0, 4.0, 5.0 }; // meters double[] heightDiffs = { -0.5, 0.0, +0.5, +1.0 }; // meters, relative to ground double[][] angleGrid = { // -----------------> HeightDiff (-0.5 -> +1.0) { 45, 40, 35, 30 }, // at d=2.0 { 42, 38, 33, 28 }, // at d=3.0 { 39, 35, 31, 27 }, // at d=4.0 { 37, 33, 29, 25 }, // at d=5.0 }; double[][] rpmGrid = { // -----------------> HeightDiff (-0.5 -> +1.0) { 4500, 4000, 3500, 3000 }, // at d=2.0 { 4200, 3800, 3300, 2800 }, // at d=3.0 { 3900, 3500, 3100, 2700 }, // at d=4.0 { 3700, 3300, 2900, 2500 }, // at d=5.0 }
Notes:
- The emprical data must be measured from the shooter's pivot point, not the barrel.
- The grids must be sorted in ascending order.
- The wind-up times must have the data point (0, 0).
- The data should be large enough to avoid extrapolation due to out-of-bounds data, which may lead to significant inacuracies.
- The RPM speeds use the roller RPMs.
- Parameters:
angleInterpolator
- The bilinear interpolator for the angles, as described above.rpmInterpolator
- The bilinear interpolator for the RPMs, as described above.- Returns:
- The builder instance for chaining.
-
nominalVoltage
Sets the nominal battery voltage.- Parameters:
value
- The nominal voltage in Volts, typically 12V - 12.5V.- Returns:
- The builder instance for chaining.
-
setRPMLimits
Sets the RPM limits for the shooter. Defaults to the value computed viamaxRPM/reduction
, the hardware maximum.- Parameters:
maxRPM
- The maximum RPM.- Returns:
- The builder instance for chaining.
-
build
Builds the ShooterDescriptor instance with the provided parameters.- Returns:
- A new ShooterDescriptor instance.
-