浏览代码

add random rot on episode start

/hh-develop-ragdoll-testing
HH 4 年前
当前提交
ab4e288a
共有 1 个文件被更改,包括 15 次插入7 次删除
  1. 22
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgentDynamic.cs

22
Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgentDynamic.cs


[Space(10)]
public Transform target;
[Header("Walk Direction Worldspace")]
public Vector3 walkDirWorldspace = Vector3.right;
//ORIENTATION
Vector3 m_WalkDir;

// m_WalkDir = target.position - hips.position;
// m_WalkDir = target.position - m_OrientationCube.transform.position;
//FACING DIR
// m_WalkDirLookRot = Quaternion.LookRotation(m_WalkDir);
sensor.AddObservation(RagdollHelpers.GetRotationDelta(m_WalkDirLookRot, hips.rotation));
sensor.AddObservation(RagdollHelpers.GetRotationDelta(m_WalkDirLookRot, head.rotation));
// m_TargetDirMatrix = Matrix4x4.TRS(Vector3.zero, m_LookRotation, Vector3.one);

void FixedUpdate()
{
//FACING DIR
// m_WalkDir = target.position - m_OrientationCube.transform.position;
m_WalkDir = walkDirWorldspace;
m_WalkDirLookRot = Quaternion.LookRotation(m_WalkDir);
//UPDATE ORIENTATION CUBE POS & ROT

// b. Rotation alignment with goal direction.
// c. Encourage head height.
// d. Discourage head movement.
m_WalkDir = target.position - m_OrientationCube.transform.position;
AddReward(
+0.02f * Vector3.Dot(m_WalkDir.normalized, m_JdController.bodyPartsDict[hips].rb.velocity)
+ 0.01f * Quaternion.Dot(m_OrientationCube.transform.rotation, hips.rotation)

{
bodyPart.Reset(bodyPart);
}
if (m_WalkDir != Vector3.zero)
{
transform.rotation = Quaternion.LookRotation(m_WalkDir);
}
// if (m_WalkDir != Vector3.zero)
// {
// transform.rotation = Quaternion.LookRotation(m_WalkDir);
// }
transform.rotation = Quaternion.Euler(0, Random.Range(0.0f, 360.0f), 0);
// transform.Rotate(Vector3.up, Random.Range(0.0f, 360.0f));
SetResetParameters();
}

正在加载...
取消
保存