How to display the path of a customized actuator in the gui?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
ruoshi wen
Posts: 32
Joined: Sat Jun 17, 2017 7:44 pm

How to display the path of a customized actuator in the gui?

Post by ruoshi wen » Mon Aug 14, 2017 4:44 am

I want to create an actuator of McKibben type and it's similar to the PathActuator. I notice that the muscle path can be displayed in the gui. So I was wondering how to display the path of a customized actuator created by myself. Do I need to write some related code when I create my own actuator or do you have some good idea?

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

Re: How to display the path of a customized actuator in the gui?

Post by Thomas Uchida » Mon Aug 14, 2017 2:47 pm

I want to create an actuator of McKibben type and it's similar to the PathActuator. I notice that the muscle path can be displayed in the gui. So I was wondering how to display the path of a customized actuator created by myself.
The McKibben actuator is available in the latest version of OpenSim (https://github.com/opensim-org/opensim- ... Actuator.h) so you could try using that; if you decide to implement it yourself (e.g., in OpenSim 3.3), you could use this code as a reference.

Regarding your question: the path-drawing work is done by GeometryPath::generateDecorations(). If your class inherits from PathActuator, then it will already contain a GeometryPath and its path will be drawn. The only thing you might want to do is change the color (e.g., make it a function of the tension), which you can do by implementing computePathColor() (see PathActuator::computePathColor()).

User avatar
ruoshi wen
Posts: 32
Joined: Sat Jun 17, 2017 7:44 pm

Re: How to display the path of a customized actuator in the gui?

Post by ruoshi wen » Sun Aug 20, 2017 6:20 pm

Thank you so much and your guidance will be a lot of help.
Here's another question.
Is there a default color displaying the path if I don't implement computePathColor()?

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

Re: How to display the path of a customized actuator in the gui?

Post by Thomas Uchida » Sun Aug 20, 2017 8:23 pm

Is there a default color displaying the path if I don't implement computePathColor()?
Yes, there is a default color.

The default color is set to SimTK::Gray when the underlying property is constructed in GeometryPath::constructProperties() (see line 185 in GeometryPath.cpp: https://github.com/opensim-org/opensim- ... h.cpp#L185). SimTK::Gray assigns RGB values of 0.5, 0.5, 0.5 (see the Simbody doxygen here: https://simtk.org/api_docs/simbody/3.5/ ... 888b2c9211).

User avatar
ruoshi wen
Posts: 32
Joined: Sat Jun 17, 2017 7:44 pm

Re: How to display the path of a customized actuator in the gui?

Post by ruoshi wen » Mon Aug 21, 2017 2:10 am

I want to create a McKibbenActuator under api 3.3.
Do I need to compile and build all the source code of opensim 3.3 after I create the actuator?
Or should I add the McKibbenActuator.cpp and McKibbenActuator.h to under the main.cpp that I create to do a simulation?(I want to visualize my model in OpenSim 3.3 GUI)

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

Re: How to display the path of a customized actuator in the gui?

Post by Thomas Uchida » Tue Aug 22, 2017 12:47 am

I want to visualize my model in OpenSim 3.3 GUI
In that case, you will need to create a plugin and load it in the GUI before opening the model; otherwise, the 3.3 GUI won't know what to do with a McKibbenActuator component. See the "Creating Plugins" page in the Confluence documentation (https://simtk-confluence.stanford.edu:8 ... ng+Plugins). You can find example code in your local OpenSim installation directory (under \sdk\APIExamples\Plugins\) and on several SimTK project pages.

POST REPLY