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

Re: How to change local coordinates to global coordinates

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

Another question:
In inverse kinematics, i want to modify the InverseKinematics.cpp to enable the following functionality:
Add 2 markers on the scapula, for every moment, ensure that the distance between the markers and the mass center is minimal. The problem is, how can I know the actual position of my markers during the mouvement? In the .trc file I only have coordinates for other points, I can't see how we can get the coordinate of my 2 markers.
If I understood the InverseKinematics correctly, the program will, for every moment, calculate the minimal distance between the marker's real position(recorded in .trc) and it's experimental position(don't know where is stored), but it will only work for those markers who have a certain weight and coordinates in the .trc file, so when the marker have no .trc records, it won't work.

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 » Tue Jun 13, 2017 11:09 am

Code: Select all

if (bs[i].getName() == "scapula"){
fromBody = bs[i];
cout << "fromBody found!!!" << endl;
}
else if (bs[i].getName() == "ground"){
toBody = bs[i];
cout << "toBody found!!!" << endl;
}
You are getting in the first if statement but you are not getting in the second. Then the body that you defined initially does not point to a valid body.

You can get a body form the BodySet by name e.g. bodySet.get("scapula"), if the body exists.

Best

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 » Tue Jun 13, 2017 11:32 pm

In inverse kinematics, i want to modify the InverseKinematics.cpp to enable the following functionality:
Add 2 markers on the scapula, for every moment, ensure that the distance between the markers and the mass center is minimal.
You have to implement your own optimization objective here, because InverseKineamtics.cpp calls the underlying Simbody for performing a tracking step.

Please see this for more details on how to create your own optimization:
http://simtk-confluence.stanford.edu:80 ... timization
In the .trc file I only have coordinates for other points, I can't see how we can get the coordinate of my 2 markers.
The .trc contains the positions of the markers that were recorded for a particular experiment. Maybe this experiment did not contain the two markers of the scapula that you are interested.

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 » Wed Jun 14, 2017 12:33 am

mitkof6 wrote: You can get a body form the BodySet by name e.g. bodySet.get("scapula"), if the body exists.
Thank you for your answer!
I tried all these two possible methodes:
toBody = markerSet[1].getBody();
toBody = bodyset.get("scapula");
and none of them work, while I can use
bodyset[1].getName(); and markerSet[1].getOffset(), which means that I got the correct markerSet object and bodySet object, I just cannot get the body object.

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 » Wed Jun 14, 2017 12:50 am

Code: Select all

const OpenSim::Ground& ground = model.getGround();
const OpenSim::Body& scapula = bodyset.get("scapula");

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 » Wed Jun 14, 2017 7:59 am

mitkof6 wrote:

Code: Select all

const OpenSim::Ground& ground = model.getGround();
const OpenSim::Body& scapula = bodyset.get("scapula");
Last question :)
How can I transforme OpenSim::Body to SimTK::Body?

User avatar
Jason Hodges
Posts: 1
Joined: Fri Jun 16, 2017 12:14 pm

Re: How to change local coordinates to global coordinates

Post by Jason Hodges » Fri Jun 16, 2017 12:17 pm

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 http://gratisvps.net know why it doesn't work.

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

Re: How to change local coordinates to global coordinates

Post by Thomas Uchida » Sat Jun 17, 2017 1:57 am

Can you explain why?
Not with the information provided. Was that the entire error message? It would help if you posted your code.

POST REPLY