Skip to content

Commit 111f1b4

Browse files
committed
Fixed a minor index problem
1 parent b1a17a4 commit 111f1b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

control_approx_linearization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@
6868
# Compute the approximate linearization
6969
A = np.array(
7070
[
71-
[0, 0, -u_d[0, k] * np.sin(x_d[2, k])],
72-
[0, 0, u_d[0, k] * np.cos(x_d[2, k])],
71+
[0, 0, -u_d[0, k - 1] * np.sin(x_d[2, k - 1])],
72+
[0, 0, u_d[0, k - 1] * np.cos(x_d[2, k - 1])],
7373
[0, 0, 0],
7474
]
7575
)
76-
B = np.array([[np.cos(x_d[2, k]), 0], [np.sin(x_d[2, k]), 0], [0, 1]])
76+
B = np.array([[np.cos(x_d[2, k - 1]), 0], [np.sin(x_d[2, k - 1]), 0], [0, 1]])
7777

7878
# Compute the gain matrix to place poles of (A-BK) at p
7979
p = np.array([-1.0, -2.0, -0.5])
8080
K = signal.place_poles(A, B, p)
8181

8282
# Compute the controls (v, omega) and convert to wheel speeds (v_L, v_R)
83-
u_unicycle = -K.gain_matrix @ (x[:, k - 1] - x_d[:, k]) + u_d[:, k]
83+
u_unicycle = -K.gain_matrix @ (x[:, k - 1] - x_d[:, k - 1]) + u_d[:, k - 1]
8484
u[:, k] = vehicle.uni2diff(u_unicycle, ELL)
8585

8686
# Simulate the differential drive vehicle motion

0 commit comments

Comments
 (0)