How to change local coordinates to global coordinates
How to change local coordinates to global coordinates
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!
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!
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: How to change local coordinates to global coordinates
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.)
Re: How to change local coordinates to global coordinates
Thank you!
In fact, my question is, in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?
In fact, my question is, in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?
Re: How to change local coordinates to global coordinates
Thank you!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.)
In fact, my question is, in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: How to change local coordinates to global coordinates
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.in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: How to change local coordinates to global coordinates
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
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
Re: How to change local coordinates to global coordinates
When I applied the function "_model->getSimbodyEngine().transformPosition(s, fromBody, marker_1_pos, toBody, newLoc);", it says thattkuchida wrote: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.in the c++ code, is there a function to transform local coordinates to global coordinates or conversely?
> 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
- Thomas Uchida
- Posts: 1790
- Joined: Wed May 16, 2012 11:40 am
Re: How to change local coordinates to global coordinates
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?Can you explain why?
Re: How to change local coordinates to global coordinates
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!
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!
Re: How to change local coordinates to global coordinates
Thank you!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
BTW are you able to solve my problem?