opensim 3.3 C++/ add marker problem

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
yujin kim
Posts: 7
Joined: Tue May 30, 2017 9:32 pm

opensim 3.3 C++/ add marker problem

Post by yujin kim » Mon Aug 21, 2017 1:42 am

Hi, I'm trying to use the existing lumbar spine model at the opensim project using opensim 3.3 C++ api.
And I'm new to the opensim api.

I have a problem to add a marker to markerset.
I tried to put the marker to the "lumbar1" and it wasn't working.

Code: Select all

 MarkerSet markerSet = osimModel.getMarkerSet();
			
const BodySet& bodySet = osimModel.getBodySet();
OpenSim::Body l1 = bodySet.get("lumbar1");	
	
const double offset1[] = { 0.5,0.5,0.5 };
Marker& m1 = *markerSet.addMarker("testMarker1", offset1, l1);
osimModel.updateMarkerSet(markerSet);
Please help me.

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

Re: opensim 3.3 C++/ add marker problem

Post by Thomas Uchida » Mon Aug 21, 2017 12:54 pm

Have you tried fetching a writable reference to the MarkerSet instead (i.e., use updMarkerSet() rather than getMarkerSet())? I think the code would look something like this:

Code: Select all

MarkerSet& ms = osimModel.updMarkerSet();
const double offset[] = {0.5, 0.5, 0.5};
Marker* newMarker = ms.addMarker("myMarker", offset, osimModel.getBodySet().get("lumbar1"));

POST REPLY