浏览代码

reimplement cube relTargetPos

/active-variablespeed
HH 4 年前
当前提交
f5d3ef52
共有 15 个文件被更改,包括 3536 次插入672 次删除
  1. 3
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollBase.prefab
  2. 20
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerStatic.unity
  3. 49
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerStaticVariableSpeed.unity
  4. 99
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
  5. 1001
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerDynamic.nn
  6. 2
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerDynamic.nn.meta
  7. 1001
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerStatic.nn
  8. 2
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerStatic.nn.meta
  9. 1001
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerStaticVariableSpeed.nn
  10. 2
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerStaticVariableSpeed.nn.meta
  11. 8
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50.meta
  12. 1001
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerDynamicVariableSpeed.nn
  13. 11
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerDynamicVariableSpeed.nn.meta
  14. 8
      Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgCoreVel50meterMax.meta
  15. 0
      /Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50

3
Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollBase.prefab


m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
VectorObservationSize: 236
VectorObservationSize: 238
NumStackedVectorObservations: 1
VectorActionSize: 27000000
VectorActionDescriptions: []

randomizeWalkSpeedEachEpisode: 1
walkDirectionMethod: 0
worldDirToWalk: {x: 1, y: 0, z: 0}
posToWalkTo: {x: 0, y: 0, z: 0}
target: {fileID: 0}
hips: {fileID: 895268871264836332}
chest: {fileID: 7933235354845945071}

20
Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerStatic.unity


type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 48d9838ba2af64512a599f6cecee6ce9,
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}

49
Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerStaticVariableSpeed.unity


type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 163fdf9da8bd8441c97f6e760543fa06,
objectReference: {fileID: 11400000, guid: 71f39bc92e5ae49edba82a2d411c0678,
type: 3}
- target: {fileID: 1077752704035527914, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}

type: 3}
propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (7)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}

propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (6)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_ConnectedAnchor.x

propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (8)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_ConnectedAnchor.x

propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (4)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_ConnectedAnchor.x

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 163fdf9da8bd8441c97f6e760543fa06,
objectReference: {fileID: 11400000, guid: 71f39bc92e5ae49edba82a2d411c0678,
type: 3}
- target: {fileID: 1077752704035527914, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}

propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (3)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_ConnectedAnchor.x

type: 3}
propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (2)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}

propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (1)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_ConnectedAnchor.x

type: 3}
propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (5)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}

type: 3}
propertyPath: m_Name
value: WalkerRagdollStVariableSpeedVariant (9)
objectReference: {fileID: 0}
- target: {fileID: 1077752704035527923, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7818481575132336858, guid: d0b01030cfe47462398dd15595ca95de,
type: 3}

99
Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs


[Header("Walk Direction")] public WalkDirectionMethod walkDirectionMethod;
public Vector3 worldDirToWalk = Vector3.right;
public Vector3 m_currentWorldDirToWalk = Vector3.right;
public Vector3 worldPosToWalkTo;
public Transform target; //Target the agent will walk towards.
[Header("Body Parts")] public Transform hips;

