Skip to content

Commit dc332c8

Browse files
committed
Fix examples in python
1 parent 32a7ec8 commit dc332c8

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

examples/go2_fulldynamics.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@
8383
timestep=dt,
8484
)
8585

86-
mpc = MPC()
87-
mpc.initialize(mpc_conf, dynproblem)
86+
mpc = MPC(mpc_conf, dynproblem)
8887

8988
""" Define contact sequence throughout horizon"""
9089
contact_phase_quadru = {
@@ -223,17 +222,17 @@
223222
solve_time.append(end - start)
224223

225224
a0 = (
226-
mpc.getSolver()
225+
mpc.solver
227226
.workspace.problem_data.stage_data[0]
228227
.dynamics_data.continuous_data.xdot[nv:]
229228
)
230229
a1 = (
231-
mpc.getSolver()
230+
mpc.solver
232231
.workspace.problem_data.stage_data[1]
233232
.dynamics_data.continuous_data.xdot[nv:]
234233
)
235234

236-
FL_f, FR_f, RL_f, RR_f, contact_states = extract_forces(mpc.getTrajOptProblem(), mpc.getSolver().workspace, 0)
235+
FL_f, FR_f, RL_f, RR_f, contact_states = extract_forces(mpc.getTrajOptProblem(), mpc.solver.workspace, 0)
237236
total_forces = np.concatenate((FL_f, FR_f, RL_f, RR_f))
238237
force_FL.append(FL_f)
239238
force_FR.append(FR_f)

examples/go2_kinodynamics.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@
9393
timestep=0.01,
9494
)
9595

96-
mpc = MPC()
97-
mpc.initialize(mpc_conf, dynproblem)
96+
mpc = MPC(mpc_conf, dynproblem)
9897

9998
""" Define contact sequence throughout horizon"""
10099
contact_phase_quadru = {
@@ -227,12 +226,12 @@
227226
L_measured.append(mpc.getDataHandler().getData().hg.angular.copy())
228227

229228
a0 = (
230-
mpc.getSolver()
229+
mpc.solver
231230
.workspace.problem_data.stage_data[0]
232231
.dynamics_data.continuous_data.xdot[nv:]
233232
)
234233
a1 = (
235-
mpc.getSolver()
234+
mpc.solver
236235
.workspace.problem_data.stage_data[1]
237236
.dynamics_data.continuous_data.xdot[nv:]
238237
)

examples/talos_centroidal.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@
8787
timestep=problem_conf["timestep"],
8888
)
8989

90-
mpc = MPC()
91-
mpc.initialize(mpc_conf, problem)
90+
mpc = MPC(mpc_conf, problem)
9291

9392
""" Define contact sequence throughout horizon"""
9493
contact_phase_double = {
@@ -210,7 +209,7 @@
210209
foot_ref = [mpc.getReferencePose(0, name) for name in model_handler.getFeetNames()]
211210
foot_ref_next = [mpc.getReferencePose(1, name) for name in model_handler.getFeetNames()]
212211
dH = (
213-
mpc.getSolver()
212+
mpc.solver
214213
.workspace.problem_data.stage_data[0]
215214
.dynamics_data.continuous_data.xdot[3:9]
216215
)
@@ -229,7 +228,7 @@
229228

230229
forces = (
231230
mpc.us[0][: nk * force_size]
232-
- 1 * mpc.getSolver().results.controlFeedbacks()[0] @ state_diff
231+
- 1 * mpc.solver.results.controlFeedbacks()[0] @ state_diff
233232
)
234233

235234

examples/talos_fulldynamics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@
112112
timestep=problem_conf["timestep"],
113113
)
114114

115-
mpc = MPC()
116-
mpc.initialize(mpc_conf, dynproblem)
115+
mpc = MPC(mpc_conf, dynproblem)
117116

118117
""" Define contact sequence throughout horizon"""
119118
contact_phase_double = {

examples/talos_kinodynamics.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@
123123
timestep=problem_conf["timestep"],
124124
)
125125

126-
mpc = MPC()
127-
mpc.initialize(mpc_conf, problem)
126+
mpc = MPC(mpc_conf, problem)
128127

129128
""" Define contact sequence throughout horizon"""
130129
contact_phase_double = {
@@ -212,12 +211,12 @@
212211
end = time.time()
213212
print("MPC iterate = " + str(end - start))
214213
a0 = (
215-
mpc.getSolver()
214+
mpc.solver
216215
.workspace.problem_data.stage_data[0]
217216
.dynamics_data.continuous_data.xdot[nv:]
218217
)
219218
a1 = (
220-
mpc.getSolver()
219+
mpc.solver
221220
.workspace.problem_data.stage_data[1]
222221
.dynamics_data.continuous_data.xdot[nv:]
223222
)

0 commit comments

Comments
 (0)