浏览代码

spawn a target

/hh-32-observation-crawler
HH 4 年前
当前提交
1dd1dd81
共有 9 个文件被更改,包括 1441 次插入817 次删除
  1. 25
      Project/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
  2. 90
      Project/Assets/ML-Agents/Examples/Crawler/Prefabs/Ragdoll/CrawlerBase.prefab
  3. 926
      Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity
  4. 26
      Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicVariableSpeed.unity
  5. 29
      Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs
  6. 1001
      Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticVariableSpeed.unity
  7. 8
      Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticVariableSpeed.unity.meta
  8. 146
      Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/Targets/Target.prefab
  9. 7
      Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/Targets/Target.prefab.meta

25
Project/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab


- target: {fileID: 3840539935788495952, guid: 46734abd0de454192b407379c6a4ab8d,
type: 3}
propertyPath: m_IsActive
value: 1
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 46734abd0de454192b407379c6a4ab8d, type: 3}

value:
objectReference: {fileID: 11400000, guid: f30160db27295406792cb2c245436596,
type: 3}
- target: {fileID: 5252291232670041176, guid: 28a89097e949f4e988b760459a6e7d4f,
type: 3}
propertyPath: m_BehaviorName
value:
objectReference: {fileID: 0}
- target: {fileID: 5252291232670041177, guid: 28a89097e949f4e988b760459a6e7d4f,
type: 3}
propertyPath: useFootGroundedVisualization
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5252291232670041179, guid: 28a89097e949f4e988b760459a6e7d4f,
type: 3}
propertyPath: m_LocalPosition.x

propertyPath: m_LocalPosition.y
value: -1.49
objectReference: {fileID: 0}
- target: {fileID: 4845971001715176648, guid: 0456c89e8c9c243d595b039fe7aa0bf9,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: a8b3070c69519483f93f8453e7dac8a4,
type: 3}
objectReference: {fileID: 7802320107249901494}
objectReference: {fileID: 0}
- target: {fileID: 4845971001715176649, guid: 0456c89e8c9c243d595b039fe7aa0bf9,
type: 3}
propertyPath: typeOfCrawler
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4845971001715176651, guid: 0456c89e8c9c243d595b039fe7aa0bf9,
type: 3}
propertyPath: m_LocalPosition.x

90
Project/Assets/ML-Agents/Examples/Crawler/Prefabs/Ragdoll/CrawlerBase.prefab


- component: {fileID: 4845971001715176663}
- component: {fileID: 4845971001715176660}
m_Layer: 0
m_Name: Crawler
m_Name: CrawlerBase
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

- {fileID: 4845971001588102148}
- {fileID: 2310084103354264149}
- {fileID: 2270141184585723026}
- {fileID: 379643616018628928}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 5000
typeOfCrawler: 0
targetPrefab: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
target: {fileID: 0}
body: {fileID: 4845971001588102148}
leg0Upper: {fileID: 4845971001327157979}

leg2Lower: {fileID: 4845971000281612789}
leg3Upper: {fileID: 4845971000943818107}
leg3Lower: {fileID: 4845971000245862063}
m_OrientationCube: {fileID: 0}
m_DirectionIndicator: {fileID: 0}
useFootGroundedVisualization: 0
foot0: {fileID: 4845971001702882992}
foot1: {fileID: 4845970999844939483}

m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!1001 &3459778465278260478
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 4845971001715176651}
m_Modifications:
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalPosition.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalPosition.z
value: 2
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3840539935788495952, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_Name
value: Target
objectReference: {fileID: 0}
- target: {fileID: 3840539935788495952, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1a2a52e48911845a8a189e0891357ea2, type: 3}
--- !u!4 &379643616018628928 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
type: 3}
m_PrefabInstance: {fileID: 3459778465278260478}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &4357529801223143938
PrefabInstance:
m_ObjectHideFlags: 0

type: 3}
propertyPath: targetToLookAt
value:
objectReference: {fileID: 0}
objectReference: {fileID: 379643616018628928}
- target: {fileID: 6026464216722085689, guid: e568400ebedb3474fac505995f12ed4a,
type: 3}
propertyPath: updatedByAgent

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

26
Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicVariableSpeed.unity


objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0058b366f9d6d44a3ba35beb06b0174b, type: 3}
--- !u!4 &794511373 stripped
--- !u!4 &1018218737 stripped
m_CorrespondingSourceObject: {fileID: 2467802541724839399, guid: 0058b366f9d6d44a3ba35beb06b0174b,
m_CorrespondingSourceObject: {fileID: 3421283061859478279, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
m_PrefabInstance: {fileID: 6815147847201213989}
m_PrefabAsset: {fileID: 0}

m_Script: {fileID: 11500000, guid: ec40c70d5160b47cd8deaab79e24892c, type: 3}
m_Name:
m_EditorClassIdentifier:
target: {fileID: 794511373}
target: {fileID: 1018218737}
--- !u!1001 &1481808307
PrefabInstance:
m_ObjectHideFlags: 0

m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2467802541598158122, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
propertyPath: typeOfCrawler
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2467802541598158122, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
propertyPath: useFootGroundedVisualization
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2467802541598158123, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
propertyPath: m_BehaviorName
value:
objectReference: {fileID: 0}
- target: {fileID: 3421283062001101770, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
propertyPath: typeOfCrawler
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6810587057221831324, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
propertyPath: m_LocalPosition.x

29
Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs


[RequireComponent(typeof(JointDriveController))] // Required to set joint forces
public class CrawlerAgent : Agent
{
{
public enum CrawlerAgentBehaviorType
{
CrawlerDynamic, CrawlerDynamicVariableSpeed, CrawlerStatic, CrawlerStaticVariableSpeed

const float m_maxWalkingSpeed = 10; //The max walking speed
//Should the agent sample a new goal velocity each episode?
//If true, walkSpeed will be randomly set between zero and m_maxWalkingSpeed in OnEpisodeBegin()
//If true, walkSpeed will be randomly set between zero and m_maxWalkingSpeed in OnEpisodeBegin()
[Header("Target To Walk Towards")] public Transform target; //Target the agent will walk towards during training.
[Header("Target To Walk Towards")]
public Transform targetPrefab; //Target prefab
public Transform target; //Target the agent will walk towards during training.
[Header("Body Parts")] [Space(10)] public Transform body;
public Transform leg0Upper;

public override void Initialize()
{
m_BehaviorParams = GetComponent<Unity.MLAgents.Policies.BehaviorParameters>();
switch (typeOfCrawler)
{

randomizeWalkSpeedEachEpisode = false;
target = Instantiate(targetPrefab, transform.position, Quaternion.identity, transform);
break;
}
case CrawlerAgentBehaviorType.CrawlerDynamicVariableSpeed :

break;
}
}
//Setup each body part
m_JdController.SetupBodyPart(body);
m_JdController.SetupBodyPart(leg0Upper);

//ragdoll's avg vel
var avgVel = GetAvgVelocity();
//current ragdoll velocity. normalized
//current ragdoll velocity. normalized
sensor.AddObservation(Vector3.Distance(velGoal, avgVel));
//avg body vel relative to cube
sensor.AddObservation(m_OrientationCube.transform.InverseTransformDirection(avgVel));

sensor.AddObservation(Quaternion.FromToRotation(body.forward, cubeForward));
//Add pos of target relative to orientation cube
sensor.AddObservation(m_OrientationCube.transform.InverseTransformPoint(target.transform.position));

CollectObservationBodyPart(bodyPart, sensor);
}
}
// /// <summary>
// /// Loop over body parts to add them to observation.
// /// </summary>

// CollectObservationBodyPart(bodyPart, sensor);
// }
// }
public override void OnActionReceived(float[] vectorAction)
public override void OnActionReceived(ActionBuffers actionBuffers)
{
// The dictionary with all the body parts in it are in the jdController
var bpDict = m_JdController.bodyPartsDict;

? groundedMaterial
: unGroundedMaterial;
}
var cubeForward = m_OrientationCube.transform.forward;
// Set reward for this step according to mixture of the following elements.

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

8
Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticVariableSpeed.unity.meta


fileFormatVersion: 2
guid: 466b29aa13fcb4f01afb832e42ffef4c
timeCreated: 1508521562
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

146
Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/Targets/Target.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3840539935788495952
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3839136118347789758}
- component: {fileID: 3836793085241645916}
- component: {fileID: 3868551391811062596}
- component: {fileID: 3826955612593018128}
- component: {fileID: 3858402326794362026}
- component: {fileID: 3631016866778687563}
m_Layer: 0
m_Name: DynamicTarget
m_TagString: target
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3839136118347789758
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3840539935788495952}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &3836793085241645916
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3840539935788495952}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!65 &3868551391811062596
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3840539935788495952}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &3826955612593018128
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3840539935788495952}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: c67450f290f3e4897bc40276a619e78d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!54 &3858402326794362026
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3840539935788495952}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 3
--- !u!114 &3631016866778687563
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3840539935788495952}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3c8f113a8b8d94967b1b1782c549be81, type: 3}
m_Name:
m_EditorClassIdentifier:
tagToDetect: agent
spawnRadius: 40
respawnIfTouched: 1
respawnIfFallsOffPlatform: 1
fallDistance: 5
onTriggerEnterEvent:
m_PersistentCalls:
m_Calls: []
onTriggerStayEvent:
m_PersistentCalls:
m_Calls: []
onTriggerExitEvent:
m_PersistentCalls:
m_Calls: []
onCollisionEnterEvent:
m_PersistentCalls:
m_Calls: []
onCollisionStayEvent:
m_PersistentCalls:
m_Calls: []
onCollisionExitEvent:
m_PersistentCalls:
m_Calls: []

7
Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/Targets/Target.prefab.meta


fileFormatVersion: 2
guid: 1a2a52e48911845a8a189e0891357ea2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存