How to change local coordinates to global coordinates

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

How to change local coordinates to global coordinates

Post by YUAN Ye » Fri Jun 09, 2017 7:13 am

Hello,

Is there a function to change a merker's local coordinate(-0.0461907 -0.0591856 -0.037296 for example) to its global coordinate (1.166667e+00 9.327390e+00 8.491460e+02 for example)?

Thanks a lot!

User avatar
Thomas Uchida
Posts: 1787
Joined: Wed May 16, 2012 11:40 am

Re: How to change local coordinates to global coordinates

Post by Thomas Uchida » Fri Jun 09, 2017 3:00 pm

In the GUI, select the Marker in the Navigator and change the value of its "body" property to "ground"; the value of its "location" property will be transformed from local coordinates into the global frame. (After changing the value of the "body" property, you need to click on another property for the "location" property to update.)

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: How to change local coordinates to global coordinates

Post by YUAN Ye » Mon Jun 12, 2017 1:17 am

Thank you!
In fact, my question is, in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: How to change local coordinates to global coordinates

Post by YUAN Ye » Mon Jun 12, 2017 1:18 am

tkuchida wrote:In the GUI, select the Marker in the Navigator and change the value of its "body" property to "ground"; the value of its "location" property will be transformed from local coordinates into the global frame. (After changing the value of the "body" property, you need to click on another property for the "location" property to update.)
Thank you!
In fact, my question is, in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?

User avatar
Thomas Uchida
Posts: 1787
Joined: Wed May 16, 2012 11:40 am

Re: How to change local coordinates to global coordinates

Post by Thomas Uchida » Mon Jun 12, 2017 1:24 am

in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?
Yes, you can use the transformPosition() method (https://simtk.org/api_docs/opensim/api_ ... 36ab374330). A script that uses this method can be found in the last post on the first page of this thread: viewtopicPhpbb.php?f=91&t=7723.

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: How to change local coordinates to global coordinates

Post by Dimitar Stanev » Mon Jun 12, 2017 1:28 am

Hi,

You can transform a station defined in body "From" to a location define in body "To" (in your case its the ground body).

https://simtk.org/api_docs/opensim/api_ ... 35205654c6

Best

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: How to change local coordinates to global coordinates

Post by YUAN Ye » Mon Jun 12, 2017 6:47 am

tkuchida wrote:
in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?
Yes, you can use the transformPosition() method (https://simtk.org/api_docs/opensim/api_ ... 36ab374330). A script that uses this method can be found in the last post on the first page of this thread: viewtopicPhpbb.php?f=91&t=7723.
When I applied the function "_model->getSimbodyEngine().transformPosition(s, fromBody, marker_1_pos, toBody, newLoc);", it says that

> SimTKsimbody.dll!SimTK::SimbodyMatterSubsystem::getMobilizedBody(SimTK::MobilizedBodyIndex id) Ligne 90 C++
osimSimulation.dll!OpenSim::SimbodyEngine::transformPosition(const SimTK::State & s, const OpenSim::Body & aBodyFrom, const SimTK::Vec<3,double,1> & aPos, const OpenSim::Body & aBodyTo, SimTK::Vec<3,double,1> & rPos) Ligne 486 C++

Can you explain why? I followed your example but still don't know why it doesn't work.
Thanks

User avatar
Thomas Uchida
Posts: 1787
Joined: Wed May 16, 2012 11:40 am

Re: How to change local coordinates to global coordinates

Post by Thomas Uchida » Mon Jun 12, 2017 12:29 pm

Can you explain why?
No, not with the information provided. Is there an error message? What version of OpenSim are you using? Have you confirmed that MATLAB has been configured correctly; do other scripts run?

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: How to change local coordinates to global coordinates

Post by YUAN Ye » Tue Jun 13, 2017 5:00 am

I'm using opensim 3.3, it seems that the problem is the programme cannot get the right body, with following code:
Body fromBody,toBody;
bs = _model->getBodySet();
for (i = 0; i < bs.getSize(); i++){
if (bs.getName() == "scapula"){
fromBody = bs;
cout << "fromBody found!!!" << endl;
}
else if (bs.getName() == "ground"){
toBody = bs;
cout << "toBody found!!!" << endl;
}
}
double distance = _model->getSimbodyEngine().calcDistance(s, fromBody, markerset[1].getOffset(), toBody, markerset[2].getOffset());

I noticed that toBody.getIndex() and fromBody.getIndex() will return -1111111111,
Writting these in InverseKinematicTool.cpp, methode run(),
The error message is :
Exception de première chance à 0x00CE75FB (SimTKsimbody.dll) dans Ellipsoide.exe : 0xC0000005 : Violation d'accès lors de la lecture de l'emplacement 0xF8BAE66C.
Exception non gérée à 0x00CE75FB (SimTKsimbody.dll) dans Ellipsoide.exe : 0xC0000005 : Violation d'accès lors de la lecture de l'emplacement 0xF8BAE66C.
After google translation:
First chance exception to 0x00CE75FB (SimTKsimbody.dll) in Ellipsoide.exe: 0xC0000005: Access violation when reading the 0xF8BAE66C location.
Unhandled exception to 0x00CE75FB (SimTKsimbody.dll) in Ellipsoide.exe: 0xC0000005: Access violation when reading the 0xF8BAE66C location.
I tried your way to get a Body: toBodyName = 'r_humerus';toBody = model.getBodySet().get(toBodyName); doesn't work either.
Is that detailed enough? BTW I'm not using MATLAB but VS2013, thank you!

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: How to change local coordinates to global coordinates

Post by YUAN Ye » Tue Jun 13, 2017 5:03 am

mitkof6 wrote:Hi,

You can transform a station defined in body "From" to a location define in body "To" (in your case its the ground body).

https://simtk.org/api_docs/opensim/api_ ... 35205654c6

Best
Thank you!
BTW are you able to solve my problem?

POST REPLY