8000 plot the hip joint control signal · col-in-coding/robot-modeling@50be774 · GitHub
[go: up one dir, main page]

Skip to content

Commit 50be774

Browse files
committed
plot the hip joint control signal
1 parent 331e58a commit 50be774

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

mathematics/cpg/code.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@
1212
# u: (optional, default 0), feedback, EX: u1 <=> x1, u2<=> y2...
1313
#
1414
# Outputs:
15-
# x1, y1 => LF
16-
# x2, y2 => RF
17-
# x3, y3 => LH
18-
# x4, y4 => RH
15+
# x1 => LF
16+
# x2 => RF
17+
# x3 => LH
18+
# x4 => RH
19+
#
20+
# x, the output of the oscillator, is control signal for hip joint
21+
# the Ascending part is in the swing phase
22+
# the Descending part is in support phase (when the knee joint is frozen)
1923
###
2024

2125
import matplotlib.pyplot as plt
2226
import numpy as np
2327

24-
alpha = 100
28+
alpha = 10000
2529
beta = 0.75
2630
mu = 1
2731
omega_sw = 5 * np.pi
2832
omega_st = omega_sw * (1 - beta) / beta
29-
a = 100
33+
a = 10
3034

3135
# phase config of walk gait
3236
phi_LF = 0
@@ -39,7 +43,7 @@
3943
# 5 seconds
4044
sim_duration = 5
4145
dt = 0.01
42-
iteration = 10
46+
iteration = 100
4347

4448
x1, y1, x2, y2, x3, y3, x4, y4 = np.random.uniform(0, 1, 8)
4549
Q = np.matrix([x1, y1, x2, y2, x3, y3, x4, y4]).T
@@ -80,6 +84,7 @@
8084
]).T
8185

8286
"""
87+
Coupling Matrix of 4 Oscillators
8388
R = [
8489
R11, R21, R31, R41;
8590
R12, R22, R32, R42;
@@ -125,16 +130,28 @@
125130
x4_t.append(x4)
126131
y4_t.append(y4)
127132

128-
fig, (ax0, ax1, ax2, ax3) = plt.subplots(4, 1)
129-
ax0.plot(t_t, x1_t, label='hip')
133+
plt.figure()
134+
plt.subplot(411)
135+
plt.plot(t_t, x1_t, label='hip')
130136
plt.ylabel('LF')
131-
ax1.plot(t_t, x2_t, label='hip')
137+
plt.grid()
138+
139+
plt.subplot(412)
140+
plt.plot(t_t, x2_t, label='hip')
132141
plt.ylabel('RF')
133-
ax2.plot(t_t, x3_t, label='hip')
142+
plt.grid()
143+
144+
plt.subplot(413)
145+
plt.plot(t_t, x3_t, label='hip')
134146
plt.ylabel('LH')
135-
ax3.plot(t_t, x4_t, label='hip')
147+
plt.grid()
148+
149+
plt.subplot(414)
150+
plt.plot(t_t, x4_t, label='hip')
136151
plt.ylabel('RH')
152+
plt.grid()
137153

154+
plt.subplots_adjust(top=0.92, bottom=0.2, hspace=0.5, wspace=0.35)
138155
plt.legend()
139156

140157

0 commit comments

Comments
 (0)
0