欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

荐 [OpenSim]CMC Tool文件设置

程序员文章站 2022-06-16 20:03:05
[OpenSim]CMC Tool文件设置关于本博客内容,为作者仿真模拟过程中的经验积累示例文件:Arm26模型文件所需要的文件路径:arm26_Setup_ComputedMuscleControl.xml< pathOpenSim-Model >\Arm26\OutputReference\ComputedMuscleControl其中< pathOpenSim-Model >为模型Model文件的保存路径1.必要的设置...

[OpenSim]CMC Tool文件设置

关于本博客内容,为作者仿真模拟过程中的经验积累

示例文件:Arm26模型文件
所需要的文件路径:arm26_Setup_ComputedMuscleControl.xml
< pathOpenSim-Model >\Arm26\OutputReference\ComputedMuscleControl
其中< pathOpenSim-Model >为模型Model文件的保存路径

1.必要的设置

       在另一份博文(点击这里)里已经提到了subject01_Setup_CMC.xml文件。因此我希望通过OpenSim自带案例,学习CMCTool的文件设置。如图
    荐
                                                        [OpenSim]CMC Tool文件设置  荐
                                                        [OpenSim]CMC Tool文件设置
你不要理会Desired Kinematics栏里的这个红色的背景标记。从上面两个图我们可以知道,Actuator constraints一栏可以不增加选择,而积分器设置也几乎不用修改。那么我们知道,必要的输入文件为:
1)期望的模型运动 - .mot 格式文件
2)Tracking tasks - ComputedMuscleControl_Task.xml 文件
3)Additional force files - xml文件,本例为arm26_Reserve_Actuators.xml
那么Reserve_Actuators.xml文件是否必要呢?作者认为,在一定程度上是必要的,否则会出现第三部分出现的崩溃。

2.文件内容

       这里列出文件的目的是,你可以根据这些设置文件,通过“复制-粘贴”的方式生成同类型文件,并在其中修改必要的设置,或适当删减,以匹配你自己的模型。

Desired Kinematics.mot文件

Coordinates
version=1
nRows=121
nColumns=3
inDegrees=yes

Units are S.I. units (second, meters, Newtons, ...)
Angles are in degrees.

endheader
time	r_shoulder_elev	r_elbow_flex
      0.00000000	     -0.03394423	     -0.05440752
      0.00833333	     -0.03657365	      0.01417949
      0.01666667	     -0.03908443	      0.08815700
      0.02500000	     -0.04126018	      0.17357577
      0.03333333	     -0.04302262	      0.27576038
      0.04166667	     -0.04431782	      0.39945264
      0.05000000	     -0.04510954	      0.54869991
      0.05833333	     -0.04537808	      0.72677247
      0.06666667	     -0.04512001	      0.93612489
      0.07500000	     -0.04434823	      1.17840384
      0.08333333	     -0.04309148	      1.45449954
      0.09166667	     -0.04139335	      1.76463436
      0.10000000	     -0.03931062	      2.10847927
      0.10833333	     -0.03691091	      2.48528740
      0.11666667	     -0.03427009	      2.89403350
      0.12500000	     -0.03146918	      3.33354847
      0.13333333	     -0.02859119	      3.80263942
      ////////////没有列完//////////

ComputedMuscleControl_Task.xml 文件

