|
68 | 68 | # Compute the approximate linearization
|
69 | 69 | A = np.array(
|
70 | 70 | [
|
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])], |
73 | 73 | [0, 0, 0],
|
74 | 74 | ]
|
75 | 75 | )
|
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]]) |
77 | 77 |
|
78 | 78 | # Compute the gain matrix to place poles of (A-BK) at p
|
79 | 79 | p = np.array([-1.0, -2.0, -0.5])
|
80 | 80 | K = signal.place_poles(A, B, p)
|
81 | 81 |
|
82 | 82 | # 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] |
84 | 84 | u[:, k] = vehicle.uni2diff(u_unicycle, ELL)
|
85 | 85 |
|
86 | 86 | # Simulate the differential drive vehicle motion
|
|
0 commit comments