浏览代码

First working iteration of actuated crawler scene, prefabs and code complete. Can train, not sure whether learn though. Camera follow is broken.

/PhysXArticulations20201
Vilmantas Balasevicius 5 年前
当前提交
81109510
共有 12 个文件被更改,包括 1434 次插入3900 次删除
  1. 5
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Brains/CrawlerStaticLearning.asset
  2. 897
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/ArticulatedCrawler.prefab
  3. 981
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/ArticulatedFixedPlatform.prefab
  4. 971
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
  5. 942
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
  6. 3
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab.meta
  7. 380
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scenes/ArticulatedCrawlerManualControl.unity
  8. 983
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scenes/ArticulatedCrawlerStaticTarget.unity
  9. 7
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/ArticulatedCrawlerAgent.cs
  10. 148
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/ArticulatedCrawlerManualControl.cs
  11. 12
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/ArticulatedJointDriveController.cs
  12. 5
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs

5
UnitySDK/Assets/ML-Agents/Examples/Crawler/Brains/CrawlerStaticLearning.asset


--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0

897
UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/ArticulatedCrawler.prefab
文件差异内容过多而无法显示
查看文件

981
UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/ArticulatedFixedPlatform.prefab
文件差异内容过多而无法显示
查看文件

971
UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
文件差异内容过多而无法显示
查看文件

942
UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
文件差异内容过多而无法显示
查看文件

3
UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab.meta


fileFormatVersion: 2
guid: 1b9d167a4e71146a883212e4f08bda88
NativeFormatImporter:
PrefabImporter:
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

380
UnitySDK/Assets/ML-Agents/Examples/Crawler/Scenes/ArticulatedCrawlerManualControl.unity


debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &1167278637 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1608323988796809829, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
m_PrefabInstance: {fileID: 1445410834}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &671491189
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1129387478859796, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_Name
value: ArticulatedCrawler
objectReference: {fileID: 0}
- target: {fileID: 1129387478859796, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalPosition.y
value: 2.1
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalPosition.z
value: 6.3
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalRotation.y
value: 0.38268343
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalRotation.w
value: 0.92387956
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 45
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
--- !u!1 &1193539137
GameObject:
m_ObjectHideFlags: 0

m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1445410834
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- 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
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalPosition.y
value: 2.1
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalPosition.z
value: 6.3
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalRotation.y
value: 0.38268343
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalRotation.w
value: 0.92387956
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 45
objectReference: {fileID: 0}
- target: {fileID: 4283901937423508, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114824265617332224, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2237312266892387086, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_Immovable
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9178360820360622353, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9178360820360622353, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9178360820360622353, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_LocalScale.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorPosition.y
value: -0.17
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorPosition.x
value: -0.34
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorPosition.z
value: -0.34
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: 0.34000003
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.y
value: -0.16999991
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.34000003
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorRotation.y
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorRotation.w
value: 0.70710695
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_Swing1
value: 1
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_Swing2
value: 1
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_XDrive.lowerLimit
value: -120
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_YDrive.lowerLimit
value: -120
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_YDrive.upperLimit
value: 120
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_XDrive.upperLimit
value: 120
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ZDrive.lowerLimit
value: -120
objectReference: {fileID: 0}
- target: {fileID: 952006233201449903, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ZDrive.upperLimit
value: 120
objectReference: {fileID: 0}
- target: {fileID: 8640153343578765727, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_Name
value: ForeLegBone0
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorPosition.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorPosition.x
value: -0.62
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_AnchorPosition.z
value: -0.82
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.x
value: -0.9852712
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.y
value: -0.15444617
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorPosition.z
value: -0.94548225
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ParentAnchorRotation.w
value: 1.0000002
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_XDrive.upperLimit
value: 120
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_Swing1
value: 2
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_Swing2
value: 2
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_XDrive.lowerLimit
value: -120
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_YDrive.lowerLimit
value: -120
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_YDrive.upperLimit
value: 120
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ZDrive.lowerLimit
value: -120
objectReference: {fileID: 0}
- target: {fileID: 75375539162916863, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_ZDrive.upperLimit
value: 120
objectReference: {fileID: 0}
- target: {fileID: 7737080709538424164, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2, type: 3}
--- !u!1 &1903117048 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8640153343578765727, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
m_PrefabInstance: {fileID: 1445410834}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1932203904 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1129387478859796, guid: 1661ce2a8a3cdfd3480c3d24bddd72f2,
type: 3}
m_PrefabInstance: {fileID: 1445410834}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1932203905
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1932203904}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1183164ed37748bf9cc8441ceb64df13, type: 3}
m_Name:
m_EditorClassIdentifier:
upperLeg: {fileID: 1167278637}
foreLeg: {fileID: 1903117048}
useAlternativeKeySetForInput: 0
maxJointForceLimit: 10000
maxJointSpring: 40
jointDampen: 3000
currentStrength: 0

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

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


using UnityEngine;
using MLAgents;
[RequireComponent(typeof(JointDriveController))] // Required to set joint forces
[RequireComponent(typeof(ArticulatedJointDriveController))] // Required to set joint forces
public class ArticulatedCrawlerAgent : Agent
{
[Header("Target To Walk Towards")][Space(10)]

if (bp.arb.transform != body)
{
// Will need to rewrite this because body parts are in hiearchy, not flat like in RigidBody case
//var localPosRelToBody = body.InverseTransformPoint(arb.position);
//AddVectorObs(localPosRelToBody);
var localPosRelToBody = body.InverseTransformPoint(arb.transform.TransformPoint(arb.transform.position)); // Translate from world space to body local space, since all articulations are children of body in hiearchy
AddVectorObs(localPosRelToBody);
AddVectorObs(bp.currentXNormalizedRot); // Current x rot
AddVectorObs(bp.currentYNormalizedRot); // Current y rot
AddVectorObs(bp.currentZNormalizedRot); // Current z rot

148
UnitySDK/Assets/ML-Agents/Examples/Crawler/Scripts/ArticulatedCrawlerManualControl.cs


{
public class ArticulatedCrawlerManualControl : MonoBehaviour
{
public GameObject upperLeg;
public GameObject foreLeg;
private ArticulationBody m_AbUpper;
private ArticulationBody m_AbFore;
public GameObject upperLeg0, upperLeg1;
public GameObject foreLeg0, foreLeg1;
private ArticulationBody m_AbUpper0, m_AbUpper1;
private ArticulationBody m_AbFore0, m_AbFore1;
private Vector3 m_rotationUpper;
private Vector3 m_rotationFore;
private Vector3 m_rotationUpper0, m_rotationUpper1;
private Vector3 m_rotationFore0, m_rotationFore1;
public bool useAlternativeKeySetForInput = false;
public float maxJointForceLimit = 1000;

/// </summary>
public void Start()
{
m_AbUpper = upperLeg.GetComponent<ArticulationBody>();
m_AbFore = foreLeg.GetComponent<ArticulationBody>();
m_AbUpper0 = upperLeg0.GetComponent<ArticulationBody>();
m_AbFore0 = foreLeg0.GetComponent<ArticulationBody>();
m_AbUpper1 = upperLeg1.GetComponent<ArticulationBody>();
m_AbFore1 = foreLeg1.GetComponent<ArticulationBody>();
m_rotationUpper = m_rotationFore = Vector3.zero;
m_rotationUpper0 = m_rotationFore0 = m_rotationUpper1 = m_rotationFore1 = Vector3.zero;
}
/// <summary>

{
m_rotationUpper = Vector3.zero;
m_rotationFore = Vector3.zero;
m_rotationUpper0 = m_rotationFore0 = m_rotationUpper1 = m_rotationFore1 = Vector3.zero;
/*
m_AbUpper.transform.position = new Vector3(0f, -4f, 0f) + transform.position;

public void FixedUpdate()
{
//float maxTorque = 1000f;
float deltaRotation = 0.01f;
float speed = 100f;
float deltaRotation = speed * Time.fixedDeltaTime;
m_rotationUpper0.x = m_AbUpper0.xDrive.target;
m_rotationUpper0.y = m_AbUpper0.yDrive.target;
m_rotationUpper0.z = m_AbUpper0.zDrive.target;
m_rotationUpper1.x = m_AbUpper1.xDrive.target;
m_rotationUpper1.y = m_AbUpper1.yDrive.target;
m_rotationUpper1.z = m_AbUpper1.zDrive.target;
m_rotationUpper.x += deltaRotation;
{
m_rotationUpper0.x += deltaRotation;
m_rotationUpper1.x += deltaRotation;
}
m_rotationUpper.x -= deltaRotation;
{
m_rotationUpper0.x -= deltaRotation;
m_rotationUpper1.x -= deltaRotation;
}
m_rotationUpper.y += deltaRotation;
{
m_rotationUpper0.y += deltaRotation;
m_rotationUpper1.y += deltaRotation;
}
m_rotationUpper.y -= deltaRotation;
{
m_rotationUpper0.y -= deltaRotation;
m_rotationUpper1.y -= deltaRotation;
}
m_rotationUpper.z += deltaRotation;
{
m_rotationUpper0.z += deltaRotation;
m_rotationUpper1.z += deltaRotation;
}
m_rotationUpper.z -= deltaRotation;
{
m_rotationUpper0.z -= deltaRotation;
m_rotationUpper1.z -= deltaRotation;
}
m_rotationUpper.x = Mathf.Clamp(m_rotationUpper.x, -Mathf.PI * 0.5f, Mathf.PI * 0.5f);
m_rotationUpper.y = Mathf.Clamp(m_rotationUpper.y, -Mathf.PI * 0.5f, Mathf.PI * 0.5f);
m_rotationUpper.z = Mathf.Clamp(m_rotationUpper.z, -Mathf.PI * 0.5f, Mathf.PI * 0.5f);
m_rotationUpper0.x = Mathf.Clamp(m_rotationUpper0.x, -180.0f, 180.0f);
m_rotationUpper0.y = Mathf.Clamp(m_rotationUpper0.y, -180.0f, 180.0f);
m_rotationUpper0.z = Mathf.Clamp(m_rotationUpper0.z, -180.0f, 180.0f);
m_rotationUpper1.x = Mathf.Clamp(m_rotationUpper1.x, -180.0f, 180.0f);
m_rotationUpper1.y = Mathf.Clamp(m_rotationUpper1.y, -180.0f, 180.0f);
m_rotationUpper1.z = Mathf.Clamp(m_rotationUpper1.z, -180.0f, 180.0f);
m_rotationFore0.x = m_AbFore0.xDrive.target;
m_rotationFore0.y = m_AbFore0.yDrive.target;
m_rotationFore0.z = m_AbFore0.zDrive.target;
m_rotationFore.x += deltaRotation;
{
m_rotationFore0.x += deltaRotation;
m_rotationFore1.x += deltaRotation;
}
m_rotationFore.x -= deltaRotation;
{
m_rotationFore0.x -= deltaRotation;
m_rotationFore1.x -= deltaRotation;
}
m_rotationFore.y += deltaRotation;
{
m_rotationFore0.y += deltaRotation;
m_rotationFore1.y += deltaRotation;
}
m_rotationFore.y -= deltaRotation;
{
m_rotationFore0.y -= deltaRotation;
m_rotationFore1.y -= deltaRotation;
}
m_rotationFore.z += deltaRotation;
{
m_rotationFore0.z += deltaRotation;
m_rotationFore1.z += deltaRotation;
}
m_rotationFore.z -= deltaRotation;
{
m_rotationFore0.z -= deltaRotation;
m_rotationFore1.z -= deltaRotation;
}
m_rotationFore0.x = Mathf.Clamp(m_rotationFore0.x, -180.0f, 180.0f);
m_rotationFore0.y = Mathf.Clamp(m_rotationFore0.y, -180.0f, 180.0f);
m_rotationFore0.z = Mathf.Clamp(m_rotationFore0.z, -180.0f, 180.0f);
m_rotationFore.x = Mathf.Clamp(m_rotationFore.x, -Mathf.PI * 0.5f, Mathf.PI * 0.5f);
m_rotationFore.y = Mathf.Clamp(m_rotationFore.y, -Mathf.PI * 0.5f, Mathf.PI * 0.5f);
m_rotationFore.z = Mathf.Clamp(m_rotationFore.z, -Mathf.PI * 0.5f, Mathf.PI * 0.5f);
m_rotationFore1.x = Mathf.Clamp(m_rotationFore1.x, -180.0f, 180.0f);
m_rotationFore1.y = Mathf.Clamp(m_rotationFore1.y, -180.0f, 180.0f);
m_rotationFore1.z = Mathf.Clamp(m_rotationFore1.z, -180.0f, 180.0f);
SetJointTargetRotation(m_AbUpper, m_rotationUpper.x, m_rotationUpper.y, m_rotationUpper.z);
SetJointStrength(m_AbUpper, 0.0001f);
SetJointTargetRotation(m_AbUpper0, m_rotationUpper0.x, m_rotationUpper0.y, m_rotationUpper0.z);
SetJointStrength(m_AbUpper0, 0.0001f);
SetJointTargetRotation(m_AbFore, m_rotationFore.x, m_rotationFore.y, m_rotationFore.z);
SetJointStrength(m_AbFore, 0.0001f);
SetJointTargetRotation(m_AbUpper1, m_rotationUpper1.x, m_rotationUpper1.y, m_rotationUpper1.z);
SetJointStrength(m_AbUpper1, 0.0001f);
SetJointTargetRotation(m_AbFore0, m_rotationFore0.x, m_rotationFore0.y, m_rotationFore0.z);
SetJointStrength(m_AbFore0, 0.0001f);
SetJointTargetRotation(m_AbFore1, m_rotationFore1.x, m_rotationFore1.y, m_rotationFore1.z);
SetJointStrength(m_AbFore1, 0.0001f);
if (Input.GetKey(KeyCode.Escape))

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


currentXNormalizedRot =
Mathf.InverseLerp(xDrive.lowerLimit, xDrive.upperLimit, xRot);
// What is this ? Vilmantas Why lowerLimit is not used ?
currentYNormalizedRot = Mathf.InverseLerp(-yDrive.upperLimit, yDrive.upperLimit, yRot);
currentZNormalizedRot = Mathf.InverseLerp(-zDrive.upperLimit, zDrive.upperLimit, zRot);
currentYNormalizedRot = Mathf.InverseLerp(yDrive.lowerLimit, yDrive.upperLimit, yRot);
currentZNormalizedRot = Mathf.InverseLerp(zDrive.lowerLimit, zDrive.upperLimit, zRot);
//joint.targetRotation = Quaternion.Euler(xRot, yRot, zRot); // Original code
xDrive.target = xRot; yDrive.target = yRot; zDrive.target = zRot;

/// </summary>
public void SetupBodyPart(Transform t)
{
// Either parent(in case of legs) or game object itself(in case of body) must have ArticulationBody
var arb = t.GetComponent<ArticulationBody>();
if (arb == null)
arb = t.parent.GetComponent<ArticulationBody>();
arb = t.GetComponent<ArticulationBody>(),
arb = arb,
startingPos = t.position,
startingRot = t.rotation
};

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


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

正在加载...
取消
保存