Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MS0201: implement load motion #11

Closed
2 tasks done
idhamari opened this issue Mar 22, 2020 · 17 comments
Closed
2 tasks done

MS0201: implement load motion #11

idhamari opened this issue Mar 22, 2020 · 17 comments

Comments

@idhamari
Copy link
Contributor

idhamari commented Mar 22, 2020

Example in

   opensim-gui/opensim-models/Piplines/Gait2354/OutputReference/subject01_simbody.osim
   opensim-gui/opensim-models/Piplines/Gait2354/OutputReference/subject01_walk1_ik.mot
  • implement load motion in file menu
  • implement the functions of the motion tool bar
    • the loaded motion should "animate" the model in the visualizer.
    • we should be able to control this animation e.g. speed and time.
    • for moving beyond the final time we either interpolate or repeat.

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

@idhamari idhamari added this to the MileStone 2: Simulation milestone Mar 22, 2020
@idhamari
Copy link
Contributor Author

@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
Copy link
Contributor

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
Copy link
Contributor Author

idhamari commented Jun 21, 2020

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

Well done 🍉 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
Copy link
Contributor

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
Copy link
Contributor Author

idhamari commented Jun 22, 2020

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
Copy link
Contributor

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
Copy link
Contributor Author

This looks great. Thanks for the excellent job 🍉

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:

  • how is the performance in an external vtk widget without qt (only the stl files)?
  • how is the performance in an external vtk widget without qt (the stl files + others except for images)?
  • how is the performance in an external vtk widget without qt (with everything)?
  • how is the performance in an external vtk widget without qt (with everything)?

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
Copy link
Contributor Author

@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
Copy link
Contributor

@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
Copy link
Contributor Author

@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
Copy link
Contributor

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
Copy link
Contributor Author

Well done 🍉
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
Copy link
Contributor Author

@yasseerr

Two more todos here:

  • Handling multiple motions. If multiple motion files are loaded, the user should be able to selects a motion from the navigator then animate the model based on the selected motion using the motion control bar.
    • this has less priority so if it takes a long time you may ignore it.
  • Fixing a bug. I found a bug while testing the code today. Some geometry is not moving correctly (in one of the legs). The figure shows the time frame 1.048 on both opensimQt and opensim Java interface. I double-checked this by reoppining the application and the model multiple times.

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
Copy link
Contributor

yasseerr commented Jun 27, 2020

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
Copy link
Contributor Author

@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
Copy link
Contributor

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
Copy link
Contributor Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants