The Question and Answer and Support Forum for the 2017 Fall Virtual Workshop.
-
Hide Kimpara
- Posts: 135
- Joined: Mon Sep 19, 2016 5:12 am
Post
by Hide Kimpara » Wed Oct 25, 2017 6:10 am
Hello,
The centralized controller needs gravity vector. We used following method to get gravity vector from SimBody in C++ programming (see below code). Then I tried to extract same variables using OpenSim 4.0 in MATLAB. However, I could not find method "getBodyForces" from osimModel.getGravityForce() in MATLAB.
On the other hand, a sample MATLAB script "testSimbody.m" shows variable term "appliedBodyForces" for calcResidualForce. However, this sample does not contain actual BodyForces.
Is there any methods to get BodyForces from OpenSim 4.0 in MATLAB?
Code: Select all
Vector g;
_model->getMatterSubsystem().multiplyBySystemJacobianTranspose(s, _model->getGravityForce().getBodyForces(s), g);
Thank you,
Hide
-
Hide Kimpara
- Posts: 135
- Joined: Mon Sep 19, 2016 5:12 am
Post
by Hide Kimpara » Wed Oct 25, 2017 11:14 am
Hello Christopher,
Oh, I see... It's open-source program. Yes, you are right. If we need them, we have to add them by ourselves.
However, unfortunately, we don't have any experience of wrapping methods for MATLAB.
Can we ask OpenSim team to add wrapping methods for coming formal release?
Also, in the meanwhile, we'd like to solve as much as possible we can... Could you give us some examples of ways to wrapping demanding methods?
Thank you
Hide
-
Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Post
by Christopher Dembia » Wed Oct 25, 2017 11:38 am
You could try adding the following line to simbody.i and then rebuild the MATLAB wrapping.
Code: Select all
%include <simbody/internal/Force_Gravity.h>
-
Hide Kimpara
- Posts: 135
- Joined: Mon Sep 19, 2016 5:12 am
Post
by Hide Kimpara » Wed Oct 25, 2017 12:43 pm
Hi Christopher,
Thank you for your suggestion.
I changed the simbody.i under C:\opensim-core-source, is it correct?
Then I go back to the step of "Configure and generate project files" as (
https://github.com/opensim-org/opensim-core).
But I got several errors in RUN_TESTS_PARALLEL as following image:
- Error_Parallel_Test.png (155.56 KiB) Viewed 409 times
I have 3 questions:
1) target file of simbody.i was under C:\opensim-core-source or C:\opensim-core ?
2) Which point should I start rebuilding for wrapping?
3) I kept C:\opensim-core-build before CMAKE building. But should I remove it before?
Thank you
Hide
-
Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Post
by Christopher Dembia » Wed Oct 25, 2017 12:46 pm
1) target file of simbody.i was under C:\opensim-core-source or C:\opensim-core ?
C:\opensim-core-source. There should be no simbody.i in C:\opensim-core.
2) Which point should I start rebuilding for wrapping?
I'm not sure what you mean.
3) I kept C:\opensim-core-build before CMAKE building. But should I remove it before?
You do not need need to change anything about CMake or C:\opensim-core-build. Simply build the INSTALL project in Visual Studio.
The tests that failed are the tests for the python wrapping. From your screenshot, I cannot see the reason why these tests failed.
-
Hide Kimpara
- Posts: 135
- Joined: Mon Sep 19, 2016 5:12 am
Post
by Hide Kimpara » Wed Oct 25, 2017 1:21 pm
Hi Christopher,
The modification looks not so easy for me.
I got some errors during the INSTALL.
Here attached image shows some error relates force.h.
- Error_Force.png (144.61 KiB) Viewed 400 times
Do you have any further solutions?
Thank you
Hide
-
Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Post
by Ayman Habib » Wed Oct 25, 2017 1:38 pm
Hide,
Sorry if we led you to believe that this's a trivial task, it could get quite messy, unfortunately.
From your log it looks that SWIG is having problem parsing/understanding Force_Gravity.h very likely because of the complicated syntax, use of templates typical of Simbody headers and/or because the file is not included in the right place (after all classes it depends on are included). Stepping back maybe we can find a different solution that doesn't involve exposing Force_Gravity at all. Can you list all the methods you need access to from Simbody along with the parameter types used to interface with these methods?
Thanks,
-Ayman
-
Hide Kimpara
- Posts: 135
- Joined: Mon Sep 19, 2016 5:12 am
Post
by Hide Kimpara » Wed Oct 25, 2017 2:52 pm
Hello Ayman,
If it's easy, I think everybody do it. But things are really tough for me...
Currently, we need getGravityForce.
Other things listed on the previous post (
viewtopicPhpbb.php?f=1398&t=8323) looks already wrapped for MATLAB.
If you have solved this matter, can you let us know? We'd like to download from git and try to install it.
Thank you,
Hide