Skip to content

Commit

Permalink
Remove control usage (commaai#33103)
Browse files Browse the repository at this point in the history
* manual matrix exp

* remove control
  • Loading branch information
maxime-desroches authored Jul 29, 2024
1 parent 1ae3adb commit 01c0756
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ dev = [
"av",
"azure-identity",
"azure-storage-blob",
"control",
"dictdiffer",
"flaky",
"inputs",
Expand Down
11 changes: 7 additions & 4 deletions selfdrive/controls/lib/tests/test_vehicle_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import math

import numpy as np
from control import StateSpace

from openpilot.selfdrive.car.honda.interface import CarInterface
from openpilot.selfdrive.car.honda.values import CAR
Expand Down Expand Up @@ -47,16 +46,20 @@ def test_syn_ss_sol_simulate(self):
A, B = create_dyn_state_matrices(u, self.VM)

# Convert to discrete time system
ss = StateSpace(A, B, np.eye(2), np.zeros((2, 2)))
ss = ss.sample(0.01)
dt = 0.01
top = np.hstack((A, B))
full = np.vstack((top, np.zeros_like(top))) * dt
Md = sum([np.linalg.matrix_power(full, k) / math.factorial(k) for k in range(25)])
Ad = Md[:A.shape[0], :A.shape[1]]
Bd = Md[:A.shape[0], A.shape[1]:]

for sa in np.linspace(math.radians(-20), math.radians(20), num=11):
inp = np.array([[sa], [roll]])

# Simulate for 1 second
x1 = np.zeros((2, 1))
for _ in range(100):
x1 = ss.A @ x1 + ss.B @ inp
x1 = Ad @ x1 + Bd @ inp

# Compute steady state solution directly
x2 = dyn_ss_sol(sa, u, roll, self.VM)
Expand Down
15 changes: 0 additions & 15 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 01c0756

Please sign in to comment.