Add calPerc progress tracking for torque calibration (#35512)
* Add calPerc field and torque progress * Fix torqued test style and CarParams usage * test: remove unused numpy import * move here * trying all combinations to see what's most linear * clean up with best method * no no * epic * clean up * last min not needed * doesn't hurt * list comppull/35519/head
parent
d9b6c16037
commit
bfa3f3cccb
5 changed files with 34 additions and 1 deletions
@ -0,0 +1,25 @@ |
|||||||
|
from cereal import car |
||||||
|
from openpilot.selfdrive.locationd.torqued import TorqueEstimator |
||||||
|
|
||||||
|
|
||||||
|
def test_cal_percent(): |
||||||
|
est = TorqueEstimator(car.CarParams()) |
||||||
|
msg = est.get_msg() |
||||||
|
assert msg.liveTorqueParameters.calPerc == 0 |
||||||
|
|
||||||
|
for (low, high), min_pts in zip(est.filtered_points.buckets.keys(), |
||||||
|
est.filtered_points.buckets_min_points.values(), strict=True): |
||||||
|
for _ in range(int(min_pts)): |
||||||
|
est.filtered_points.add_point((low + high) / 2.0, 0.0) |
||||||
|
|
||||||
|
# enough bucket points, but not enough total points |
||||||
|
msg = est.get_msg() |
||||||
|
assert msg.liveTorqueParameters.calPerc == (len(est.filtered_points) / est.min_points_total * 100 + 100) / 2 |
||||||
|
|
||||||
|
# add enough points to bucket with most capacity |
||||||
|
key = list(est.filtered_points.buckets)[0] |
||||||
|
for _ in range(est.min_points_total - len(est.filtered_points)): |
||||||
|
est.filtered_points.add_point((key[0] + key[1]) / 2.0, 0.0) |
||||||
|
|
||||||
|
msg = est.get_msg() |
||||||
|
assert msg.liveTorqueParameters.calPerc == 100 |
@ -1 +1 @@ |
|||||||
9e2fe2942fbf77f24bccdbef15893831f9c0b390 |
1f5f2708a82fb8a1b68f23dd2eb246c0b1d0b47d |
Loading…
Reference in new issue