<?xml version="1.0" encoding="UTF-8" ?>
<OpenSimDocument Version="30000">
	<CMC_TaskSet name="arm26">
		<objects>
			<CMC_Joint name="r_shoulder_elev">
				<!--Flag (true or false) indicating whether or not a task is enabled.-->
				<on>true</on>
				<!--Weight with which a task is tracked relative to other tasks. To track a task more tightly, make the weight larger.-->
				<weight> 1</weight>
				<!--Array of 3 flags (each true or false) specifying whether a component of a task is active.  For example, tracking the trajectory of a point in space could have three components (x,y,z).  This allows each of those to be made active (true) or inactive (false).  A task for tracking a joint coordinate only has one component.-->
				<active> true false false</active>
				<!--Position error feedback gain (stiffness). To achieve critical damping of errors, choose kv = 2*sqrt(kp).-->
				<kp> 100</kp>
				<!--Velocity error feedback gain (damping). To achieve critical damping of errors, choose kv = 2*sqrt(kp).-->
				<kv> 20</kv>
				<!--Feedforward acceleration gain.  This is normally set to 1.0, so no gain.-->
				<ka> 1</ka>
				<!--Name of the coordinate to be tracked.-->
				<coordinate>r_shoulder_elev</coordinate>
				<!--Error limit on the tracking accuracy for this coordinate. If the tracking errors approach this limit, the weighting for this coordinate is increased. -->
				<limit>0</limit>
			</CMC_Joint>
			<CMC_Joint name="r_elbow_flex">
				<!--Flag (true or false) indicating whether or not a task is enabled.-->
				<on>true</on>
				<!--Weight with which a task is tracked relative to other tasks. To track a task more tightly, make the weight larger.-->
				<weight> 1</weight>
				<!--Array of 3 flags (each true or false) specifying whether a component of a task is active.  For example, tracking the trajectory of a point in space could have three components (x,y,z).  This allows each of those to be made active (true) or inactive (false).  A task for tracking a joint coordinate only has one component.-->
				<active> true false false</active>
				<!--Position error feedback gain (stiffness). To achieve critical damping of errors, choose kv = 2*sqrt(kp).-->
				<kp> 100</kp>
				<!--Velocity error feedback gain (damping). To achieve critical damping of errors, choose kv = 2*sqrt(kp).-->
				<kv> 20</kv>
				<!--Feedforward acceleration gain.  This is normally set to 1.0, so no gain.-->
				<ka> 1</ka>
				<!--Name of the coordinate to be tracked.-->
				<coordinate>r_elbow_flex</coordinate>
				<!--Error limit on the tracking accuracy for this coordinate. If the tracking errors approach this limit, the weighting for this coordinate is increased. -->
				<limit>0</limit>
			</CMC_Joint>
		</objects>
		<groups />
	</CMC_TaskSet>
</OpenSimDocument>

arm26_Reserve_Actuators.xml文件

<?xml version="1.0" encoding="UTF-8" ?>
<OpenSimDocument Version="30000">
	<ForceSet name="arm26">
		<objects>
			<CoordinateActuator name="r_shoulder_elev_reserve">
				<!--Flag indicating whether the force is disabled or not. Disabled means that the force is not active in subsequent dynamics realizations.-->
				<isDisabled>false</isDisabled>
				<!--Minimum allowed value for control signal. Used primarily when solving for control values.-->
				<min_control>-Inf</min_control>
				<!--Maximum allowed value for control signal. Used primarily when solving for control values.-->
				<max_control>Inf</max_control>
				<!--Name of the generalized coordinate to which the actuator applies.-->
				<coordinate>r_shoulder_elev</coordinate>
				<!--The maximum generalized force produced by this actuator.-->
				<optimal_force>1</optimal_force>
			</CoordinateActuator>
			<CoordinateActuator name="r_elbow_flex_reserve">
				<!--Flag indicating whether the force is disabled or not. Disabled means that the force is not active in subsequent dynamics realizations.-->
				<isDisabled>false</isDisabled>
				<!--Minimum allowed value for control signal. Used primarily when solving for control values.-->
				<min_control>-Inf</min_control>
				<!--Maximum allowed value for control signal. Used primarily when solving for control values.-->
				<max_control>Inf</max_control>
				<!--Name of the generalized coordinate to which the actuator applies.-->
				<coordinate>r_elbow_flex</coordinate>
				<!--The maximum generalized force produced by this actuator.-->
				<optimal_force>1</optimal_force>
			</CoordinateActuator>
		</objects>
		<groups />
	</ForceSet>
</OpenSimDocument>
3.可能的崩溃

1)在第二部分的ComputedMuscleControl_Task.xml 文件当中,

<limit>0</limit>

可能会使得程序崩溃;此外,在该设置文件当中,若跟踪的CMC_Joint的名称,如

<CMC_Joint name="r_shoulder_elev">

与你的模型内该关节的名称不符,也会发生崩溃。
2)如第一部分所述,若arm26_Reserve_Actuators.xml文件不包含,大概率会导致OpenSim崩溃退出。对于该文件的功能,作者还不清楚。

本文地址:https://blog.csdn.net/qq_44207723/article/details/107288588