/// </summary>
public override void OnEpisodeBegin()
{
// if (walkTowardsType == WalkTowardsType.UseTarget && !target)
// {
// Debug.LogError("Missing a reference toTarget");

{
bodyPart.Reset(bodyPart);
}
//Random start rotation to help generalize
hips.rotation = Quaternion.Euler(0, Random.Range(0.0f, 360.0f), 0);

//Set the initial position to walk toa
if (walkDirectionMethod == WalkDirectionMethod.UseWorldDirection)
{
worldPosToWalkTo = hips.position + (worldDirToWalk * 1000);
}
rewardManager.ResetEpisodeRewards();
//Set our goal walking speed

//rotation deltas
sensor.AddObservation(Quaternion.FromToRotation(hips.forward, cubeForward));
sensor.AddObservation(Quaternion.FromToRotation(head.forward, cubeForward));
// sensor.AddObservation((int)walkDirectionMethod);
//Dist To Target. Max 50 meters. Normalized;
//If we're walking in world dir, always return 1;
float distToTarget = walkDirectionMethod == WalkDirectionMethod.UseTarget
? Mathf.Clamp((target.position - hips.position).magnitude, 0, 50)/50
: 1;
sensor.AddObservation(distToTarget);
// //Dist To Target. Max 50 meters. Normalized;
// //If we're walking in world dir, always return 1;
// float distToTarget = walkDirectionMethod == WalkDirectionMethod.UseTarget
// ? Mathf.Clamp((target.position - hips.position).magnitude, 0, 50)/50
// : 1;
// sensor.AddObservation(distToTarget);
// worldPosToWalkTo = GetUpdatedTargetPosition();
//
// Vector3 relPos = Vector3.zero;
// if (walkDirectionMethod == WalkDirectionMethod.UseTarget)
// {
// relPos = Vector3.ClampMagnitude(m_OrientationCube.transform.InverseTransformPoint(target.transform.position), 100);
// }
// sensor.AddObservation(relPos);
if (walkDirectionMethod == WalkDirectionMethod.UseTarget)
{
worldPosToWalkTo = target.transform.position;
}
// worldPosToWalkTo = walkDirectionMethod == WalkDirectionMethod.UseTarget
// ? target.transform.position
//// : hips.position + (dirToLook * 100);
//// : m_OrientationCube.transform.TransformDirection(dirToLook * 100);
// : m_OrientationCube.transform.position + (cubeForward * 100);
// targetPos.y = 0;
Vector3 relPos = Vector3.ClampMagnitude(m_OrientationCube.transform.InverseTransformPoint(worldPosToWalkTo), 100);
sensor.AddObservation(relPos);
// Debug.DrawRay(worldPosToWalkTo, Vector3.up, Color.green,1);
// Debug.DrawRay(relPos, Vector3.up, Color.green,1);
// Debug.DrawRay(m_OrientationCube.transform.InverseTransformPoint(worldPosToWalkTo), Vector3.up * 2, Color.red,5);
// worldPosToWalkTo = GetUpdatedWorldTargetPosition();
// Vector3 relPos = Vector3.ClampMagnitude(m_OrientationCube.transform.InverseTransformPoint(worldPosToWalkTo), 100);
// sensor.AddObservation(relPos);
// Debug.DrawRay(worldPosToWalkTo, Vector3.up, Color.green,1);
// Debug.DrawRay(m_OrientationCube.transform.InverseTransformPoint(worldPosToWalkTo), Vector3.up * 2, Color.red,5);
// Vector3 targetPos = walkDirectionMethod == WalkDirectionMethod.UseTarget
// ? target.transform.position
//// : hips.position + (dirToLook * 100);
//// : m_OrientationCube.transform.TransformDirection(dirToLook * 100);
// : m_OrientationCube.transform.position + (cubeForward * 100);
// targetPos.y = 0;
// Vector3 relPos = Vector3.ClampMagnitude(m_OrientationCube.transform.InverseTransformPoint(targetPos), 100);
// sensor.AddObservation(relPos);
// Debug.DrawRay(targetPos, Vector3.up, Color.green,1);
// Debug.DrawRay(m_OrientationCube.transform.InverseTransformPoint(targetPos), Vector3.up * 2, Color.red,5);
// Vector3 targetPos = walkDirectionMethod == WalkDirectionMethod.UseTarget
// ? target.transform.position

m_DirectionIndicator.MatchOrientation(m_OrientationCube.transform);
}
Vector3 GetUpdatedWorldTargetPosition()
{
if (walkDirectionMethod == WalkDirectionMethod.UseWorldDirection)
{
//Wait until we are within 10 units and then update the position
//This helps prevent direction drift
if (Vector3.Distance(worldPosToWalkTo, hips.position) < 10)
{
return hips.position + (worldDirToWalk * 100);
}
else
{
return worldPosToWalkTo;
}
}
else //use target
{
return target.position;
}
}
void FixedUpdate()
{
UpdateOrientationObjects();

// Vector3 targetPos
// if(targetPos hips.position)
// }
// if(m_currentWorldDirToWalk != worldDirToWalk)
// {
// worldPosToWalkTo = hips.position + (worldDirToWalk * 100);
// }
var cubeForward = m_OrientationCube.transform.forward;

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

2
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerDynamic.nn.meta


fileFormatVersion: 2
guid: 9f01b1f0509774dcc91f9ab5bb125010
guid: 3079edf9e685e42bd9469552093d6c79
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj

1001
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerStatic.nn
文件差异内容过多而无法显示
查看文件

2
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerStatic.nn.meta


fileFormatVersion: 2
guid: 2e0d900f09db24987be3c20897bb9f62
guid: 922e20ca5872c4de8a4d785a9dfdeb0d
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj

1001
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerStaticVariableSpeed.nn
文件差异内容过多而无法显示
查看文件

2
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerStaticVariableSpeed.nn.meta


fileFormatVersion: 2
guid: abd8e7fd1933f453aaf141ba83845699
guid: 8a7474f51e2a84a1f97442b60c5450d9
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj

8
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50.meta


fileFormatVersion: 2
guid: edfd5cf7fe9674978b62b3df669c4e0e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerDynamicVariableSpeed.nn
文件差异内容过多而无法显示
查看文件

11
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50/WalkerDynamicVariableSpeed.nn.meta


fileFormatVersion: 2
guid: f5c2229e01ddb453c9c308f781a6b6c5
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj
11400002: model data
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 19ed1486aa27d4903b34839f37b8f69f, type: 3}

8
Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgCoreVel50meterMax.meta


fileFormatVersion: 2
guid: 39106c3db5c7845618a6d498f348d1f4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

/Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgCoreVel50meterMax → /Project/Assets/ML-Agents/Examples/Walker/TFModels/20kAvgVelAllBPMaxDist50

正在加载...
取消
保存