浏览代码

Fixed bugs in joint anchor point axis and positions. Fixed various other in code. Trains. Still something wrong: cumulative reward of 25 is reached and when it falls down to zero. Camera follow doesn't work.

/PhysXArticulations20201
Vilmantas Balasevicius 5 年前
当前提交
cc4316a0
共有 6 个文件被更改,包括 776 次插入316 次删除
  1. 56
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/ArticulatedCrawler.prefab
  2. 189
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/ArticulatedFixedPlatform.prefab
  3. 791
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scenes/ArticulatedCrawlerStaticTarget.unity
  4. 10
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/ArticulatedCrawlerAgent.cs
  5. 41
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/ArticulatedJointDriveController.cs
  6. 5
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs

56
UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/ArticulatedCrawler.prefab


- component: {fileID: 4283901937423508}
- component: {fileID: 201389242582710296}
- component: {fileID: 7737080709538424164}
- component: {fileID: 660832040}
m_Layer: 0
m_Name: ArticulatedCrawler
m_TagString: Untagged

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1129387478859796}
m_LocalRotation: {x: 0, y: 0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: 0, y: 2.1, z: 6.3}
m_LocalPosition: {x: -400, y: 2.1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4415045083540138}

m_Script: {fileID: 11500000, guid: d8020ed16eb94c9aac4589a46facb1fa, type: 3}
m_Name:
m_EditorClassIdentifier:
maxJointSpring: 80
jointDampen: 10
maxJointSpring: 200
jointDampen: 20
maxJointForceLimit: 1000
bodyPartsList: []
--- !u!114 &7737080709538424164

foot3: {fileID: 4401195584138594589}
groundedMaterial: {fileID: 0}
unGroundedMaterial: {fileID: 0}
--- !u!114 &660832040
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1129387478859796}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1183164ed37748bf9cc8441ceb64df13, type: 3}
m_Name:
m_EditorClassIdentifier:
upperLeg0: {fileID: 1375085644099298951}
upperLeg1: {fileID: 9138266637015102719}
foreLeg0: {fileID: 8645302927567461119}
foreLeg1: {fileID: 8600072863197404167}
useAlternativeKeySetForInput: 0
maxJointForceLimit: 1000
maxJointSpring: 60
jointDampen: 10
currentStrength: 0
--- !u!1 &1374302196839222
GameObject:
m_ObjectHideFlags: 0

m_GameObject: {fileID: 1375085644099298951}
m_Enabled: 1
m_Mass: 3
m_ParentAnchorPosition: {x: 0.34000003, y: -0.16999991, z: -0.34000003}
m_ParentAnchorPosition: {x: 0.34, y: -0.16999991, z: -0.33999467}
m_ParentAnchorRotation: {x: 0, y: 0.92387974, z: 0, w: -0.38268343}
m_AnchorPosition: {x: -0.34, y: -0.17, z: -0.34}
m_AnchorRotation: {x: 0, y: 0.3826835, z: 0, w: -0.9238795}

m_GameObject: {fileID: 1608323988796809829}
m_Enabled: 1
m_Mass: 3
m_ParentAnchorPosition: {x: -0.34000015, y: -0.16999991, z: -0.33999997}
m_ParentAnchorRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068}
m_ParentAnchorPosition: {x: -0.34000003, y: -0.16999991, z: -0.3399946}
m_ParentAnchorRotation: {x: 0, y: 0.38268355, z: 0, w: -0.9238796}
m_AnchorRotation: {x: 0, y: 0, z: 0.70710677, w: 0.70710677}
m_AnchorRotation: {x: 0, y: 0.3826835, z: 0, w: -0.9238795}
m_ComputeParentAnchor: 1
m_ArticulationJointType: 3
m_LinearX: 0

m_GameObject: {fileID: 6436309409552997484}
m_Enabled: 1
m_Mass: 3
m_ParentAnchorPosition: {x: -0.34000003, y: -0.16999991, z: 0.34000003}
m_ParentAnchorPosition: {x: -0.34000003, y: -0.16999991, z: 0.33999476}
m_ParentAnchorRotation: {x: 0, y: -0.38268343, z: 0, w: -0.92387974}
m_AnchorPosition: {x: -0.34, y: -0.17, z: -0.34}
m_AnchorRotation: {x: 0, y: 0.3826835, z: 0, w: -0.9238795}

m_GameObject: {fileID: 8599193235947197219}
m_Enabled: 1
m_Mass: 1
m_ParentAnchorPosition: {x: -0.9852708, y: -0.15444617, z: -0.94548213}
m_ParentAnchorPosition: {x: -0.98528135, y: -0.15444617, z: -0.9454819}
m_ParentAnchorRotation: {x: 0, y: 0.38268355, z: 0, w: 0.92387974}
m_AnchorPosition: {x: -0.62, y: -0, z: -0.82}
m_AnchorRotation: {x: 0, y: 0.38268346, z: 0, w: 0.9238795}

m_GameObject: {fileID: 8600072863197404167}
m_Enabled: 1
m_Mass: 1
m_ParentAnchorPosition: {x: -0.98527044, y: -0.15444617, z: -0.94548166}
m_ParentAnchorPosition: {x: -0.98527056, y: -0.15444617, z: -0.9454919}
m_ParentAnchorRotation: {x: 0, y: 0.38268352, z: 0, w: 0.9238796}
m_AnchorPosition: {x: -0.62, y: -0, z: -0.82}
m_AnchorRotation: {x: 0, y: 0.38268346, z: 0, w: 0.9238795}

m_GameObject: {fileID: 8640153343578765727}
m_Enabled: 1
m_Mass: 1
m_ParentAnchorPosition: {x: -0.36527064, y: -0.15444617, z: -0.12548165}
m_ParentAnchorRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068}
m_AnchorPosition: {x: 0, y: 0, z: 0}
m_AnchorRotation: {x: 0, y: 0, z: 0.70710677, w: 0.70710677}
m_ParentAnchorPosition: {x: -0.98527056, y: -0.15444617, z: -0.9454919}
m_ParentAnchorRotation: {x: 0, y: 0.38268352, z: 0, w: 0.9238796}
m_AnchorPosition: {x: -0.62, y: 0, z: -0.82}
m_AnchorRotation: {x: 0, y: 0.38268346, z: 0, w: 0.9238795}
m_ComputeParentAnchor: 1
m_ArticulationJointType: 2
m_LinearX: 0

m_Swing2: 0
m_Twist: 0
m_Twist: 1
m_XDrive:
lowerLimit: -120
upperLimit: 120

m_GameObject: {fileID: 8645302927567461119}
m_Enabled: 1
m_Mass: 1
m_ParentAnchorPosition: {x: -0.9852708, y: -0.15444617, z: -0.94548196}
m_ParentAnchorPosition: {x: -0.9852817, y: -0.15444617, z: -0.945482}
m_ParentAnchorRotation: {x: 0, y: 0.38268355, z: 0, w: 0.92387974}
m_AnchorPosition: {x: -0.62, y: -0, z: -0.82}
m_AnchorRotation: {x: 0, y: 0.38268346, z: 0, w: 0.9238795}

m_GameObject: {fileID: 9138266637015102719}
m_Enabled: 1
m_Mass: 3
m_ParentAnchorPosition: {x: 0.34000015, y: -0.16999991, z: 0.33999997}
m_ParentAnchorPosition: {x: 0.34000003, y: -0.16999991, z: 0.3399946}
m_ParentAnchorRotation: {x: 0, y: -0.9238796, z: 0, w: -0.38268355}
m_AnchorPosition: {x: -0.34, y: -0.17, z: -0.34}
m_AnchorRotation: {x: 0, y: 0.3826835, z: 0, w: -0.9238795}

189
UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/ArticulatedFixedPlatform.prefab


- component: {fileID: 33357510309310810}
- component: {fileID: 65988756214975206}
- component: {fileID: 23273142761279318}
- component: {fileID: 248458943591167062}
m_Layer: 0
m_Name: Target
m_TagString: target

m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!54 &248458943591167062
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379819145489036}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!1 &1846708386698568
GameObject:
m_ObjectHideFlags: 0

m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 150000, y: 1, z: 5000}
m_Size: {x: 150000, y: 5, z: 5000}
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &1949512470922882
GameObject:

m_Modification:
m_TransformParent: {fileID: 4309919623019186}
m_Modifications:
- target: {fileID: 8962597602698882073, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: -0.98526704
objectReference: {fileID: 0}
- target: {fileID: 8962597602698882073, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.945482
objectReference: {fileID: 0}
- target: {fileID: 7568056552315507695, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: 0.34
objectReference: {fileID: 0}
- target: {fileID: 7568056552315507695, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.33999467
objectReference: {fileID: 0}
- target: {fileID: 391510198893407734, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: -0.9852668
objectReference: {fileID: 0}
- target: {fileID: 391510198893407734, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.9454822
objectReference: {fileID: 0}
- target: {fileID: 5477127875235992920, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: -0.34
objectReference: {fileID: 0}
- target: {fileID: 5477127875235992920, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: 0.33999467
objectReference: {fileID: 0}
- target: {fileID: 1129387478859796, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_Name
value: ArticulatedCrawler
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalPosition.x
value: 0

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
- target: {fileID: 1129387478859796, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_Name
value: ArticulatedCrawler
objectReference: {fileID: 0}
- target: {fileID: 7737080709538424164, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: target
value:
objectReference: {fileID: 4749909135913778}
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: targetIsStatic
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5477127875235992920, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: ground
value:
objectReference: {fileID: 4856650706546504}
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: m_ParentAnchorPosition.x
value: -0.34
objectReference: {fileID: 0}
- target: {fileID: 5477127875235992920, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: brain
value:
objectReference: {fileID: 11400000, guid: 0505e961608004377974940ed17e03d5,
type: 2}
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: m_ParentAnchorPosition.z
value: 0.33999467
objectReference: {fileID: 0}
- target: {fileID: 7568056552315507695, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: detectTargets
value: 0
propertyPath: m_ParentAnchorPosition.x
value: 0.34
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
- target: {fileID: 7568056552315507695, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: targetIsStatic
value: 1
propertyPath: m_ParentAnchorPosition.z
value: -0.33999467
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}

- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorRotation.y
value: 0
value: 0.38268355
value: 0.7071068
value: 0
value: 0.7071068
value: -0.9238796
objectReference: {fileID: 0}
- target: {fileID: 484994017600599577, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: 0.34000012
objectReference: {fileID: 0}
- target: {fileID: 484994017600599577, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: 0.3399946
objectReference: {fileID: 0}
- target: {fileID: 5132821532538140345, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.94547755
objectReference: {fileID: 0}
- target: {fileID: 5132821532538140345, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: -0.98527044
objectReference: {fileID: 0}
- target: {fileID: 8962597602698882073, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: -0.98526704
objectReference: {fileID: 0}
- target: {fileID: 8962597602698882073, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.945482
objectReference: {fileID: 0}
- target: {fileID: 391510198893407734, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: -0.9852668
objectReference: {fileID: 0}
- target: {fileID: 391510198893407734, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.9454822
value: -0.36527067
value: -0.98527044
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}

- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.12548523
value: -0.94547755
value: 0.7071068
value: 0
value: 0.7071068
value: 0.9238796
- target: {fileID: 484994017600599577, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: target
value:
objectReference: {fileID: 4749909135913778}
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: ground
value:
objectReference: {fileID: 4856650706546504}
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: m_ParentAnchorPosition.x
value: 0.34000012
objectReference: {fileID: 0}
- target: {fileID: 484994017600599577, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: brain
value:
objectReference: {fileID: 11400000, guid: 0505e961608004377974940ed17e03d5,
type: 2}
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: m_ParentAnchorPosition.z
value: 0.3399946
propertyPath: detectTargets
value: 0
- target: {fileID: 5132821532538140345, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
propertyPath: m_ParentAnchorPosition.z
value: -0.94547755
propertyPath: targetIsStatic
value: 1
objectReference: {fileID: 0}
- target: {fileID: 153208165644155028, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}

791
UnitySDK/Assets/ML-Agents/Examples/Crawler/Scenes/ArticulatedCrawlerStaticTarget.unity
文件差异内容过多而无法显示
查看文件

10
UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/ArticulatedCrawlerAgent.cs


public override void CollectObservations()
{
m_JdController.GetCurrentJointForces();
// Update pos to target
m_DirToTarget = target.position - body.position;
m_LookRotation = Quaternion.LookRotation(m_DirToTarget);

var i = -1;
// Pick a new target joint rotation
bpDict[leg0Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[leg1Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[leg2Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[leg3Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[leg0Upper].SetJointTargetRotation(0, vectorAction[++i], vectorAction[++i]);
bpDict[leg1Upper].SetJointTargetRotation(0, vectorAction[++i], vectorAction[++i]);
bpDict[leg2Upper].SetJointTargetRotation(0, vectorAction[++i], vectorAction[++i]);
bpDict[leg3Upper].SetJointTargetRotation(0, vectorAction[++i], vectorAction[++i]);
bpDict[leg0Lower].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[leg1Lower].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[leg2Lower].SetJointTargetRotation(vectorAction[++i], 0, 0);

41
UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/ArticulatedJointDriveController.cs


public float currentYNormalizedRot;
public float currentZNormalizedRot;
[Header("Other Debug Info")][Space(10)]
public Vector3 currentJointForce;
public float currentJointForceSqrMag;
public Vector3 currentJointTorque;
public float currentJointTorqueSqrMag;
public AnimationCurve jointForceCurve = new AnimationCurve();
public AnimationCurve jointTorqueCurve = new AnimationCurve();
/// <summary>
/// Reset body part to initial configuration.
/// </summary>

bp.thisJdController = this;
bodyPartsDict.Add(t, bp);
bodyPartsList.Add(bp);
}
public void GetCurrentJointForces()
{
/*
foreach (var bodyPart in bodyPartsDict.Values)
{
if (!bodyPart.arb.isRoot)
{
// Why do we need a force here ?
//bodyPart.currentJointForce = bodyPart.arb;
bodyPart.currentJointForceSqrMag = bodyPart.joint.currentForce.magnitude;
bodyPart.currentJointTorque = bodyPart.joint.currentTorque;
bodyPart.currentJointTorqueSqrMag = bodyPart.joint.currentTorque.magnitude;
if (Application.isEditor)
{
if (bodyPart.jointForceCurve.length > 1000)
{
bodyPart.jointForceCurve = new AnimationCurve();
}
if (bodyPart.jointTorqueCurve.length > 1000)
{
bodyPart.jointTorqueCurve = new AnimationCurve();
}
bodyPart.jointForceCurve.AddKey(Time.time, bodyPart.currentJointForceSqrMag);
bodyPart.jointTorqueCurve.AddKey(Time.time, bodyPart.currentJointTorqueSqrMag);
}
}
}
*/
}
}
}

5
UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs


public override void InitializeAcademy()
{
Monitor.verticalOffset = 1f;
// Not needed for articulations
//Physics.defaultSolverIterations = 12;
//Physics.defaultSolverVelocityIterations = 12;
Physics.defaultSolverIterations = 12;
Physics.defaultSolverVelocityIterations = 12;
Time.fixedDeltaTime = 0.01333f; // (75fps). default is .2 (60fps)
Time.maximumDeltaTime = .15f; // Default is .33
}

正在加载...
取消
保存