Test the combined ModelD steering smoothing join

This commit is contained in:
firestar5683
2026-11-30 00:10:23 -06:00
parent 1a5023ce7b
commit 4e2af76cad
2 changed files with 9 additions and 4 deletions
@@ -15,6 +15,10 @@ from openpilot.starpilot.models.laboratory_runner import LaboratoryPair
def common_join():
tree = ast.parse(Path(modeld.__file__).read_text())
smoothing = [statement for statement in ast.walk(tree) if isinstance(statement, ast.Assign)
and any(isinstance(target, ast.Name) and target.id == 'steering_smoothing' for target in statement.targets)]
assert len(smoothing) == 1
assert ast.unparse(smoothing[0]) == 'steering_smoothing = subaru_tau + volkswagen_tau + kona_tau + bolt_tau'
matches = []
for node in ast.walk(tree):
body = getattr(node, 'body', None)
@@ -28,9 +32,9 @@ def common_join():
assert len(statements) == 3
assert sum(isinstance(call, ast.Call) and ast.unparse(call.func) == 'model.get_action_from_model'
for call in ast.walk(statements[0])) == 1
assert ast.unparse(statements[1]) == 'filter_action(action, prev_action, v_ego, subaru_tau + volkswagen_tau + kona_tau)'
assert ast.unparse(statements[1]) == 'filter_action(action, prev_action, v_ego, steering_smoothing)'
assert ast.unparse(statements[2]) == 'prev_action = action'
matches.append(ast.Module(body=statements, type_ignores=[]))
matches.append(ast.Module(body=smoothing + statements, type_ignores=[]))
assert len(matches) == 1
return compile(matches[0], modeld.__file__, 'exec')
@@ -56,7 +60,8 @@ def test_actual_common_join_once_and_acceleration_unchanged(owner, tau, kona_tau
SimpleNamespace(get_action_from_model=function))
paired_action = function(outputs, previous, .2, .2, 2.) if owner == 'laboratory' else None
scope = {'model': model, 'LaboratoryPair': LaboratoryPair, 'laboratory_action': paired_action, 'model_output': outputs, 'prev_action': previous,
'lat_action_t': .2, 'long_action_t': .2, 'v_ego': 2., 'subaru_tau': tau, 'volkswagen_tau': 0., 'kona_tau': kona_tau, 'filter_action': filter_action}
'lat_action_t': .2, 'long_action_t': .2, 'v_ego': 2., 'subaru_tau': tau,
'volkswagen_tau': 0., 'kona_tau': kona_tau, 'bolt_tau': 0., 'filter_action': filter_action}
exec(common_join(), scope)
action = scope['action']
assert isinstance(action, (_DynamicStructBuilder, _DynamicStructReader))
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "4ad359126bef50ee97347c7c0458446ee79c700cab0fd6334a7db67f2d315e31", "schema_version": 1}
{"protected_inventory_sha256": "2614bb3f7b68edcd15463336ead8c005797a09e80d10a54bbd77ce3b36f5a995", "schema_version": 1}