How to modify the CoordinateSet

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
ruoshi wen
Posts: 32
Joined: Sat Jun 17, 2017 7:44 pm

How to modify the CoordinateSet

Post by ruoshi wen » Mon Jul 24, 2017 7:49 pm

Hi, all!
I am trying to define a custom joint using OpenSim API 3.3 and create a similar arm to Arm26 which is one of your offical models.
In the arm26.osim file, no matter how I modify my code, I just can't modify the CoordinateSet.
Here's my code.

Code: Select all

CustomJoint* shoulder = new CustomJoint("r_shoulder", ground, locationInGround, orientationInGround, *humerus, locationInHumerus, orientationInHumerus, shoulderST, false);
		using OpenSim::CoordinateSet;
		using SimTK::convertDegreesToRadians;
		using SimTK::Pi;
		// Modify the CoordinateSet
		CoordinateSet shoulderCS = shoulder->upd_CoordinateSet();
		//Coordinate *shoulderCoord = new Coordinate;
		//shoulderCoord->setName("r_shoulder_elev");
		//shoulderCoord->setMotionType(Rotational);
		//shoulderCoord->setDefaultValue(0);
		//shoulderCoord->setDefaultSpeedValue(0);
		//shoulderCoord->setRangeMin(-1.57079633);
		//shoulderCoord->setRangeMax(3.14159265);
		//shoulderCoord->setDefaultClamped(false);
		//shoulderCoord->setDefaultLocked(false);
		//shoulderCS.cloneAndAppend(*shoulderCoord);
		//shoulder->set_CoordinateSet(shoulderCS);
		double shoulderCS0Range[2] = { -Pi/2, Pi };
		shoulderCS[0].setRange(shoulderCS0Range);
		shoulderCS[0].setDefaultValue(0);
		shoulderCS[0].setDefaultLocked(false);
Here's my .osim file generated by my code.(I also tried the code which is commented as above)

Code: Select all

<CoordinateSet>
								<objects>
									<Coordinate name="r_shoulder_elev">
										<!--All properties of this object have their default values.-->
									</Coordinate>
								</objects>
								<groups />
							</CoordinateSet>
I wonder how to modify it using api(I am scripting in C++ to create the arm) and create a .osim with the same properties of CoordinateSet as in arm26.osim. Part of arm26.osim is as follows.

Code: Select all

<CoordinateSet>
								<objects>
									<Coordinate name="r_shoulder_elev">
										<!--Coordinate can describe rotational, translational, or coupled motion. Defaults to rotational.-->
										<motion_type>rotational</motion_type>
										<!--The value of this coordinate before any value has been set. Rotational coordinate value is in radians and Translational in meters.-->
										<default_value>0</default_value>
										<!--The speed value of this coordinate before any value has been set. Rotational coordinate value is in rad/s and Translational in m/s.-->
										<default_speed_value>0</default_speed_value>
										<!--The minimum and maximum values that the coordinate can range between. Rotational coordinate range in radians and Translational in meters.-->
										<range>-1.57079633 3.14159265</range>
										<!--Flag indicating whether or not the values of the coordinates should be limited to the range, above.-->
										<clamped>false</clamped>
										<!--Flag indicating whether or not the values of the coordinates should be constrained to the current (e.g. default) value, above.-->
										<locked>false</locked>
										<!--If specified, the coordinate can be prescribed by a function of time. It can be any OpenSim Function with valid second order derivatives.-->
										<prescribed_function />
									</Coordinate>
								</objects>
								<groups />
							</CoordinateSet>
							<reverse>false</reverse>
Part of the arm26.osim is as follows.

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: How to modify the CoordinateSet

Post by jimmy d » Mon Jul 24, 2017 8:03 pm

Please go through the Building a Dynamic Walker Example; http://simtk-confluence.stanford.edu:80 ... lker+Model

The download has an example .cpp with code that will be useful.

POST REPLY