Closed idhamari closed 4 years ago
Hi @idhamari do you have a link or an exemple that explain what is the integrator and accuracy in a simulation
@yasseerr
The simboy theory book explains everything.
In short, as I understood:
A good example: pendulumDF.zip. It creates the model .osim file, use opensim manager to set the integrator settings then calls the visualizer to visualize the simulation. This example does not use the java interface and it is a direct connection between the visualizer and the opensim library. You need only to set the opensim path in the cmake file.
For the current task, usually, we only provide the simulation final time and opensim uses default values for other integrator settings.
thanks for the explanation in the pendulumDF code there is a manager that you introduce thees parameters to , and its connected to the model.
for now the simulation normaly works but needs some frame rate configuration (latest commit on the simulation branch).
next, do you want each simulation to have a Manager to use the (accuracy and integrator) or you want to put a checkbox that allows you to choose wether to use them or not.
@yasseerr
Excellent :watermelon: , I thought this would take you some time to complete, I am impressed :)
works but needs some frame rate configuration
Usually, there should be a small toolbar for the simulation to control the time and the speed e.g.
next, do you want each simulation to have a Manager to use the (accuracy and integrator) or you want to put a checkbox that allows you to choose whether to use them or not.
This can be handled using a "Simulation" menu item as in the attached video. SimulationMenu.zip
@yasseerr
Update:
I just tested the code, here is a feedback:
I think the Simulation toolbar looks excellent, an improvement would be:
Bugs:
`
applying simulation to this model "arm2626" simulation ended playing results for: "arm2626" Storage: read data file =arm2626_states.sto (nr=347 nc=17) motion is being updated visuazer vtk "vtkVisualiser" visuazer vtk "vtkVisualiser" Motion Name : "states" corrdinate name in model : "r_shoulder_elev" corrdinate name in model : "r_elbow_flex" motion is being updated current motion changed TIME_STEP: 33 libpng warning: iCCP: known incorrect sRGB profile VisSim: Getting object prperties is done ........................ libpng warning: iCCP: known incorrect sRGB profile bug here ================================ start Object 0 1 bug here ================================ end VisSim: Getting object prperties is done ........................ corrdinate name in model : "r_shoulder_elev" corrdinate name in model : "r_elbow_flex" corrdinate name in model : "r_shoulder_elev" corrdinate name in model : "r_elbow_flex" corrdinate name in model : "r_shoulder_elev" corrdinate name in model : "r_elbow_flex" Segmentation fault (core dumped)
`
thanks for your response. although there are some points i didnt finish yet
add the sample rate or frames per second, option to control the animation speed. add the integrator IDs and names instead of their IDs. 3 default values: endtime=3 seconds, step size = 0.001, accuracy =0.0000001, integrator= 4. RungeKuttaMerson
this 3 points are added exept the integration of the values of the Manager and they will be implemented next
Bugs: I don't see animation of the simulation I don't see simulation output actually this should appear in the messages window under the visualizer windoe. after the simulation when running the motion, the program crashed Here is part of the output.
indeed when i tested on other modules like the arm26 it craches, although my first assumption was based on the pandulium in this video Simulation_Video . it appears that the sto files generated by the simulation contain different names and indecies from the ones in the Model and the differences will be investigated.
for the output a reporter will be added to get the output values.
@yasseerr
these 3 points are added except the integration of the values of the Manager and they will be implemented next
Thanks for the info. Please push the final code when you complete so I can test it.
indeed when i tested on other modules like the arm26 it crashes, although my first assumption was based on the pandulium in this video Simulation_Video . it appears that the sto files generated by the simulation contain different names and indices from the ones in the Model and the differences will be investigated.
I confirm this, the motion works using double_pendulum.osim. I noticed that the OpenSimDocument versions are different
@yasseerr
I was checking the code and I found out that you implemented the simulation using applySimulationToModel function which read a motion file, or maybe I missed something?.
I think this is not online animation as as what happens in pendulumDF example I attached above. The visualizer should interact directly with the optimizer output state each step-size (or number of step-size steps) and animate the model based on the result from that state.
@idhamari it is a life simulation when you run simulate(model,state,endtime,true) with the last parameter as true it will create a motion_file at the end of simulation that follows this naming modelName_states.sto . you can remove it and when you run the simulation it will be generated again the file will be loaded then and displayed to be able to investigate the simulation , at least this is how netbeans do it (call simulate()).
for the integrator i ddnt implement it yet and will see how it retreive and save its states. as in the pendulumDF exemple you didn't call simulate and called the manager integrate instead . i will see how it works and report back.
@yasseerr
Thanks for your clarification, probably I should trace the code.
as in the pendulumDF exemple you didn't call simulate and called the manager integrate instead . i will see how it works and report back.
I think Simulate function uses the manager as well. Maybe we can create our own manager e.g. vsOpemSimManager that override the functions in the original manager class to provide more options?
update! now the simulation is done using a manager in applySimulaitonToModelUsingManager() function in vsMotionUtils. the output of the reporters kinematic,velocity and states will be generated inside the Simulations folder where the executable is. the bug in the arm26 was not related to simulation but to motion update(optimisation), the current code dosnt update the properties and it redraws the model entirely (slow), just to isolate the bugs. investigating the indexation bug next.
I think Simulate function uses the manager as well. Maybe we can create our own manager e.g. vsOpemSimManager that override the functions in the original manager class to provide more options?
yes it seems that simulate is a wrapped around a manager , the openSimManager can be found in the vsMotionUtils as activeManager. if you have options to add to the manager we should create a class.
@yasseerr
well done :watermelon:
the bug in the arm26 was not related to simulation but to motion update(optimisation), the current code doesn't update the properties and it redraws the model entirely (slow), just to isolate the bugs. investigating the indexation bug next.
just checked it, the arm model is not animated during the simulation but now the motion works as you mentioned too slow (also in my system, it seems the whole thing including the ground is moving)
yes it seems that simulate is a wrapped around a manager , the openSimManager can be found in the vsMotionUtils as activeManager. if you have options to add to the manager we should create a class.
I don't mind leaving it as it is if it works.
investigating the indexation bug next.
I am looking forward to seeing a working solution :)
@idhamari i think it works now . the visualizer bug that causes the simulation to crash was solved. a shift in simulation/motion states indecies that made the simulation looks different then when it runs in netbeans was corrected.
check to see if there are some points that still missing. just a note ,the bug with the extra muscles is still in the run.
@yasseerr
the visualizer bug that causes the simulation to crash was solved.
Well done :watermelon: I see you are doing an excellent job in a very short time, you being more and more expert in openhsim :) I hope the tasks are not taking much time of your master study/project.
the bug with the extra muscles is still in the run.
This is the last important thing about this milestone, good luck!
hhhh thank you and the presentation of the master/project was delayed becauase of COVID and the absence of transport so i had this days to focus on OpenSim
This is the last important thing about this milestone, good luck!
it its appear to be some gememetries update function is not being called at each fram that's it should be solved tommorow
@yasseerr
I just checked the last commit. Looks great, the motion bug is fixed and the performance is excellent. There are only two comments (you can check this later after completing the missing stuff):
@idhamari
my current understanding as presented in netbeans when you click simulate the OpenSim calculate the states direcly(for all times) and label each state with its time . for exemple if the simulation takes(200seconds) and the object is simple it will generate the states in less then 4seconds. but the simulation is labeled with 200s it is not live. it became life when you start reading the states from the storage generated according to the time label. and that happend when you start the motion. at least this is how our visualizer and netbeans do it . for the default visualizer i will check with the code to see what they are using. but if we do it life we need to do one calculations and one rendring then stop the process and then calculating again instead of doing the calculations all at ones and then visualize it. i will see in the visualizer if they are using the first or the second and report back. One more note i noticed that the step of 0.001 that means 1000frame/second and 1000 line in the storage data for one second and that can slow the simulation calculation knowing that the humain eye i think only needs 120frame/s max. unless there are a use case i dont know about .
for the integrator i think i linked it to the simulation manager . i will run the pendulium exemple and try to spot the differences because i thought before they are multiple techniques to generate the same simulation. i will investigate the differences and fix it when finishing the missing stuff.
@yasseerr
I had a problem with git so I had to rewrite the code so some updated stuff is not working yet. The code is pushed to the master branch
Here are the remaining (hopefully small) tasks:
@idhamari ok i will start executing this task and give updates when needed.
@idhamari 1-2 the colorizing and selection and deselection are now implemented 3- the renaming of the bodies from the visualizer is working and the linked attributes are updated when calling finilize as you can check on the properties table at least on windows , give it a try on linux . note that the model is not saved to file untill you click the save/saveAs action 4- creating the model from the template was not working because the pendulum file was not accepted by opensim(currupted). a changed it to arm26 and it will load it when you click new model. you can change the template.osim file and run cmake to change the default model. 5- edit model externaly is working now note that it is recomended to set the prefered program to open the file with in the operating system
all of the above changes are in the simulation branch
Well done @yasseerr :watermelon: This issue is now closed. I will test it and if needed, I will add a feedback.
This is an important element in the interface that need more understanding of how the visualizer interacts with the model during the simulation. Notice that, the simbody-visualizer can animate the model and run the simulation if it calls from a cpp file. We may do the same. I will explain this in detail when we start working on this task. Another way is to call opensim-cmd with an xml file then use the load motion from the previous task.
We will have: