浏览代码

remove multiple walk dir methods because its confusing

/active-variablespeed
HH 4 年前
当前提交
07115ce4
共有 10 个文件被更改,包括 192 次插入2036 次删除
  1. 14
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/OrientationCubeController.cs
  2. 4
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/Platforms/PlatformWalkerDynamicSingleSpeed.prefab
  3. 4
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/Platforms/PlatformWalkerDynamicVariableSpeed.prefab
  4. 85
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollStSingleSpeedVariant.prefab
  5. 85
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollStVariableSpeedVariant.prefab
  6. 938
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamic.unity
  7. 6
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamicVariableSpeed.unity
  8. 105
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerStatic.unity
  9. 914
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerStaticVariableSpeed.unity
  10. 73
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs

14
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/OrientationCubeController.cs


public class OrientationCubeController : MonoBehaviour
{
//Public method to allow Agent to set look rotation of this transform
//This method will be deprecated in future PR
public void UpdateOrientation(Transform rootBP, Transform target)
{
var dirVector = target.position - transform.position;

//UPDATE ORIENTATION CUBE POS & ROT
transform.SetPositionAndRotation(rootBP.position, lookRot);
}
//Public method to allow Agent to set look rotation of this transform
public void UpdateOrientation(Vector3 pos, Vector3 dirVector)
{
dirVector.y = 0; //flatten dir on the y. this will only work on level surfaces
var lookRot =
dirVector == Vector3.zero
? Quaternion.identity
: Quaternion.LookRotation(dirVector.normalized); //get our look rot to the target
//UPDATE ORIENTATION CUBE POS & ROT
transform.SetPositionAndRotation(pos, lookRot);
}
}
}

4
Project/Assets/ML-Agents/Examples/Walker/Prefabs/Platforms/PlatformWalkerDynamicSingleSpeed.prefab


type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 2c37bf93cad864ba5a91689aa40eba6d,
objectReference: {fileID: 11400000, guid: e3bbf8676df3c415dac2a116b343b9f1,
type: 3}
- target: {fileID: 8228205183255163001, guid: 095e843732bad4a02b273c01eaff4b26,
type: 3}

- target: {fileID: 6907740118844148851, guid: f0d7741d9e06247f6843b921a206b978,
type: 3}
propertyPath: m_Name
value: PlatformWalkerDynamicSingleSpeed
value: PlatformDynamicTarget
objectReference: {fileID: 0}
- target: {fileID: 6907845698621467345, guid: f0d7741d9e06247f6843b921a206b978,
type: 3}

4
Project/Assets/ML-Agents/Examples/Walker/Prefabs/Platforms/PlatformWalkerDynamicVariableSpeed.prefab


- target: {fileID: 6907740118844148851, guid: f0d7741d9e06247f6843b921a206b978,
type: 3}
propertyPath: m_Name
value: PlatformWalkerDynamicVariableSpeed
value: PlatformDynamicTarget
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f0d7741d9e06247f6843b921a206b978, type: 3}

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 1a6e4a4e15a5d49a7acac1f78bc1f514,
objectReference: {fileID: 11400000, guid: dc2e1982748f3474383cc108ef2f7f26,
type: 3}
- target: {fileID: 1077752704035527914, guid: 90f3321ab5beb43e28bc651909d99e39,
type: 3}

85
Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollStSingleSpeedVariant.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &5790588709327378380
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 8228205183255162976}
m_Modifications:
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalPosition.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalPosition.z
value: 1800
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3840539935788495952, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_Name
value: StaticTarget
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e, type: 3}
--- !u!4 &7285439043585008242 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
m_PrefabInstance: {fileID: 5790588709327378380}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &9105389283052742586
PrefabInstance:
m_ObjectHideFlags: 0

type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 6328576cf5b5e45a3bf49967070b5df7,
objectReference: {fileID: 11400000, guid: e41acb4dffc814200b7789d02f04a83a,
type: 3}
- target: {fileID: 895268871377934298, guid: 765582efd9dda46ed98564603316353f,
type: 3}

type: 3}
propertyPath: target
value:
objectReference: {fileID: 0}
objectReference: {fileID: 7285439043585008242}
- target: {fileID: 7408209125961349353, guid: 765582efd9dda46ed98564603316353f,
type: 3}
propertyPath: randomizeWalkSpeedEachEpisode

objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 765582efd9dda46ed98564603316353f, type: 3}
--- !u!4 &8228205183255162976 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 895268871377934298, guid: 765582efd9dda46ed98564603316353f,
type: 3}
m_PrefabInstance: {fileID: 9105389283052742586}
m_PrefabAsset: {fileID: 0}

85
Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollStVariableSpeedVariant.prefab


type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: 71f39bc92e5ae49edba82a2d411c0678,
objectReference: {fileID: 11400000, guid: 0fbba45545dc944969c95565fa88d4fa,
type: 3}
- target: {fileID: 895268871377934298, guid: 765582efd9dda46ed98564603316353f,
type: 3}

type: 3}
propertyPath: target
value:
objectReference: {fileID: 0}
objectReference: {fileID: 4058446934158437408}
- target: {fileID: 7408209125961349353, guid: 765582efd9dda46ed98564603316353f,
type: 3}
propertyPath: randomizeWalkSpeedEachEpisode

objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 765582efd9dda46ed98564603316353f, type: 3}
--- !u!4 &1077752704035527914 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 895268871377934298, guid: 765582efd9dda46ed98564603316353f,
type: 3}
m_PrefabInstance: {fileID: 186987432828422960}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &942701540323662238
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1077752704035527914}
m_Modifications:
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalPosition.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalPosition.z
value: 1800
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3840539935788495952, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
propertyPath: m_Name
value: StaticTarget
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e, type: 3}
--- !u!4 &4058446934158437408 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
type: 3}
m_PrefabInstance: {fileID: 942701540323662238}
m_PrefabAsset: {fileID: 0}

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

6
Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamicVariableSpeed.unity


m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5047057869591498720, guid: 84359146bf7af47e58c229d877e801d7,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: dc2e1982748f3474383cc108ef2f7f26,
type: 3}
- target: {fileID: 6713178126238440196, guid: 84359146bf7af47e58c229d877e801d7,
type: 3}
propertyPath: m_Name

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


propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Name

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
objectReference: {fileID: 0}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}
--- !u!1001 &833025198

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}
--- !u!1001 &1109751809

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
objectReference: {fileID: 0}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
objectReference: {fileID: 0}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
objectReference: {fileID: 0}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}
--- !u!1001 &1679910049

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
objectReference: {fileID: 0}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8228205183255162979, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: d8bebea7ecfd0470f87cbab469bd1411,
type: 3}
objectReference: {fileID: 0}
- target: {fileID: 8228205183255163001, guid: c319a0a1c387d420a92f520b38ef875b,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c319a0a1c387d420a92f520b38ef875b, type: 3}

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

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


using System;
using MLAgentsExamples;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgentsExamples;

public class WalkerAgent : Agent
{
[Header("Walk Speed")] [Range(0.1f, 10)] public float targetWalkingSpeed = 10; //The walking speed to try and achieve
[Header("Walk Speed")] [Range(0.1f, 10)]
public float targetWalkingSpeed = 10; //The walking speed to try and achieve
const float m_maxWalkingSpeed = 10; //The max walking speed
//Should the agent sample a new goal velocity each episode?

//The method the agent will use during training to determine walk direction
//If UseWorldDirection is selected, the agent will be rewarded for facing worldDirToWalk during training
//If UseTarget is selected, the agent will be rewarded for facing target during training
//The purpose of this is to be able to give a target to chase OR a direction to walk. This could be useful when...
//...making behaviors for player controllers OR NPC behaviors
public enum WalkDirectionMethod
{
UseWorldDirection,
UseTarget
}
//The direction an agent will walk during training.
public Vector3 worldDirToWalk = Vector3.right;
[Header("Walk Direction")] public WalkDirectionMethod walkDirectionMethod;
//The direction an agent will walk during training. Only used if UseWorldDirection is selected.
public Vector3 worldDirToWalk = Vector3.right;
public Vector3 worldPosToWalkTo; //The position the agent will walk towards.
public Transform target; //Target the agent will walk towards.
[Header("Target To Walk Towards")] public Transform target; //Target the agent will walk towards during training.
[Header("Body Parts")] public Transform hips;
public Transform chest;

//This will be used as a stabilized model space reference point for observations
//Because ragdolls can move erratically during training, using a stabilized reference transform improves learning
OrientationCubeController m_OrientationCube;
//The indicator graphic gameobject that points towards the target
DirectionIndicator m_DirectionIndicator;
JointDriveController m_JdController;

UpdateOrientationObjects();
//Set the initial position to walk to
if (walkDirectionMethod == WalkDirectionMethod.UseWorldDirection)
{
worldPosToWalkTo = hips.position + (worldDirToWalk * 1000);
}
//Set our goal walking speed
targetWalkingSpeed =
randomizeWalkSpeedEachEpisode ? Random.Range(0.1f, m_maxWalkingSpeed) : targetWalkingSpeed;

{
var cubeForward = m_OrientationCube.transform.forward;
//ragdoll's avg vel
//velocity we want to match
//ragdoll's avg vel
// sensor.AddObservation(GetMatchingVelocityInverseLerp(cubeForward * targetWalkingSpeed, GetAvgVelocity()));
//actual vel relative to cube
//avg body vel relative to cube
// sensor.AddObservation(avgVel);
// //current speed goal
// sensor.AddObservation(targetWalkingSpeed);
if (walkDirectionMethod == WalkDirectionMethod.UseTarget)
{
worldPosToWalkTo = target.transform.position;
}
Vector3 relPos =
Vector3.ClampMagnitude(m_OrientationCube.transform.InverseTransformPoint(worldPosToWalkTo), 100);
sensor.AddObservation(relPos);
sensor.AddObservation(m_OrientationCube.transform.InverseTransformPoint(target.transform.position));
foreach (var bodyPart in m_JdController.bodyPartsList)
{

//Update OrientationCube and DirectionIndicator
void UpdateOrientationObjects()
{
worldDirToWalk = walkDirectionMethod == WalkDirectionMethod.UseTarget
? target.position - hips.position
: worldDirToWalk;
m_OrientationCube.UpdateOrientation(hips.position, worldDirToWalk);
if(m_DirectionIndicator)
worldDirToWalk = target.position - hips.position;
m_OrientationCube.UpdateOrientation(hips, target);
if (m_DirectionIndicator)
{
m_DirectionIndicator.MatchOrientation(m_OrientationCube.transform);
}

// Set reward for this step according to mixture of the following elements.
// a. Match target speed
//This reward will approach 1 if it matches perfectly and approach zero as it deviates
// var matchSpeedReward = GetMatchingVelocityInverseLerp(cubeForward * targetWalkingSpeed, GetAvgVelocity());
$" cubeForward: {cubeForward}\n"+
$" hips.velocity: {m_JdController.bodyPartsDict[hips].rb.velocity}\n"+
$" cubeForward: {cubeForward}\n" +
$" hips.velocity: {m_JdController.bodyPartsDict[hips].rb.velocity}\n" +
$" maximumWalkingSpeed: {m_maxWalkingSpeed}"
);
}

{
throw new ArgumentException(
"NaN in lookAtTargetReward.\n" +
$" cubeForward: {cubeForward}\n"+
$" cubeForward: {cubeForward}\n" +
//...using the average helps prevent this erratic movment
//...using the average helps prevent this erratic movement
Vector3 GetAvgVelocity()
{
Vector3 velSum = Vector3.zero;

正在加载...
取消
保存