How to display the path of a customized actuator in the gui?
- ruoshi wen
- Posts: 32
- Joined: Sat Jun 17, 2017 7:44 pm
How to display the path of a customized actuator in the gui?
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?
- 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?
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.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.
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()).
- 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?
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()?
Here's another question.
Is there a default color displaying the path if I don't implement computePathColor()?
- 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?
Yes, there is a default color.Is there a default color displaying the path if I don't implement computePathColor()?
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).
- 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?
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)
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)
- 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?
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.I want to visualize my model in OpenSim 3.3 GUI