Adding a Coordinate Actuator to the muscles of the arm

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
sariah Mghames
Posts: 23
Joined: Thu Jun 30, 2016 5:56 am

Re: Adding a Coordinate Actuator to the muscles of the arm

Post by sariah Mghames » Tue Sep 20, 2016 11:08 pm

Thanks alot for your time,

I have something working now, but I want to be sure about thing i did:

Since it's not necessary to create a force set, instead just adding the coordinate actuator(through model->addForce) to the model will be sufficient;
I am questioning the following: I added the input control of that coordinate actuator( a torque N.m should be) to the controlSet created to hold the control input ( excitations 0->1) of the 6 muscles. would it be considered a torque/force inside the controlSet if i didnt created a forceSet to hold it alone ?

Thanks,

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Adding a Coordinate Actuator to the muscles of the arm

Post by Dimitar Stanev » Tue Sep 20, 2016 11:24 pm

OpenSim does not care what you put in the control set. It just read it and supplies the value to the actuator regarded of the type. It is the actuator who chooses how to handle the control.

User avatar
shayan moradkhani
Posts: 41
Joined: Fri May 05, 2017 5:12 pm

Re: Adding a Coordinate Actuator to the muscles of the arm

Post by shayan moradkhani » Wed Jun 14, 2017 12:30 pm

dear all,
i`m a bit too confused. i`m trying to edit an existing API example, by adding an actuator between two bodies. i wan the actuator to create torque for forward simulation. i want to know the difference between CoordinateActuator and TorqueActuator.
assuming i already know which one to pick, CoordinateActuator as an example, by studying the CoordinateActuator() structure in Doxygen, i get
OpenSim::CoordinateActuator::CoordinateActuator ( const std::string & coordinateName = " ").
the thing is it only asks for the name and does not really say how i need to define this actuator: how to put that between bodies, does it need to have initial force, how to connect it to a controller,...
i don`t really figure out if this is just c++ knowledge or something else.
i would really appreciate your help
regards
Shayan

User avatar
Thomas Uchida
Posts: 1795
Joined: Wed May 16, 2012 11:40 am

Re: Adding a Coordinate Actuator to the muscles of the arm

Post by Thomas Uchida » Wed Jun 14, 2017 9:28 pm

i want to know the difference between CoordinateActuator and TorqueActuator.
A CoordinateActuator applies a generalized force in the direction of a generalized coordinate (e.g., a knee joint torque at a knee joint). A TorqueActuator applies an arbitrary torque between two arbitrary bodies.
by studying the CoordinateActuator() structure in Doxygen, i get
OpenSim::CoordinateActuator::CoordinateActuator ( const std::string & coordinateName = " ").
the thing is it only asks for the name and does not really say how i need to define this actuator: how to put that between bodies, does it need to have initial force, how to connect it to a controller,...
Doxygen is more like a dictionary; I suggest looking at examples first. The "Dynamic Walker Competition January 2014" page in the Confluence documentation (http://simtk-confluence.stanford.edu:80 ... nuary+2014) includes a link to a .zip file (https://simtk.org/frs/download.php?file_id=3862) that contains sample MATLAB code you might find helpful (see, for example, UserFunctions\AddCoordinateActuator.m). The example on the main GitHub page (https://github.com/opensim-org/opensim-core) demonstrates adding a controller to a model.

User avatar
shayan moradkhani
Posts: 41
Joined: Fri May 05, 2017 5:12 pm

Re: Adding a Coordinate Actuator to the muscles of the arm

Post by shayan moradkhani » Thu Jun 15, 2017 2:36 am

dear Tom,

thank you very much for your help, that was really beneficial. at least it was a success for me to write a few lines of code. i added : CoordinateActuator *TorqueGenerator = new CoordinateActuator("ankle");
TorqueGenerator->setName("TorqueGenerator");
TorqueGenerator->setOptimalForce(10.0);
TorqueGenerator->setMinControl(-20000);
TorqueGenerator->setMaxControl(20000);
osimModel.addForce(TorqueGenerator);
it build successfully, however, created no simulation.
what i did was i took the example on "creating customized actuator" and edited the "toyLeg_example". i commented the "controllable spring", and instead, added the above code.
i suppose one problem is related to the legController which i kept a linear function and did not change.
please find the .cpp file in the attachment.
best regards
Shayan
Attachments
test.cpp
(10.05 KiB) Downloaded 16 times

User avatar
Thomas Uchida
Posts: 1795
Joined: Wed May 16, 2012 11:40 am

Re: Adding a Coordinate Actuator to the muscles of the arm

Post by Thomas Uchida » Fri Jun 16, 2017 12:29 am

it build successfully, however, created no simulation.
On line 160, you have

Code: Select all

CoordinateActuator *TorqueGenerator = new CoordinateActuator("ankle");
The constructor for CoordinateActuator is described in the doxygen as (https://simtk.org/api_docs/opensim/api_ ... edb073ab9e)

Code: Select all

OpenSim::CoordinateActuator::CoordinateActuator ( const std::string& coordinateName = "" )
You're specifying "ankle" on line 160, which is the name of the Joint (not the Coordinate). On line 109, the name of the first (and only) Coordinate owned by the "ankle" Joint is set to "q1"; this is what you must provide to the CoordinateActuator constructor on line 160.

POST REPLY