Adding torque in Static Optmization

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

Adding torque in Static Optmization

Post by Samane Amini » Wed Sep 11, 2024 4:05 am

Hi guys

I want to add a torque to a joint actuator meanwhile static optimization is done. To do this, I have used this code in the optimization loop:

Code: Select all

    H_controller = osim.PrescribedController()
    actuatorSet = model.getActuators()  
    H_controller.addActuator(actuatorSet.get('hip_motor_r')) 
    T_hipr = osim.Constant(0)
    H_controller.prescribeControlForActuator('hip_motor_r', T_hipr)
    model.addController(Hexa_controller)
Then the coordinates are set by motion file:

Code: Select all

        coord = coords.get(coordinate_names[j])
        coord.setValue(state, coordinates[k, j])
        coord.setSpeedValue(state, speeds[k, j])
But it gave me this error:

Code: Select all

RuntimeError: std::exception in 'void OpenSim::Coordinate::setValue(SimTK::State &,double,bool) const': Component::getModelingOption: ERR- name 'is_clamped' not found.
 for component 'hip_flexion_r' of type Coordinate
So i need sth to update the control. Anybody knows? Actually, I don't know where I put the addingController to apply the torque correctly.

Best

POST REPLY