Add turret offset to shooter table

This commit is contained in:
nathanrsxtn
2022-04-08 12:37:35 -06:00
parent 3b5749569b
commit c7f5d66a47
2 changed files with 29 additions and 18 deletions
+17 -17
View File
@@ -1,17 +1,17 @@
Distance (in) ,Hood Ext. (u) ,Drum Velocity (u/ds) Distance (in) ,Hood Ext. (u) ,Drum Velocity (u/ds) ,Turret Offset (deg)
0 ,-29.5 ,8000 0 ,-29.5 ,8000 ,10
78.5 ,-29.5 ,8500 78.5 ,-29.5 ,8500 ,8.5
88 ,-34.2 ,8600 88 ,-34.2 ,8600 ,8.5
90 ,-35.47 ,9500 90 ,-35.47 ,9500 ,8.5
99 ,-39.62 ,9500 99 ,-39.62 ,9500 ,8.0
111 ,-42 ,9500 111 ,-42 ,9500 ,8.0
127.25 ,-49.12 ,9500 127.25 ,-49.12 ,9500 ,8.0
141 ,-59.4 ,9900 141 ,-59.4 ,9900 ,7.5
150 ,-66.22 ,10000 150 ,-66.22 ,10000 ,7.5
164.5 ,-75.52 ,10000 164.5 ,-75.52 ,10000 ,6.5
189.9 ,-81.39 ,11000 189.9 ,-81.39 ,11000 ,6.0
207 ,-104.07 ,11000 207 ,-104.07 ,11000 ,5.5
227 ,-105.32 ,11500 227 ,-105.32 ,11500 ,5.0
239 ,-105.5 ,12380 239 ,-105.5 ,12380 ,4.5
255.5 ,-105.8 ,13500 255.5 ,-105.8 ,13500 ,4.0
999 ,-105.8 ,13500 999 ,-105.8 ,13500 ,3.0
1 Distance (in) Hood Ext. (u) Drum Velocity (u/ds) Drum Velocity (u/ds) Turret Offset (deg)
2 0 -29.5 8000 8000 10
3 78.5 -29.5 8500 8500 8.5
4 88 -34.2 8600 8600 8.5
5 90 -35.47 9500 9500 8.5
6 99 -39.62 9500 9500 8.0
7 111 -42 9500 9500 8.0
8 127.25 -49.12 9500 9500 8.0
9 141 -59.4 9900 9900 7.5
10 150 -66.22 10000 10000 7.5
11 164.5 -75.52 10000 10000 6.5
12 189.9 -81.39 11000 11000 6.0
13 207 -104.07 11000 11000 5.5
14 227 -105.32 11500 11500 5.0
15 239 -105.5 12380 12380 4.5
16 255.5 -105.8 13500 13500 4.0
17 999 -105.8 13500 13500 3.0
@@ -55,7 +55,7 @@ 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, turretOffset;
} }
private ShooterTableEntry[] m_shooterTable; private ShooterTableEntry[] m_shooterTable;
@@ -101,6 +101,17 @@ public class BoomBoom extends SubsystemBase {
return NumericData.linearInterpolate(m_shooterTable, distance, e -> e.distance, e -> e.hoodExt).doubleValue(); return NumericData.linearInterpolate(m_shooterTable, distance, e -> e.distance, e -> e.hoodExt).doubleValue();
} }
/**
* This is a function that takes a value (distance) and returns a value (turretOffset) that is a linear
* interpolation of the two values (turretOffset) at the two closest points in the table (m_shooterTable)
* to the given value (distance).
* @param distance Distance in shooter table
* @return Turret offset in degrees
*/
public Double getOffset(final Double distance) {
return NumericData.linearInterpolate(m_shooterTable, distance, e -> e.distance, e -> e.turretOffset).doubleValue();
}
@Override @Override
public void periodic() { public void periodic() {
// This method will be called once per scheduler run // This method will be called once per scheduler run