Specify control file and use it

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Endale Schilling
Posts: 2
Joined: Thu Sep 29, 2022 12:09 pm

Specify control file and use it

Post by Endale Schilling » Mon Nov 21, 2022 8:42 am

Dear OpenSim Community,
I am a beginner in the OpenSim world and I have the following problem.
My control file defined in Matlab is not taken into consideration when simulating in the OpenSim GUI, so the simulation gives the same result with or without the control file. I have used this thread for the input of the control file
(viewtopicPhpbb.php?f=91&t=4139&p=9619&s ... 967ce2b820)
and wrote the following code:
import org.opensim.modeling.*;
osimModel = Model('buildWalker_Complete.osim');

% get coordinates
RKnee_rz = osimModel.getForceSet.getActuators.get(5);
LKnee_rz = osimModel.getForceSet.getActuators.get(6);
Pelvis_tx = osimModel.getForceSet.getActuators.get(1);
% create controller
brain = PrescribedController();
brain.set_controls_file('C:\Users\...\Dynamic_Walker_Builder\contrFile.sto')
brain.set_interpolation_method(5)
brain.addActuator(RKnee_rz);
brain.addActuator(LKnee_rz);
brain.addActuator(Pelvis_tx);
brain.upd_controls_file();

brain.prescribeControlForActuator('RKnee_rz', PiecewiseLinearFunction())
brain.prescribeControlForActuator('LKnee_rz', PiecewiseLinearFunction())
brain.prescribeControlForActuator('Pelvis_tx', PiecewiseLinearFunction())
brain.setName('PrescribedController');
% add to model
osimModel.addController(brain)
osimModel.updActuators()
osimModel.finalizeConnections
osimModel.setName('DWM_controlled')
osimModel.print('DWM_controlled.osim')
winopen('DWM_controlled.osim')

In the image (model tree.JPG), you can see the hierarchy structure of the model. As you can see in the picture, the actuator_list, controls_file, and interpolation_method are defined. For the 'ControlFunctions' I have defined a PiecewiseLinearFunction (see code), but this is not shown in the structure tree. Furthermore, I assume that OpenSim takes the start and end values of the function from the control file. For example, in the other image (LKnee_value_response.JPG), you can see the target state of the left knee joint calculated by the PD control. So what am I doing wrong?

Thank you in advance,
Endale
Attachments
LKnee_value_response.jpg
LKnee_value_response.jpg (67.84 KiB) Viewed 148 times
model tree.JPG
model tree.JPG (58.55 KiB) Viewed 148 times

Tags:

POST REPLY