set Markers weight in inverse kinematics by C++ API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
pan zhengye
Posts: 7
Joined: Sat Aug 14, 2021 7:20 pm

set Markers weight in inverse kinematics by C++ API

Post by pan zhengye » Tue Sep 07, 2021 7:21 am

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();
}

Tags:

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

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

Post by Ayman Habib » Tue Sep 07, 2021 7:54 am

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

User avatar
pan zhengye
Posts: 7
Joined: Sat Aug 14, 2021 7:20 pm

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

Post by pan zhengye » Tue Sep 07, 2021 7:57 am

Thanks! I think it will be very helpful for me.

POST REPLY