Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Yu-Wei Chen
- Posts: 13
- Joined: Wed Jan 08, 2014 1:13 am
Post
by Yu-Wei Chen » Thu Dec 18, 2014 2:44 am
Hello, everyone,
I am using PointKinematics in tracking interested points on the model. It runs well in GUI, but when I implement it using C++ API, I encounter some problems. The following is my example code for setting PointKinematics:
Code: Select all
// Set Point Kinematics
PointKinematics pk = PointKinematics();
pk.setName("PointKinematics");
pk.setOn(true);
pk.setStartTime(10.0);
pk.setEndTime(markerData.getLastFrameTime());
pk.setStepInterval(10);
pk.setInDegrees(true);
Model pkModel = Model(pkModelFile);
OpenSim::Body& ground = pkModel.getGroundBody();
OpenSim::Body& torso = pkModel.updBodySet().get("torso");
//pk.setBody(&torso);
//pk.setRelativeToBody(&ground);
pk.setPointName("TEST");
//pk.setPoint(Vec3(0.0, 0.0, 0.0));
There are 3 functions which I commented always throw exception. I have no idea how to fix it? Could anyone help me? Thanks very much.
Best regards,
Yu-Wei
-
Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Post
by Ayman Habib » Thu Dec 18, 2014 11:43 am
Hi Yu-Wei,
Please use the call sequence below (taken from testConstraints.cpp in our source distribution) instead, as your current code creates a PointKinematics analysis with no model underneath it.
PointKinematics *pointKin = new PointKinematics(osimModel);
// Get the point location of the shank origin in space
pointKin->setBodyPoint("shank", Vec3(0));
// You can call any method you want on pointKin here
osimModel->addAnalysis(pointKin);
Please let us know if that works for you.
Best regards,
-Ayman
-
Yu-Wei Chen
- Posts: 13
- Joined: Wed Jan 08, 2014 1:13 am
Post
by Yu-Wei Chen » Thu Dec 18, 2014 11:13 pm
Hello, Ayman,
I add pk.setModel(pkModel) so that the functions do not throw exceptions, and it works for me. My flow is that I output the setup file first (I want to save the configuration file) and then read it to run. I use this trick in my StaticOptimization and JointReaction analysis before.
Thank you very much.
Best regards,
Yu-Wei