This is an example that predicts a squat-to-stand movement and optimizes the stiffness of an assistive passive device. This example is used in hands-on workshops, and accordingly has blanks that users must fill in. See exampleSquatToStand_answers.m for a completed version.
4import exampleSquatToStand_helpers
as helpers
5import mocoPlotTrajectory
as plot
8torqueDrivenModel = helpers.getTorqueDrivenModel()
9muscleDrivenModel = helpers.getMuscleDrivenModel()
38problem.setTimeBounds( )
42problem.setStateInfo(
'/jointset/hip_r/hip_flexion_r/value', )
43problem.setStateInfo(
'/jointset/knee_r/knee_angle_r/value', )
44problem.setStateInfo(
'/jointset/ankle_r/ankle_angle_r/value', )
47problem.setStateInfoPattern(
'/jointset/.*/speed', )
55if not os.path.isfile(
'predictSolution.sto'):
79if not os.path.isfile(
'trackingSolution.sto'):
85plot.mocoPlotTrajectory(
'predictSolution.sto',
'trackingSolution.sto',
101inverse.set_initial_time( )
102inverse.set_final_time( )
103inverse.set_mesh_interval( )
104inverse.set_convergence_tolerance( )
105inverse.set_constraint_tolerance( )
108inverse.set_kinematics_allow_extra_columns(
True)
109inverse.set_minimize_sum_squared_activations(
True)
113inverse.append_output_paths(
'.*normalized_fiber_length')
114inverse.append_output_paths(
'.*passive_force_multiplier')
135print(
'Cost without device: ', solution.getObjective())
136print(
'Cost with device: ', deviceSolution.getObjective())
140helpers.compareInverseSolutions(inverseSolution, inverseDeviceSolution)