Page 1 of 1

set Markers weight in inverse kinematics by C++ API

Posted: Tue Sep 07, 2021 7:21 am
by panzhengye123
Dear opensim team
hello, I want to set Markers weight in inverse kinematics by C++ API. However, after I made the following settings, nothing changed.

Code: Select all

int main() {
	Model test("arm26.osim");
	InverseKinematicsTool* IK =
		new InverseKinematicsTool();
	IK->setModel(test);
	IK->setMarkerDataFileName("arm26_elbow_flex.trc");
	OpenSim::Set<MarkerWeight>* marker_weight =
		new OpenSim::Set<MarkerWeight>();
	marker_weight->insert(0, new MarkerWeight("r_acromion", 10));
	marker_weight->insert(1, new MarkerWeight("r_humerus_epicondyle", 1));
	marker_weight->insert(2, new MarkerWeight("r_radius_styloid", 1));
	IKTaskSet IKT = IK->getIKTaskSet();
	IKT.createMarkerWeightSet(*marker_weight);
	IK->setStartTime(0.0);
	IK->setEndTime(1.0);
	IK->run();
}

Re: set Markers weight in inverse kinematics by C++ API

Posted: Tue Sep 07, 2021 7:54 am
by aymanh
Hi Pan,

For C++ code examples/snippets you can consult our source code repository on github, in particular test cases that exercise the functionality, e.g.
https://github.com/opensim-org/opensim- ... testIK.cpp

Hope this helps,
-Ayman

Re: set Markers weight in inverse kinematics by C++ API

Posted: Tue Sep 07, 2021 7:57 am
by panzhengye123
Thanks! I think it will be very helpful for me.