【发布时间】:2021-02-03 11:53:01
【问题描述】:
我采用了 Crawler 项目示例并将其重新设计为个人项目。而且我有一个很大的问题是让小腿的关节工作(不是大腿的想法)。
我必须像这样应用局部变换,以便对象都在同一个方向。然后我在可配置关节中编辑了轴,只有 Z 轴被限制,其他被锁定。然后我应用了 90 度限制角度旋转。
问题是,在我对轴使用的任何约束中,当我应用一个角度时,我仍然得到相同的角度限制。 我使用模型在 -1 和 1 之间预测角度的输出,该输出映射到函数中以给出 0 或 180 度。
public void SetJointTargetRotation(float x, float y, float z)
{
x = (x + 1f) * 0.5f;
y = (y + 1f) * 0.5f;
z = (z + 1f) * 0.5f;
var xRot = Mathf.Lerp(joint.lowAngularXLimit.limit, joint.highAngularXLimit.limit, x);
var yRot = Mathf.Lerp(-joint.angularYLimit.limit, joint.angularYLimit.limit, y);
var zRot = Mathf.Lerp(-joint.angularZLimit.limit, joint.angularZLimit.limit, z);
currentXNormalizedRot =
Mathf.InverseLerp(joint.lowAngularXLimit.limit, joint.highAngularXLimit.limit, xRot);
currentYNormalizedRot = Mathf.InverseLerp(-joint.angularYLimit.limit, joint.angularYLimit.limit, yRot);
currentZNormalizedRot = Mathf.InverseLerp(-joint.angularZLimit.limit, joint.angularZLimit.limit, zRot);
joint.targetRotation = Quaternion.Euler(xRot, yRot, zRot);
currentEularJointRotation = new Vector3(xRot, yRot, zRot);
}
但为了测试,我还没有使用神经网络,我对输入进行硬编码,如下所示:
bpDict[leg3Lower].SetJointTargetRotation(0, 0, 1f);
但这就是我得到的:
用红色表示腿的运动(从下到右)。 在 bleu 中,腿的原始位置。 在黑色中,它应该形成的“轴”和限制。\
即使我在轴上胡乱摆弄,当我应用 1f(在机器人内部,应该是向下)-1(平坦,应该在天空上)时,它总是会转到相同的位置。
我错过了什么吗?
【问题讨论】: