Inverse Dynamics

SimTKcore exists as a separate project to provide 'one stop shopping' for SimTK Core software and support, although the software is actually developed as a set of interdependent projects. SimTK 1.0 was released in March 2008, SimTK 2.0 in December, 2009.
User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Thu Mar 12, 2009 12:38 pm

Hello Peter,

I am trying to implement the method we had discussed here and I am having a hard time doing so.

I first create some bodies (Body::Rigid) and then mobilizes them (MobilizedBody::Orientation).

I the realize the topology, get the default state, then apply orientations to these bodies using setQToFitRotation (I explicitly specify quaternion values here).

Then comes the step where I would realize the state. I tried to use System.realize(State, Stage::Dynamics, but the Stage static members (Dynamics, Topology, etc.) seem to not have been instantiated in the cpp/DLL, giving me a linking error.

Following the realize() call, I would expect to get able to use Responses and Operators, such as System.calcPotentialEnergy, etc.

Any chance you can give me a little pointer as to what I am doing wrong?

I'll give you the code in my next post.

Thanks!

P.-S. I link against SimTKcommon.lib SimTKcpodes.lib SimTKlapack.lib SimTKmath.lib SimTKmolmodel.lib SimTKsimbody.lib SimTKsimbody_aux.lib.

P.-P.-S. The linking error is error LNK2001: unresolved external symbol "public: static class SimTK::Stage const SimTK::Stage::HighestValid" (?HighestValid@Stage@SimTK@@2V12@B)

User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Thu Mar 12, 2009 12:40 pm

const SimTK::Vec3 PelvisCoM = SimTK::Vec3(-1.76, 5.45, 5.42);
const SimTK::Vec3 PelvisRASIS = SimTK::Vec3(3.76, 8.78, 4.15);
const SimTK::Vec3 PelvisLASIS = SimTK::Vec3(3.76, 8.78, -22.09);
const SimTK::Vec3 PelvisRPSIS = SimTK::Vec3(-11.33,8.58,-4.53);
const SimTK::Vec3 PelvisLPSIS = SimTK::Vec3(-11.14,8.97,-13.34);
const SimTK::Vec3 HipCenter = SimTK::Vec3(0, 0, 0);
const SimTK::Vec3 KneeCenter = SimTK::Vec3(3.84, -40.78, 1.38);
const SimTK::Vec3 MedEpi = SimTK::Vec3(7.68, -40.50, -3.21);
const SimTK::Vec3 LatEpi = SimTK::Vec3(3.17, -39.96, 5.47);
const SimTK::Vec3 ThighCoM = SimTK::Vec3(6.45, -40.36, 4.40);

// Create system and subsystems
SimTK::MultibodySystem System;
SimTK::SimbodyMatterSubsystem Matter(System);
SimTK::GeneralForceSubsystem Forces(System);

SimTK::Force::UniformGravity Gravity(Forces, Matter, SimTK::Vec3(0, -9.8, 0));

// Create segments definitions
SimTK::Body::Rigid PelvisSegment(SimTK::MassProperties(3.18, SimTK::Vec3(0), SimTK::Inertia(0.012, 0.017, 0.012)));
SimTK::Body::Rigid ThighSegment(SimTK::MassProperties(11.54, SimTK::Vec3(0), SimTK::Inertia(0.197, 0.058, 0.197)));

// Add bodies to the system
SimTK::MobilizedBody::Orientation Pelvis(
Matter.Ground(),
SimTK::Transform(SimTK::Vec3(0,0,0)),
PelvisSegment,
SimTK::Transform(SimTK::Vec3(0,0,0)));

SimTK::Vec3 RHipRotCenter = PelvisCoM;
SimTK::MobilizedBody::Orientation RightThigh(
Pelvis,
SimTK::Transform(RHipRotCenter),
ThighSegment,
SimTK::Transform(RHipRotCenter - ThighCoM));

SimTK::Vec3 LHipRotCenter = SimTK::Vec3(PelvisCoM(0), -PelvisCoM(1), PelvisCoM(2));
SimTK::Vec3 Outer = RHipRotCenter - ThighCoM;
Outer = SimTK::Vec3(Outer(0), -Outer(1), Outer(2));
SimTK::MobilizedBody::Orientation LeftThigh(
Pelvis,
SimTK::Transform(LHipRotCenter),
ThighSegment,
SimTK::Transform(Outer));

System.realizeTopology();
SimTK::State State = System.getDefaultState();
Pelvis.setQToFitRotation(State, SimTK::Rotation(SimTK::Quaternion(0.998287198986834, 0.449425149905188, -0.403966721902387, 0.146608128192425)));
LeftThigh.setQToFitRotation(State, SimTK::Rotation(SimTK::Quaternion(0.71571603148505, -0.051844570408622, 0.200838132439153, 0.747317297152225)));
RightThigh.setQToFitRotation(State, SimTK::Rotation(SimTK::Quaternion(-0.77904948785205, -0.08002974995868, -0.043528498571530, 0.876441751469790)));
System.realize(State);

double PE = System.calcPotentialEnergy(State);

User avatar
Peter Eastman
Posts: 2602
Joined: Thu Aug 09, 2007 1:25 pm

RE: Inverse Dynamics

Post by Peter Eastman » Thu Mar 12, 2009 2:57 pm

Hi,

If you're getting a linking error, the problem is probably in the way you're compiling or running, not in the code. Does the error occur at compile time or run time? You need to make sure you have all the proper libraries in your compile/run path. Also, are you statically or dynamically linking to the libraries?

Peter

User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Thu Mar 12, 2009 3:34 pm

Hello Peter,

I am linking dynamically and I get the error at link time.

Note that I ran simulations without any problems. It is specifically the realize() call (which has a 2nd default argument of Stage::LastValid or something like that) that is causing problems.

User avatar
Michael Sherman
Posts: 812
Joined: Fri Apr 01, 2005 6:05 pm

RE: Inverse Dynamics

Post by Michael Sherman » Thu Mar 12, 2009 3:47 pm

Hi, J-O. Can you capture the link messages and post them? Thanks, Sherm

User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Thu Mar 12, 2009 5:06 pm

They are in my original message, in the P.-.P.-S. section, at the bottom.

Thanks guys,

User avatar
Michael Sherman
Posts: 812
Joined: Fri Apr 01, 2005 6:05 pm

RE: Inverse Dynamics

Post by Michael Sherman » Sat Mar 14, 2009 12:18 pm

Thanks, J-O.

Your code looks perfectly reasonable to me. It appears that the static symbol SimTK::Stage::HighestValid is not being found in SimTKcommon.lib where it should be. This is of course a very common symbol since it is used as the default value for the second realize() parameter, so I am confident that it is normally present in our released libraries.

Can you provide some details about how you are building and linking? Are you using our prebuilt binaries or have you built your own from source? What Windows OS are you running? What version of what build environment? Are there other undefined symbols? How about other Stage values -- you could try an explicit realize(s,Stage::Report) which is the value of HighestValid.

Regards, Sherm

User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Mon Mar 16, 2009 10:42 am

Hello Sherm,

I am surprised by your answer: is it possible to build from source? Each time I looked at the SVN access, it seems all there is in there is the documentation and some build information, I've never seen any source code. Where can I get the source to build from it? This would make debugging problems such as my current problem a lot easier to solve...

In any case, I sent you (by e-mail) my solution/project for you to check. I have Vista 64 and my solution is a 32 bits solution, using VS2005.

This also brings me to another question: is there plans to have a 64 bits version of SimTKCore? If so, what are they?

Thanks!

POST REPLY