Skip to content

Commit a7ffab4

Browse files
committed
updated tuning for shooting
1 parent c9b3050 commit a7ffab4

2 files changed

Lines changed: 52 additions & 50 deletions

File tree

src/main/deploy/tuning/arc.json

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,128 +5,121 @@
55
"hood" : 5.0,
66
"points" : [
77
{
8-
// Shoot cmd
8+
99
"distance" : 1.24,
1010
"velocity" : 51.0
1111
},
1212
{
13-
// Shoot cmd
13+
1414
"distance" : 1.4,
1515
"velocity" : 54.0
1616
},
1717
{
18-
// Shoot cmd
19-
"distance" : 1.7,
20-
"velocity" : 56.0
18+
19+
"distance" : 1.73,
20+
"velocity" : 60.0
2121
}
2222
]
2323
},
2424
{
2525
"hood" : 15.0,
2626
"points" : [
2727
{
28-
// Shoot cmd
29-
"distance" : 1.9,
30-
"velocity" : 51.0
28+
29+
"distance" : 1.91,
30+
"velocity" : 54.0
3131
},
3232
{
33-
// Shoot cmd
33+
3434
"distance" : 2.11,
35-
"velocity" : 52.0
35+
"velocity" : 56.0
3636
},
3737
{
38-
// Shoot mode
38+
3939
"distance" : 2.3,
40-
"velocity" : 54.5
40+
"velocity" : 58.0
4141
},
4242
{
43-
// Shoot mode
44-
"distance" : 2.50,
45-
"velocity" : 56.0
43+
44+
"distance" : 2.49,
45+
"velocity" : 59.0
4646
}
4747
]
4848
},
4949
{
5050
"hood" : 25.0,
5151
"points" : [
52-
// {
53-
// "distance": 2.7,
54-
// "velocity": 55.0
55-
// },
5652
{
57-
// Shoot cmd
53+
5854
"distance" : 2.7,
59-
"velocity" : 53
55+
"velocity" : 54
6056
},
6157
{
62-
// Shoot cmd
58+
6359
"distance" : 2.9,
64-
"velocity" : 54
60+
"velocity" : 56
6561
},
6662
{
67-
// Shoot cmd
68-
"distance" : 3.1,
69-
"velocity" : 55.5
63+
64+
"distance" : 3.16,
65+
"velocity" : 57
7066
},
7167
{
72-
// Shoot cmd
73-
"distance" : 3.29,
74-
"velocity" : 56.0
68+
69+
"distance" : 3.35,
70+
"velocity" : 59.0
7571
},
7672
{
77-
// Shoot cmd
78-
"distance" : 3.50,
79-
"velocity" : 57.0
73+
74+
"distance" : 3.53,
75+
"velocity" : 61.0
8076
},
8177
{
82-
// Shoot cmd
78+
8379
"distance" : 3.71,
84-
"velocity" : 58.0
80+
"velocity" : 63
8581
}
8682
]
8783
},
8884
{
8985
"hood" : 30.0,
9086
"points" : [
9187
{
92-
"distance" : 3.8,
93-
"velocity" : 57.0
94-
},
95-
{
96-
// Shoot cmd
88+
9789
"distance" : 3.90,
98-
"velocity" : 58.0
90+
"velocity" : 61.0
9991
},
10092
{
101-
// Shoot cmd
93+
10294
"distance" : 4.1,
103-
"velocity" : 60.0
95+
"velocity" : 63.0
10496
},
10597
{
106-
// Shoot cmd
98+
10799
"distance" : 4.3,
108-
"velocity" : 62.5
100+
"velocity" : 65
109101
},
110102
{
111103
"distance": 4.5,
112-
"velocity": 64
104+
"velocity": 67
113105
},
114106
{
115107
"distance": 4.8,
116-
"velocity": 65.5
108+
"velocity": 69
109+
117110
},
118111
{
119-
"distance": 5.3,
120-
"velocity": 70.0
112+
"distance": 5.4,
113+
"velocity": 75.0
121114
}
122115
]
123116
},
124117
{
125118
"hood": 45.0,
126119
"points": [
127120
{
128-
"distance": 5.5,
129-
"velocity": 65
121+
"distance": 5.8,
122+
"velocity": 66
130123
},
131124
{
132125
"distance": 6.5,

src/main/java/frc/robot/subsystems/shooter/ShooterTuning.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public ShooterTuning(String name) {
7070
readTuningData("tuning/" + name + ".json") ;
7171
}
7272

73+
public void reset() {
74+
lastHoodIndex_ = -1 ;
75+
}
76+
7377
public String getName() {
7478
return name_ ;
7579
}
@@ -144,6 +148,7 @@ private double doBetterInterpolate(OneHoodTuning tuning, double dist, boolean la
144148
}
145149

146150
public ShooterParams getShooterParams(double dist) {
151+
lastHoodIndex_ = -1 ;
147152
int h = getHoodIndex(dist) ;
148153
double vel = doBetterInterpolate(settings_.get(h), dist, h == settings_.size() - 1) ;
149154
var ret = new ShooterParams(dist, settings_.get(h).hood_, vel) ;
@@ -165,23 +170,27 @@ private int getHoodIndex(double dist) {
165170
private int processHysteresis(double dist, int newIndex) {
166171
if (lastHoodIndex_ == -1) {
167172
lastHoodIndex_ = newIndex ;
173+
System.out.println("ShooterTuning: setting initial hood index to " + newIndex + " for distance " + dist) ;
168174
return newIndex ;
169175
}
170176

171177
if (newIndex == lastHoodIndex_ + 1) {
172178
// We moved to the next hood index
173179
// Stay at the old hood index until we exceed its max distance plus hysteresis
174180
if (dist <= settings_.get(lastHoodIndex_).max_dist_ + HYSTERESIS_DIST) {
181+
System.out.println("ShooterTuning: 1 staying at hood index " + lastHoodIndex_ + " for distance " + dist + " due to hysteresis") ;
175182
return lastHoodIndex_ ;
176183
}
177184
}
178185
else if (newIndex == lastHoodIndex_ - 1) {
179186
// We moved to the previous hood index
180187
if (dist > settings_.get(lastHoodIndex_).min_dist_ - HYSTERESIS_DIST) {
188+
System.out.println("ShooterTuning: 2 staying at hood index " + lastHoodIndex_ + " for distance " + dist + " due to hysteresis") ;
181189
return lastHoodIndex_ ;
182190
}
183191
}
184192

193+
System.out.println("ShooterTuning: moving from hood index " + lastHoodIndex_ + " to " + newIndex + " for distance " + dist) ;
185194
lastHoodIndex_ = newIndex ;
186195
return newIndex ;
187196
}

0 commit comments

Comments
 (0)