setInFrame for JointReaction

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Hide Kimpara
Posts: 135
Joined: Mon Sep 19, 2016 5:12 am

setInFrame for JointReaction

Post by Hide Kimpara » Thu May 03, 2018 4:49 pm

Hello,

I tried to use JointReaction with 4.0 from C++.

I wrote a simple code as following:

Code: Select all

Model osimModel("PendulumJoint_type5b.osim");

SimTK::State& si = osimModel.initSystem();
		
JointReaction *aJointReaction = new JointReaction();
aJointReaction->setName("J_Reac_Force");

Array<std::string> jFrame("parent", 1);
aJointReaction->setInFrame(jFrame);

Array<std::string> jOnBody("parent",1);
aJointReaction->setOnBody(jOnBody);

osimModel.addAnalysis(aJointReaction);

osimModel.initSystem();
	        
SimTK::RungeKuttaMersonIntegrator
integrator( osimModel.getMultibodySystem() );
integrator.setMinimumStepSize(5e-7);


Manager manager(osimModel, integrator);
si.setTime(initialTime);
manager.initialize(si);

manager.integrate(finalTime);	        
However, I got an error message at the initSystem.

Code: Select all

Component 'PendulumJoint_type5b' could not find 'parent' of type Frame. Make sure a component exists at this path and that it is of the correct type.
        Thrown at Component.h:739 in getComponent().
What part is missing on this example?

Best regards,
Hide

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

Re: setInFrame for JointReaction

Post by Thomas Uchida » Thu May 03, 2018 10:44 pm

You haven't attached your model so I can't confirm, but it looks like there's no Frame named "parent". In 4.0, the express_in_frame property of the JointReaction analysis requires the names (or paths) of Frames. Please see the following for details:
- PR #1449: https://github.com/opensim-org/opensim-core/pull/1449
- Line 295 in this setup file (used by testJointReactions.cpp): https://github.com/opensim-org/opensim- ... n.xml#L295

User avatar
Hide Kimpara
Posts: 135
Joined: Mon Sep 19, 2016 5:12 am

Re: setInFrame for JointReaction

Post by Hide Kimpara » Fri May 04, 2018 7:33 am

Hello Tom,

Thank you for your suggestion! I appreciate your helps every time!
Once I tried based on previous conversation viewtopicPhpbb.php?f=91&t=5135. But I realized the definitions have been changed from 3.3 to 4.0.

