浏览代码

updated dynamic platforms

/hh-develop-ragdoll-testing
HH 5 年前
当前提交
6df39dfd
共有 7 个文件被更改,包括 3071 次插入4 次删除
  1. 51
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgentDynamic.cs
  2. 1001
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/DynamicPlatformWalker.prefab
  3. 7
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/DynamicPlatformWalker.prefab.meta
  4. 1001
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerRagdollScale1Dynamic.prefab
  5. 7
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerRagdollScale1Dynamic.prefab.meta
  6. 1001
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamic.unity
  7. 7
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamic.unity.meta

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


[Header("Target To Walk Towards")]
[Space(10)]
public Transform target;
public Transform ground;
public bool detectTargets;
public bool targetIsStatic;
public bool respawnTargetWhenTouched;
public float targetSpawnRadius;
public Vector3 walkDirWorldspace = Vector3.right;
// public Vector3 walkDirWorldspace = Vector3.right;
//ORIENTATION

{
//FACING DIR
m_WalkDir = target.position - m_OrientationCube.transform.position;
m_WalkDir.y = 0;
// m_WalkDir = walkDirWorldspace;
m_WalkDirLookRot = Quaternion.LookRotation(m_WalkDir);

oCubePos.y = -.45f;
// oCubePos.y = -.45f;
m_OrientationCube.transform.position = oCubePos;
m_OrientationCube.transform.rotation = m_WalkDirLookRot;

void FixedUpdate()
{
if (detectTargets)
{
foreach (var bodyPart in m_JdController.bodyPartsDict.Values)
{
if (bodyPart.targetContact && bodyPart.targetContact.touchingTarget)
{
TouchedTarget();
}
}
}
UpdateOrientationCube();
//reward looking at
// float facingReward = + 0.01f * Quaternion.Dot(m_OrientationCube.transform.rotation, hips.rotation)

// +0.02f * Vector3.Dot(m_WalkDir.normalized, m_JdController.bodyPartsDict[hips].rb.velocity)
// + 0.02f * Vector3.Dot(m_OrientationCube.transform.forward,Vector3.ClampMagnitude(m_JdController.bodyPartsDict[hips].rb.velocity,5))
+0.01f * Vector3.Dot(m_OrientationCube.transform.forward,
Vector3.ClampMagnitude(m_JdController.bodyPartsDict[hips].rb.velocity, 3))
Vector3.ClampMagnitude(m_JdController.bodyPartsDict[hips].rb.velocity, 5))
+ 0.01f * Vector3.Dot(m_OrientationCube.transform.forward, hips.forward)
+ 0.01f * Vector3.Dot(m_OrientationCube.transform.forward, hips.forward)

}
/// <summary>
/// Agent touched the target
/// </summary>
public void TouchedTarget()
{
AddReward(1f);
if (respawnTargetWhenTouched)
{
GetRandomTargetPos();
}
}
/// <summary>
/// Moves target to a random position within specified radius.
/// </summary>
public void GetRandomTargetPos()
{
var newTargetPos = Random.insideUnitSphere * targetSpawnRadius;
newTargetPos.y = 5;
target.position = newTargetPos + ground.position;
}
/// <summary>
/// Loop over body parts and reset them to initial conditions.
/// </summary>
public override void OnEpisodeBegin()

// transform.Rotate(Vector3.up, Random.Range(0.0f, 360.0f));
if (detectTargets && !targetIsStatic)
{
GetRandomTargetPos();
}
SetResetParameters();
}

1001
Project/Assets/ML-Agents/Examples/Walker/Prefabs/DynamicPlatformWalker.prefab
文件差异内容过多而无法显示
查看文件

7
Project/Assets/ML-Agents/Examples/Walker/Prefabs/DynamicPlatformWalker.prefab.meta


fileFormatVersion: 2
guid: f51e8260728fd4c8fa87bcda9d0e2027
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerRagdollScale1Dynamic.prefab
文件差异内容过多而无法显示
查看文件

7
Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerRagdollScale1Dynamic.prefab.meta


fileFormatVersion: 2
guid: 001d1b295f8df4798b00a691b6882732
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamic.unity
文件差异内容过多而无法显示
查看文件

7
Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamic.unity.meta


fileFormatVersion: 2
guid: 79d5d2687bfbe45f5b78bd6c04992e0d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存