Page 1 of 1
Method for giving control signal to path actuator
Posted: Fri Jan 24, 2020 5:11 am
by sambhav.ratna
Hello,
I am trying to add path actuator between the arm and the forearm part. This path actuator is actually an approximation of the bowden cable and pulley system. I have implemented the path actuator as shown in the visualizer based on what I understood from Doxygen. Following is the code which I used:
%% Path actuator
act = PathActuator();
act.addNewPathPoint('p1',arm_exo1,Vec3(0.035,0,0));
act.addNewPathPoint('p2',arm_exo2,Vec3(0.035,0,0));
act.setOptimalForce(10);
model.addForce(act);
%%
Can you please give me an example or something from where I can understand how to give control signal to this actuator. I have searched everywhere but I didn't find anything. Ofcourse I am a newbie here. I tried PrescribedControl but that is not working for this. Also, how will I set the slack length in this?
Thanks..
Re: Method for giving control signal to path actuator
Posted: Fri Jan 24, 2020 7:49 am
by tkuchida
The example on the main GitHub page uses a controller (
https://github.com/opensim-org/opensim-core; scroll down to the "Simple example" section). Below the C++ code, there are equivalent scripts for Python and Matlab.
Re: Method for giving control signal to path actuator
Posted: Fri Jan 24, 2020 8:45 am
by sambhav.ratna
Hello Thomas Uchida,
Thanks for your kind attention and reply. In the simple example code, muscle has been controlled but what I want to control here is the PathActuator, which basically creates tension based on the value of it's OptimalForce and the control signal applied to it.
I tried giving control signal to it, using PrescibedController as is used for controlling muscles, but its showing that the PathActuator is not in the list of muscles under PrescribedController. Here is my code and the error file has been attached as jpg.
%% Path actuator
act = PathActuator();
act.addNewPathPoint('p1',arm_exo1,Vec3(0.035,0,0));
act.addNewPathPoint('p2',arm_exo2,Vec3(0.035,0,0));
act.setOptimalForce(10);
model.addForce(act);
%%
%% Prescribed controller
brain = PrescribedController();
brain.addActuator(act);
brain.prescribeControlForActuator('act', StepFunction(0.5, 3.0, 0.3, 1.0));
model.addController(brain);
Can you suggest me which controller has to be used for PathActuator and the basic command for that.
My aim is to implement a control loop of actuator and muscles, so that for every iteration based on value of elbow angle and muscle force, a control signal will be given to the PathActuator which will create a tension in itself and thus apply a torque on elbow.
Thanks
Re: Method for giving control signal to path actuator
Posted: Fri Jan 24, 2020 3:51 pm
by tkuchida
Please see the documentation for the
prescribeControlForActuator() method:
https://simtk.org/api_docs/opensim/api_ ... cba89bea0c. The first argument is a string, which I believe should be the name of the actuator (i.e., the name assigned to the actuator, not the Matlab variable). You are passing 'act' but you have not assigned a name to your PathActuator. Try adding
after you create the PathActuator.
Re: Method for giving control signal to path actuator
Posted: Fri Jan 24, 2020 9:35 pm
by sambhav.ratna
Thanks, that worked. I understood what I was doing wrong.
Re: Method for giving control signal to path actuator
Posted: Thu Jul 09, 2020 8:11 am
by eadooley
I had this same issue. Thanks for following up. This thread is really helpful.
In the example from the webinar, the Matlab variable and the name assigned to the actuator were the same, so it was not clear it needed the name of the actuator. Is it good practice for these two things to have the same name?
Thanks again,
EAD