The model was a pendulum model modified from tug_of_war sample, "PendulumJoint_type5b.osim":

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<OpenSimDocument Version="30000">
	<Model name="PendulumJoint_type5b">
		<credits>This TugOfWar model was modified by Brian Umberger to have a single DOF slider joint, rather than a 6 DOF free joint with 5 constraints. It was modifed from the TugOfWar model that is provided with OpenSim that is due to Frank Anderson, Peter Loan, Ayman Habib, Ajay Seth and Michael Sherman</credits>
		<publications>Unassigned</publications>
		<length_units>meters</length_units>
		<force_units>N</force_units>
		<!--Acceleration due to gravity.-->
		<gravity> 0 -9.8 0</gravity>
		<!--Bodies in the model.-->
		<BodySet>
			<objects>
				<Body name="ground">
					<mass>0</mass>
					<mass_center> 0 0 0</mass_center>
					<inertia_xx>1</inertia_xx>
					<inertia_yy>1</inertia_yy>
					<inertia_zz>1</inertia_zz>
					<inertia_xy>0</inertia_xy>
					<inertia_xz>0</inertia_xz>
					<inertia_yz>0</inertia_yz>
					<!--Joint that connects this body with the parent body.-->
					<Joint />
					<VisibleObject>
						<!--Set of geometry files and associated attributes, allow .vtp, .stl, .obj-->
						<GeometrySet>
							<objects>
								<DisplayGeometry>
									<!--Name of geometry file .vtp, .stl, .obj-->
									<geometry_file>ground.vtp</geometry_file>
									<!--Color used to display the geometry when visible-->
									<color> .1 .1 .1</color>
									<!--Name of texture file .jpg, .bmp-->
									<texture_file />
									<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
									<transform> 0 0 0 0 0 0</transform>
									<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
									<scale_factors> 1 1 1</scale_factors>
									<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
									<display_preference>4</display_preference>
									<!--Display opacity between 0.0 and 1.0-->
									<opacity>1</opacity>
								</DisplayGeometry>
								<DisplayGeometry>
									<!--Name of geometry file .vtp, .stl, .obj-->
									<geometry_file>plane.vtp</geometry_file>
									<!--Color used to display the geometry when visible-->
									<color> .5 .5 .5</color>
									<!--Name of texture file .jpg, .bmp-->
									<texture_file />
									<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
									<transform> 1.5707963267949 0 0 0 0 0</transform>
									<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
									<scale_factors> 1 .01 .01</scale_factors>
									<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
									<display_preference>4</display_preference>
									<!--Display opacity between 0.0 and 1.0-->
									<opacity>0.5</opacity>
								</DisplayGeometry>
							</objects>
							<groups />
						</GeometrySet>
						<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
						<scale_factors> 1 1 1</scale_factors>
						<!--transform relative to owner specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
						<transform> -0 0 -0 0 0 0</transform>
						<!--Whether to show a coordinate frame-->
						<show_axes>false</show_axes>
						<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded Can be overriden for individual geometries-->
						<display_preference>4</display_preference>
					</VisibleObject>
					<WrapObjectSet>
						<objects />
						<groups />
					</WrapObjectSet>
				</Body>
				<Body name="Base">
					<mass>100</mass>
					<mass_center> 0 0 0</mass_center>
					<inertia_xx>10</inertia_xx>
					<inertia_yy>10</inertia_yy>
					<inertia_zz>10</inertia_zz>
					<inertia_xy>0</inertia_xy>
					<inertia_xz>0</inertia_xz>
					<inertia_yz>0</inertia_yz>
					<!--Joint that connects this body with the parent body.-->
					<Joint>
						<PinJoint name="Base_Joint">
							<!--Name of the parent body to which this joint connects its owner body.-->
							<parent_body>ground</parent_body>
							<!--Location of the joint in the parent body specified in the parent reference frame. Default is (0,0,0).-->
							<location_in_parent>0 0 0</location_in_parent>
							<!--Orientation of the joint in the parent body specified in the parent reference frame. Euler XYZ body-fixed rotation angles are used to express the orientation. Default is (0,0,0).-->
							<orientation_in_parent>3.141592 1.5707963267949 0</orientation_in_parent>
							<!--Location of the joint in the child body specified in the child reference frame. For SIMM models, this vector is always the zero vector (i.e., the body reference frame coincides with the joint). -->
							<location>0 0 0</location>
							<!--Orientation of the joint in the owing body specified in the owning body reference frame.  Euler XYZ body-fixed rotation angles are used to express the orientation. -->
							<orientation>0 1.5707963267949 0</orientation>
							<!--Set holding the generalized coordinates (q's) that parmeterize this joint.-->
							<CoordinateSet>
								<objects>
									<Coordinate name="base_flex">
										<!--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.15</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>-2.0943951 2.0943951</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>true</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 />
										<!--Flag indicating whether or not the values of the coordinates should be prescribed according to the function above. It is ignored if the no prescribed function is specified.-->
										<prescribed>false</prescribed>
									</Coordinate>
								</objects>
								<groups />
							</CoordinateSet>
							<!--Whether the joint transform defines parent->child or child->parent.-->
							<reverse>false</reverse>
						</PinJoint>
					</Joint>
					<VisibleObject>
						<!--Set of geometry files and associated attributes, allow .vtp, .stl, .obj-->
						<GeometrySet>
							<objects>
								<DisplayGeometry>
									<!--Name of geometry file .vtp, .stl, .obj-->
									<geometry_file>anchor1.vtp</geometry_file>
									<!--Color used to display the geometry when visible-->
									<color> 1 1 1</color>
									<!--Name of texture file .jpg, .bmp-->
									<texture_file />
									<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
									<transform> -0 0 -0 0 0 0</transform>
									<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
									<scale_factors> 1 1 1</scale_factors>
									<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
									<display_preference>4</display_preference>
									<!--Display opacity between 0.0 and 1.0-->
									<opacity>1</opacity>
								</DisplayGeometry>
								<DisplayGeometry>
									<!--Name of geometry file .vtp, .stl, .obj-->
									<geometry_file>anchor2.vtp</geometry_file>
									<!--Color used to display the geometry when visible-->
									<color> 1 1 1</color>
									<!--Name of texture file .jpg, .bmp-->
									<texture_file />
									<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
									<transform> -0 0 -0 0 0 0</transform>
									<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
									<scale_factors> 1 1 1</scale_factors>
									<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
									<display_preference>4</display_preference>
									<!--Display opacity between 0.0 and 1.0-->
									<opacity>1</opacity>
								</DisplayGeometry>
							</objects>
							<groups />
						</GeometrySet>
						<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
						<scale_factors> 1 1 1</scale_factors>
						<!--transform relative to owner specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
						<transform> -0 0 -0 0 0 0</transform>
						<!--Whether to show a coordinate frame-->
						<show_axes>false</show_axes>
						<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded Can be overriden for individual geometries-->
						<display_preference>4</display_preference>
					</VisibleObject>
					<WrapObjectSet>
						<objects />
						<groups />
					</WrapObjectSet>
				</Body>
				<Body name="Block">
					<mass>10</mass>
					<mass_center> 0 0 0</mass_center>
					<inertia_xx>10</inertia_xx>
					<inertia_yy>1</inertia_yy>
					<inertia_zz>10</inertia_zz>
					<inertia_xy>0</inertia_xy>
					<inertia_xz>0</inertia_xz>
					<inertia_yz>0</inertia_yz>
					<!--Joint that connects this body with the parent body.-->
					<Joint>
						<PinJoint name="Pin_Joint">
							<!--Name of the parent body to which this joint connects its owner body.-->
							<parent_body>Base</parent_body>
							<!--Location of the joint in the parent body specified in the parent reference frame. Default is (0,0,0).-->
							<location_in_parent>0 0.05 0</location_in_parent>
							<!--Orientation of the joint in the parent body specified in the parent reference frame. Euler XYZ body-fixed rotation angles are used to express the orientation. Default is (0,0,0).-->
							<orientation_in_parent>0 1.5707963267949 0</orientation_in_parent>
							<!--Location of the joint in the child body specified in the child reference frame. For SIMM models, this vector is always the zero vector (i.e., the body reference frame coincides with the joint). -->
							<location>0 0.5 0</location>
							<!--Orientation of the joint in the owing body specified in the owning body reference frame.  Euler XYZ body-fixed rotation angles are used to express the orientation. -->
							<orientation>0 0 0</orientation>
							<!--Set holding the generalized coordinates (q's) that parmeterize this joint.-->
							<CoordinateSet>
								<objects>
									<Coordinate name="pin_flex">
										<!--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.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>-2.0943951 2.0943951</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 />
										<!--Flag indicating whether or not the values of the coordinates should be prescribed according to the function above. It is ignored if the no prescribed function is specified.-->
										<prescribed>false</prescribed>
									</Coordinate>
								</objects>
								<groups />
							</CoordinateSet>
							<!--Whether the joint transform defines parent->child or child->parent.-->
							<reverse>false</reverse>
						</PinJoint>
					</Joint>
					<VisibleObject>
						<!--Set of geometry files and associated attributes, allow .vtp, .stl, .obj-->
						<GeometrySet>
							<objects>
								<DisplayGeometry>
									<!--Name of geometry file .vtp, .stl, .obj-->
									<geometry_file>block.vtp</geometry_file>
									<!--Color used to display the geometry when visible-->
									<color> 0.5 0.5 1</color>
									<!--Name of texture file .jpg, .bmp-->
									<texture_file />
									<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
									<transform> -0 0 -0 0 0 0</transform>
									<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
									<scale_factors> 1 1 1</scale_factors>
									<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
									<display_preference>4</display_preference>
									<!--Display opacity between 0.0 and 1.0-->
									<opacity>1</opacity>
								</DisplayGeometry>
							</objects>
							<groups />
						</GeometrySet>
						<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
						<scale_factors> 1 10 1</scale_factors>
						<!--transform relative to owner specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
						<transform> -0 0 -0 0 0 0</transform>
						<!--Whether to show a coordinate frame-->
						<show_axes>false</show_axes>
						<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded Can be overriden for individual geometries-->
						<display_preference>4</display_preference>
					</VisibleObject>
					<WrapObjectSet>
						<objects />
						<groups />
					</WrapObjectSet>
				</Body>
			</objects>
			<groups />
		</BodySet>
		<!--Constraints in the model.-->
		<ConstraintSet>
			<objects />
			<groups />
		</ConstraintSet>
		<!--Forces in the model.-->
		<ForceSet>
			<objects>
				<Thelen2003Muscle name="muscle1">
					<!--Minimum allowed value for control signal. Used primarily when solving for control values.-->
					<min_control>0</min_control>
					<!--Maximum allowed value for control signal. Used primarily when solving for control values.-->
					<max_control>1</max_control>
					<!--The set of points defining the path of the muscle.-->
					<GeometryPath>
						<!--The set of points defining the path-->
						<PathPointSet>
							<objects>
								<PathPoint name="muscle1-point1">
									<location> 0 0.05 -0.35</location>
									<body>Base</body>
								</PathPoint>
								<PathPoint name="muscle1-point2">
									<location> 0.05 0 0</location>
									<body>Block</body>
								</PathPoint>
							</objects>
							<groups />
						</PathPointSet>
						<!--Used to display the path in the 3D window-->
						<VisibleObject name="display">
							<!--Set of geometry files and associated attributes, allow .vtp, .stl, .obj-->
							<GeometrySet>
								<objects />
								<groups />
							</GeometrySet>
							<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
							<scale_factors> 1 1 1</scale_factors>
							<!--transform relative to owner specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
							<transform> -0 0 -0 0 0 0</transform>
							<!--Whether to show a coordinate frame-->
							<show_axes>false</show_axes>
							<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded Can be overriden for individual geometries-->
							<display_preference>4</display_preference>
						</VisibleObject>
					</GeometryPath>
					<!--Maximum isometric force that the fibers can generate-->
					<max_isometric_force>1000</max_isometric_force>
					<!--Optimal length of the muscle fibers-->
					<optimal_fiber_length>0.52</optimal_fiber_length>
					<!--Resting length of the tendon-->
					<tendon_slack_length>0.05</tendon_slack_length>
					<!--Angle between tendon and fibers at optimal fiber length expressed in radians-->
					<pennation_angle_at_optimal>0</pennation_angle_at_optimal>
					<!--time constant for ramping up muscle activation-->
					<activation_time_constant>0.055</activation_time_constant>
					<!--time constant for ramping down of muscle activation-->
					<deactivation_time_constant>0.065</deactivation_time_constant>
				</Thelen2003Muscle>
				<Thelen2003Muscle name="muscle2">
					<!--Minimum allowed value for control signal. Used primarily when solving for control values.-->
					<min_control>0</min_control>
					<!--Maximum allowed value for control signal. Used primarily when solving for control values.-->
					<max_control>1</max_control>
					<!--The set of points defining the path of the muscle.-->
					<GeometryPath>
						<!--The set of points defining the path-->
						<PathPointSet>
							<objects>
								<PathPoint name="muscle2-point1">
									<location> 0 0.05 0.35</location>
									<body>Base</body>
								</PathPoint>
								<PathPoint name="muscle2-point2">
									<location> -0.05 0 0</location>
									<body>Block</body>
								</PathPoint>
							</objects>
							<groups />
						</PathPointSet>
						<!--Used to display the path in the 3D window-->
						<VisibleObject name="display">
							<!--Set of geometry files and associated attributes, allow .vtp, .stl, .obj-->
							<GeometrySet>
								<objects />
								<groups />
							</GeometrySet>
							<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
							<scale_factors> 1 1 1</scale_factors>
							<!--transform relative to owner specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
							<transform> -0 0 -0 0 0 0</transform>
							<!--Whether to show a coordinate frame-->
							<show_axes>false</show_axes>
							<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded Can be overriden for individual geometries-->
							<display_preference>4</display_preference>
						</VisibleObject>
					</GeometryPath>
					<!--Maximum isometric force that the fibers can generate-->
					<max_isometric_force>1000</max_isometric_force>
					<!--Optimal length of the muscle fibers-->
					<optimal_fiber_length>0.52</optimal_fiber_length>
					<!--Resting length of the tendon-->
					<tendon_slack_length>0.05</tendon_slack_length>
					<!--Angle between tendon and fibers at optimal fiber length expressed in radians-->
					<pennation_angle_at_optimal>0</pennation_angle_at_optimal>
					<!--time constant for ramping up muscle activation-->
					<activation_time_constant>0.055</activation_time_constant>
					<!--time constant for ramping down of muscle activation-->
					<deactivation_time_constant>0.065</deactivation_time_constant>
				</Thelen2003Muscle>
				<BushingForce name="Pin_Joint_bushing">
					<!--Flag indicating whether the force is disabled or not. Disabled means that the force is not active in subsequent dynamics realizations.-->
					<isDisabled>false</isDisabled>
					<!--One of the two bodies connected by the bushing.-->
					<body_1>Base</body_1>
					<!--The other of the two bodies connected by the bushing.-->
					<body_2>Block</body_2>
					<!--Location of bushing frame on body 1.-->
					<location_body_1>0 0.5 0</location_body_1>
					<!--Orientation of bushing frame in body 1 as x-y-z, body fixed Euler rotations.-->
					<orientation_body_1>0 1.5707963267949 0</orientation_body_1>
					<!--Location of bushing frame on body 2.-->
					<location_body_2>0 0.5 0</location_body_2>
					<!--Orientation of bushing frame in body 2 as x-y-z, body fixed Euler rotations.-->
					<orientation_body_2>0 0 0</orientation_body_2>
					<!--Stiffness parameters resisting relative rotation (Nm/rad).-->
					<rotational_stiffness>0 0 0</rotational_stiffness>
					<!--Stiffness parameters resisting relative translation (N/m).-->
					<translational_stiffness>0 0 0</translational_stiffness>
					<!--Damping parameters resisting relative angular velocity. (Nm/(rad/s))-->
					<rotational_damping>0.01 0.01 0.01</rotational_damping>
					<!--Damping parameters resisting relative translational velocity. (N/(m/s)-->
					<translational_damping>10 10 10</translational_damping>
				</BushingForce>
				<CoordinateLimitForce name="Pin_Joint_Limit_Force">
					<!--Coordinate (name) to be limited.-->
					<coordinate>pin_flex</coordinate>
					<!--Stiffness of the passive limit force when coordinate exceeds upper limit. Note, rotational stiffness expected in N*m/degree.-->
					<upper_stiffness>200</upper_stiffness>
					<!--The upper limit of the coordinate range of motion (rotations in degrees).-->
					<upper_limit>20</upper_limit>
					<!--Stiffness of the passive limit force when coordinate exceeds lower limit. Note, rotational stiffness expected in N*m/degree.-->
					<lower_stiffness>200</lower_stiffness>
					<!--The lower limit of the coordinate range of motion (rotations in degrees).-->
					<lower_limit>-20</lower_limit>
					<!--Damping factor on the coordinate's speed applied only when limit is exceeded. For translational has units N/(m/s) and rotational has Nm/(degree/s)-->
					<damping>0.025</damping>
					<!--Transition region width in the units of the coordinate (rotations in degrees). Dictates the transition from zero to constant stiffness as coordinate exceeds its limit.-->
					<transition>1</transition>
					<!--Option to compute the dissipation energy due to damping in the CoordinateLimitForce. If true the dissipation power is automatically integrated to provide energy. Default is false.-->
					<compute_dissipation_energy>false</compute_dissipation_energy>
				</CoordinateLimitForce>
			</objects>
			<groups />
		</ForceSet>
		<!--Markers in the model.-->
		<MarkerSet>
			<objects />
			<groups />
		</MarkerSet>
		<!--ContactGeometries  in the model.-->
		<ContactGeometrySet>
			<objects />
			<groups />
		</ContactGeometrySet>
		<!--Controllers in the model.-->
		<ControllerSet name="Controllers">
			<objects>
				<PrescribedController name="PiecewiseLinear Controller">
					<!--The list of model actuators that this controller will control.The keyword ALL indicates the controller will controll all the acuators in the model-->
					<actuator_list>muscle1 muscle2</actuator_list>
					<!--Functions (one per control) describing the controls for actuatorsspecified for this controller.-->
					<FunctionSet name="ControlFunctions">
						<objects>
							<PiecewiseLinearFunction>
								<x> 0 0.15 0.16 1.35 1.45 1.7 2.0</x>
								<y> 0.0 0.0 .21 .01 .05 .05 .01</y>
							</PiecewiseLinearFunction>
							<PiecewiseLinearFunction>
								<x> 0 1.05 1.06 1.5 1.8 1.9</x>
								<y> 0.0 0.0 .12 .21 .31 0.2</y>
							</PiecewiseLinearFunction>
						</objects>
						<groups />
					</FunctionSet>
				</PrescribedController>
			</objects>
			<groups />
		</ControllerSet>
		<!--Additional components in the model.-->
		<ComponentSet name="MiscComponents">
			<objects />
			<groups />
		</ComponentSet>
		<!--Probes in the model.-->
		<ProbeSet>
			<objects />
			<groups />
		</ProbeSet>
	</Model>
</OpenSimDocument>
When I used following C++ script, I got a correct output now.

Code: Select all

		JointReaction *aJointReaction = new JointReaction();
		aJointReaction->setName("J_Reac_Force");

		Array<std::string> jNames;
		jNames.set(0, "Pin_Joint");

		aJointReaction->setJointNames(jNames);
		std::cout << "Joint Names:" << aJointReaction->getJointNames() << std::endl;

		Array<std::string> jFrame;
		jFrame.set(0, "Base");

		aJointReaction->setInFrame(jFrame);
		std::cout << "Joint Frame:" << aJointReaction->getInFrame() << std::endl;

		Array<std::string> jOnBody;
		jOnBody.set(0, "child");

		aJointReaction->setOnBody(jOnBody);
		std::cout << "Joint OnBody:" << aJointReaction->getOnBody() << std::endl;

		osimModel.addAnalysis(aJointReaction);

		osimModel.initSystem();
Then, I have two questions.
1) I found "pin1/rod1_offset" in "testJointReactions.cpp". I am not familiar with "_offset" frame. But I realize that 4.0 OpenSim can print new format osim file and sometimes there are *_offset under <JointSet> definitions. What is the _offset meaning? How is it different from simple "rod1"?
2) When I tried to get the frame names as following:

Code: Select all

osimModel.getJointSet().get(i).getParentFrame().getName()
Then I got frame names of "ground_offset" or "base_offset". But these names are not accepted OpenSim solver. What is the better ways to assign parent frame programatically?

Thank you and Best,
Hide

User avatar
Hide Kimpara
Posts: 135
Joined: Mon Sep 19, 2016 5:12 am

Re: setInFrame for JointReaction

Post by Hide Kimpara » Fri May 04, 2018 8:07 am

Hello Tom,

I got parent frame name as this:

Code: Select all

osimModel.getJointSet().get(i).getParentFrame().findBaseFrame().getName()
But I don't know why the outputs are different between "Base" and "Pin_Joint/Base_offset" setInFrames.

Thank you,
Hide

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

Re: setInFrame for JointReaction

Post by Thomas Uchida » Fri May 04, 2018 7:13 pm

1) I found "pin1/rod1_offset" in "testJointReactions.cpp". I am not familiar with "_offset" frame. But I realize that 4.0 OpenSim can print new format osim file and sometimes there are *_offset under <JointSet> definitions. What is the _offset meaning? How is it different from simple "rod1"?
Please see the "detailed description" section of the doxygen for PhysicalOffsetFrame: http://myosin.sourceforge.net/2166/clas ... ml#details
2) When I tried to get the frame names as following:
osimModel.getJointSet().get(i).getParentFrame().getName()
Then I got frame names of "ground_offset" or "base_offset". But these names are not accepted OpenSim solver. What is the better ways to assign parent frame programatically?
Try getAbsolutePathString(): http://myosin.sourceforge.net/2166/clas ... fb1e0b0ca7
I got parent frame name as this:
osimModel.getJointSet().get(i).getParentFrame().findBaseFrame().getName()
But I don't know why the outputs are different between "Base" and "Pin_Joint/Base_offset" setInFrames.
The description for Frame::findBaseFrame() points to the 'Advanced' note in the doxygen for Frame: http://myosin.sourceforge.net/2166/clas ... Frame.html (search for "advanced").

POST REPLY