Add a function to get the kinetic and potential energy of a node from a python script#504
Conversation
alxbilger
left a comment
There was a problem hiding this comment.
Great! Thanks
Does it work? Have you tested?
The problem is that not all the components implement the computation of the energies.
|
I haven't tested it yet, I can't build the plugin for some reason. I opened a topic in the forum : sofa-framework/sofa#5554 |
|
I have managed to build it in-tree. It works great for a simple scene with an object sliding on an incline. Do you happen to know which components may be a problem and need to be tested ? |
|
I cannot be specific, but usually, there is a runtime warning such as For example: |
|
So from what I read, the methods that are not implemented actually just return 0. So the code will run, produce a warning, and a wrong result. I think this is fine ? Otherwise, I can change the not implemented method to return NaNs instead of 0. |
|
Sounds reasonable to me to return 0 |
Yes, it's fine |
… a python script (sofa-framework#504) * Add binding to return the energy of a node. * Fix bugs * ADD example scene * Apply suggestions from code review --------- Co-authored-by: Alexandre Blanc <alexandre.blanc@pasteur.fr> Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
As suggested by @alxbilger here
Also adapted from QEnergyStatWidget in Sofa.Qt.
I did not manage to build this yet on my machine, so I haven't tested it.