ia-dev / opensimQt

CPP GUI for OpenSim
Apache License 2.0
5 stars 6 forks source link

MS0201: implement load motion #11

Closed idhamari closed 4 years ago

idhamari commented 4 years ago

Example in

   opensim-gui/opensim-models/Piplines/Gait2354/OutputReference/subject01_simbody.osim
   opensim-gui/opensim-models/Piplines/Gait2354/OutputReference/subject01_walk1_ik.mot

note that later, we will do the simulation in a somehow similar way.

idhamari commented 4 years ago

@yasseerr

I saw you already updated the code. How is the progress so far? did you figure out how to animate the 3D view based on the motion file?

yasseerr commented 4 years ago

hi! @idhamari The progress is doing some what fine after some code inspection, the data in the motion file is loaded and assigned to the model but for now only the first frame/state of the motion is displayed(to be checked if it is aligned) and i'm currently working on the animation frame by frame by updating the 3D geometries in response to a Timer.

idhamari commented 4 years ago

for now only the first frame/state of the motion is displayed(to be checked if it is aligned)

Well done :watermelon: I think this is the difficult part, to understand how OpenSim treats the geometry and present them in the 3D widget, you may get crazy-looking animation based on the configuration as a small error in the transformation makes everything goes wrong. I suggest you check the example I provided as it uses only OpenSim without the java interface (you get a direct connection between the visualizer and opensim).

Please notice that the animation in the simulation is similar, the only difference is these states are generated online.

yasseerr commented 4 years ago

you are right i'm currently trying to adjust the crazy-looking animations and will switch to the code you posted in the open-sim forum as it looks more straight forward 2020-06-21_22-02-14

idhamari commented 4 years ago

I had the same thing when I worked with this before (the problem was the angles unit). Try to trace frame 0 and frame 1 and check what is wrong. Check how somebody visualizer handles the information. Probably there are transformations happen within the simbody visualizer code.

I am not sure if we need this but probably we may a need a transformation class from opensim to vtk. It should transform everything from opensim world to vtk world.

Please note:

  1. angles unit are important e.g. radian and degrees (try to check which one should work).
  2. relative coordinates concept: this is usually is already handled in the somebody visualizer. As I understood, if body2 or joint2 belongs to body1 the location information of body2 or joint2 are relative to body one not to the ground system e.g. if body2 location is 1,1,1 this means it has 1 distance unit from body1. Everything about this in the somebody pdf book you find in the documentation (you may need to build the documentation) titled "SimbodyTheoryManual".

If you like, we can arrange an online meeting this week.

yasseerr commented 4 years ago

thanks for the notes! and the methodes for handling changes/transforms from opensim to vtk are created in the vtkVisualizer, with radian unit. but what left is to implement the tool bar buttons and popup menu for the motion. also i'm trying to optimize the perfermance, because the motion is slow when rendering frames eventhough calculations needed are minimized. for the meeting contact me when you have time. 2020-06-22_18-33-26

idhamari commented 4 years ago

This looks great. Thanks for the excellent job :watermelon:

but what left is to implement the toolbar buttons and popup menu for the motion.

For now, only the motion toolbar functions are needed. You may ignore the popup menu.

also i'm trying to optimize the performance because the motion is slow when rendering frames even though calculations needed are minimized. for the meeting contact me when you have time.

I will test this in my workstation with 32GB memory and RTX2080Ti GPU and report. Please let me know if the updated code is already in your branch.

Please check if the problem from vtk, qt, the images in the widget, or size of the stl:

for the meeting contact me when you have time.

This week is already booked. What about next week on Tuesday at 11:00 or 17:00 German time?

idhamari commented 4 years ago

@yasseerr

Update: I just checked the code. The performance seems to be OK and the motion looks normal. Please implement the toolbar and close this issue.

Note: I have only a problem interacting with the widget before loading the model or the motion (this problem wan not there before). When moving the mouse it acts as drag (e.g. click and move) which makes the objects rotate with the mouse movement. I suspect this is a Linux-Qt problem as I have this before with other programs so you may ignore this problem for now until I check this in my windows.

yasseerr commented 4 years ago

@idhamari another update, i just pushed an optimized code for motion exemple now it moves kind of smoothly even though it is not on a RTX2080Ti 🥇 i will optimise more whenever possible ,i'm switching now to the tool bar. concerning the dragging error try with the last commit although it does not appear on windows. if it is consistent i will try it on a VM. for the meeting next week on Tuesday is good.

idhamari commented 4 years ago

@yasseerr well done! by the way, in my previous comment, I tested the code on my laptop not on a workstation. The performance was good. I will check your updated code soon and provide feedback if needed.

yasseerr commented 4 years ago

hello @idhamari the motion tools are implemented give them a check to see if something is missing . currently i'm merging the simulation with the master.

idhamari commented 4 years ago

Well done :watermelon: I will close the issue for now and it can be-reopened if needed.

With the current knowledge from the motion, handling the simulation task should be much simpler. You can check the same pendulum example and see how the visualizer work during the simulation process. In the simulation process, opensim computes the states online then sends them to the visualizer to animate the model, when the simulation completed, opensim load the motion to the navigator so the user can save it to a file if needed.

idhamari commented 4 years ago

@yasseerr

Two more todos here:

Model: Pipelines/Gait2354_Simbody/OutputReference/subject01_simbody.osim Motion: Pipelines/Gait2354_Simbody/OutputReference//subject01_walk1_ik.mot

Screenshot from 2020-06-25 10-38-05

Screenshot from 2020-06-25 10-43-26

yasseerr commented 4 years ago

Update: the make current option on the motion popup menu is implemented but the reason for why that rogue muscle appear i couldn't find it yet

idhamari commented 4 years ago

@yasseerr

well done!

but the reason for why that rogue muscle appear i couldn't find it yet

it is OK for now, we will have a good idea after the implementation of simulation. Please proceed to the next task in this milestone.

yasseerr commented 4 years ago

thanks! just a note i found out that when i recreate the vtk actors each frame instead of just changing the coordinates ,rotaion and display properties the problem go away . It is done like that in netbeans but it causes a huge lack of performance when implemented in vtk. so that muscle is a performance optimization issue, and i will try and find how to mix the two solutions to avoid the muscle being rendered. after finishing the Simulation.

idhamari commented 4 years ago

I already created a new issue to handle this. Please keep the related discussion there. I will copy your feedback to the new issue. For now please concentrate on the simulation task as it is the final task in this milestone (other tasks will be handled by the other students).