shooter tables duration

This commit is contained in:
aarav18
2022-03-12 14:54:42 -07:00
parent 06ccba971e
commit 35662f72f9
2 changed files with 29 additions and 12 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
Distance (in) ,Hood Ext. (u) ,Drum Velocity (u/ds) ,Time (s) Distance (in) ,Hood Ext. (u) ,Drum Velocity (u/ds) ,Duration (s)
96 ,-25.00 ,0.425 ,0 96 ,-25.00 ,0.425 ,0
144 ,-47.57 ,0. ,0 144 ,-47.57 ,0. ,0
192 ,-55.55 ,0.500 ,0 192 ,-55.55 ,0.500 ,0
1 Distance (in) Hood Ext. (u) Drum Velocity (u/ds) Time (s) Duration (s)
2 96 -25.00 0.425 0 0
3 144 -47.57 0. 0 0
4 192 -55.55 0.500 0 0
@@ -47,14 +47,12 @@ public class BoomBoom extends SubsystemBase {
// SimpleMotorFeedforward feedforward = new SimpleMotorFeedforward(69, 42, 0); //get real values later // SimpleMotorFeedforward feedforward = new SimpleMotorFeedforward(69, 42, 0); //get real values later
public static class ShooterTableEntry { public static class ShooterTableEntry {
public Double distance, hoodExt, drumVelocity; public Double distance, hoodExt, drumVelocity, duration;
} }
private ShooterTableEntry[] m_shooterTable; private ShooterTableEntry[] m_shooterTable;
/*
* Creates new BoomBoom subsystem, has drum shooter and angle adjuster /** Creates a new BoomBoom, which has a drum shooter and angle adjuster. */
*/
/** Creates a new BoomBoom. */
public BoomBoom(WPI_TalonFX shooterFalconLeft, WPI_TalonFX shooterFalconRight) { public BoomBoom(WPI_TalonFX shooterFalconLeft, WPI_TalonFX shooterFalconRight) {
m_shooterFalconLeft = shooterFalconLeft; m_shooterFalconLeft = shooterFalconLeft;
m_shooterFalconRight = shooterFalconRight; m_shooterFalconRight = shooterFalconRight;
@@ -94,20 +92,39 @@ public class BoomBoom extends SubsystemBase {
} }
} }
/**
* This is a function that takes a value (distance) and returns a value (drumVelocity) that is a
* linear interpolation of the two values (drumVelocity) at the two closest points in the table
* (m_shooterTable) to the given value (distance).
* @param distance Distance in shooter table
* @return Drum Velocity in units per 100 ms
*/
public Double getVelocity(final Double distance) { public Double getVelocity(final Double distance) {
// This is a function that takes a value (distance) and returns a value (drumVelocity) that is a
// linear interpolation of the two values (drumVelocity) at the two closest points in the table
// (m_shooterTable) to the given value (distance).
return linearInterpolate(m_shooterTable, distance, e -> e.distance, e -> e.drumVelocity).doubleValue(); return linearInterpolate(m_shooterTable, distance, e -> e.distance, e -> e.drumVelocity).doubleValue();
} }
/**
* This is a function that takes a value (distance) and returns a value (hoodExt) that is a linear
* interpolation of the two values (hoodExt) at the two closest points in the table (m_shooterTable)
* to the given value (distance).
* @param distance Distance in shooter table
* @return Hood extension in units
*/
public Double getHood(final Double distance) { public Double getHood(final Double distance) {
// This is a function that takes a value (distance) and returns a value (hoodExt) that is a linear
// interpolation of the two values (hoodExt) at the two closest points in the table (m_shooterTable)
// to the given value (distance).
return linearInterpolate(m_shooterTable, distance, e -> e.distance, e -> e.hoodExt).doubleValue(); return linearInterpolate(m_shooterTable, distance, e -> e.distance, e -> e.hoodExt).doubleValue();
} }
/**
* This is a function that takes a value (distance) and returns a value (duration) that is a linear
* interpolation of the two values (duration) at the two closest points in the table (m_shooterTable)
* to the given value (distance).
* @param distance Distance in shooter table
* @return Shot duration in seconds
*/
public Double getDuration(final Double distance) {
return linearInterpolate(m_shooterTable, distance, e -> e.distance, e -> e.duration).doubleValue();
}
/** /**
* Using the given lookup value (x) and lookup getter function, locates the nearest entries in the * Using the given lookup value (x) and lookup getter function, locates the nearest entries in the
* given table to be used as the lower (x0) and upper (x1) bounds for interpolation. Returns the * given table to be used as the lower (x0) and upper (x1) bounds for interpolation. Returns the