6161for i in range (9 ):
6262 eom [9 + i ] = genforce_scale * eom [9 + i ]
6363
64- # %%
65- # Create a state variable "delt" which is equal to time, for use in controller
66- # and/or instance constraints.
67- #
68- # .. math::
69- #
70- # \Delta_t(t) = \int_{t_0}^{t} d\tau
71- #
72- delt = sm .Function ('delt' , real = True )(time_symbol )
73- eom = eom .col_join (sm .Matrix ([delt .diff (time_symbol ) - 1 ]))
74-
75- states = symbolics .states + [delt ]
64+ states = symbolics .states
7665num_states = len (states )
7766
7867# %%
120109# - Only let the hip, knee, and ankle flex and extend to realistic limits.
121110# - Put a maximum on the peak torque values.
122111bounds = {
123- delt : (0.0 , 2.0 ),
124112 qax : (- 1.0 , 1.0 ),
125113 qay : (0.5 , 1.5 ),
126114 qa : np .deg2rad ((- 60.0 , 60.0 )),
149137# goes for the joint angular rates.
150138#
151139instance_constraints = (
152- delt .func (0 * h ) - 0.0 ,
153140 qax .func (0 * h ) - 0.0 ,
154141 qax .func (duration ) - 0.0 ,
155142 qay .func (0 * h ) - qay .func (duration ),
179166 Tg .func (0 * h ) - Td .func (duration ),
180167)
181168
182-
183169# %%
184170# The objective is a combination of squared torques and squared tracking errors
185171
@@ -254,7 +240,7 @@ def obj_grad(free):
254240def solve_gait (speed , initial_guess = None ):
255241
256242 # change the belt speed signal
257- traj_map [v ] = speed + np .zeros (num_nodes )
243+ traj_map [v ] = speed * np .ones (num_nodes )
258244
259245 # solve
260246 print (datetime .now ().strftime ("%H:%M:%S" ) +
@@ -272,13 +258,9 @@ def solve_gait(speed, initial_guess=None):
272258
273259
274260# solve for a series of increasing speeds, ending at the required speed
275- for speed in np .linspace (0 , walking_speed , 10 ):
261+ for speed in np .linspace (0.0 , walking_speed , num = 10 ):
276262 solution = solve_gait (speed , initial_guess )
277263 initial_guess = solution # use this solution as guess for the next problem
278- # solution = solve_gait(0.0, initial_guess)
279-
280- fname = f'human_gait_{ num_nodes } _nodes_solution.csv'
281- np .savetxt (fname , solution , fmt = '%.5f' )
282264
283265# %%
284266# make plots
0 commit comments