浏览代码

cleanup

/hh-32-observation-crawler
HH 4 年前
当前提交
19097dc5
共有 3 个文件被更改,包括 137 次插入160 次删除
  1. 5
      Project/Assets/ML-Agents/Examples/Crawler/Prefabs/Ragdoll/CrawlerBase.prefab
  2. 248
      Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticVariableSpeed.unity
  3. 44
      Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs

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


crawlerStVSBrain: {fileID: 11400000, guid: db9d60279f76f44858fbaf03edf5648f, type: 3}
m_TargetWalkingSpeed: 15
randomizeWalkSpeedEachEpisode: 0
targetPrefab: {fileID: 3839136118347789758, guid: 1a2a52e48911845a8a189e0891357ea2,
dynamicTargetPrefab: {fileID: 3839136118347789758, guid: 46734abd0de454192b407379c6a4ab8d,
type: 3}
staticTargetPrefab: {fileID: 3839136118347789758, guid: 2173d15c0b5fc49e5870c9d1c7f7ee8e,
target: {fileID: 0}
body: {fileID: 4845971001588102148}
leg0Upper: {fileID: 4845971001327157979}
leg0Lower: {fileID: 4845971000000621467}

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


- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.000007897615
value: 0.000005751848
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: 0.28284454
value: 0.28283697
value: 0.2828369
value: 0.28284454
value: -0.28284454
value: -0.28283697
value: -0.2828369
value: -0.28284454
value: -0.28284454
value: -0.28283688
value: 0.2828369
value: 0.2828446
value: 0.28284454
value: 0.28283688
value: -0.2828369
value: -0.2828446
value: 0.000005528331
value: -0.000005081296
value: 0.33000812
value: 0.3300083
value: 0.000005558133
value: -0.0000050514936
value: 0.33000812
value: 0.3300083
value: -0.000007972121
value: 0.0000056773424
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
- target: {fileID: 8231708464545277303, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.000007897615
value: 0.000005751848
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: 0.28284454
value: 0.28283697
value: 0.2828369
value: 0.28284454
value: -0.28284454
value: -0.28283697
value: -0.2828369
value: -0.28284454
value: -0.28284454
value: -0.28283688
value: 0.2828369
value: 0.2828446
value: 0.28284454
value: 0.28283688
value: -0.2828369
value: -0.2828446
value: 0.000005528331
value: -0.000005081296
value: 0.33000812
value: 0.3300083
value: 0.000005558133
value: -0.0000050514936
value: 0.33000812
value: 0.3300083
value: -0.000007972121
value: 0.0000056773424
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b9d167a4e71146a883212e4f08bda88, type: 3}

- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000066310167
value: 0.000006839633
value: 0.33000672
value: 0.33000723
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.2828369
value: 0.28284287
value: -0.2828369
value: -0.28284287
value: 0.2828369
value: 0.28284281
value: -0.2828369
value: -0.28284281
value: 0.0000067949295
value: -0.0000064373016
value: 0.33000684
value: 0.33000696
value: 0.000006571412
value: -0.0000062435865
objectReference: {fileID: 0}
- target: {fileID: 3386028170881877093, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028170904845107, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000069588423
value: 0.000007018447
value: 0.33000648
value: 0.33000696
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b9d167a4e71146a883212e4f08bda88, type: 3}

- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000066310167
value: 0.000006839633
value: 0.33000672
value: 0.33000723
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.2828369
value: 0.28284287
value: -0.2828369
value: -0.28284287
value: 0.2828369
value: 0.28284281
value: -0.2828369
value: -0.28284281
value: 0.0000067949295
value: -0.0000064373016
value: 0.33000684
value: 0.33000696
value: 0.000006571412
value: -0.0000062435865
objectReference: {fileID: 0}
- target: {fileID: 3386028170881877093, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028170904845107, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000069588423
value: 0.000007018447
value: 0.33000648
value: 0.33000696
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b9d167a4e71146a883212e4f08bda88, type: 3}

- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000066310167
value: 0.000006839633
value: 0.33000672
value: 0.33000723
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.2828369
value: 0.28284287
value: -0.2828369
value: -0.28284287
value: 0.2828369
value: 0.28284281
value: -0.2828369
value: -0.28284281
value: 0.0000067949295
value: -0.0000064373016
value: 0.33000684
value: 0.33000696
value: 0.000006571412
value: -0.0000062435865
objectReference: {fileID: 0}
- target: {fileID: 3386028170881877093, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028170904845107, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000069588423
value: 0.000007018447
value: 0.33000648
value: 0.33000696
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b9d167a4e71146a883212e4f08bda88, type: 3}

- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.000007897615
value: 0.000005751848
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: 0.28284454
value: 0.28283697
value: 0.2828369
value: 0.28284454
value: -0.28284454
value: -0.28283697
value: -0.2828369
value: -0.28284454
value: -0.28284454
value: -0.28283688
value: 0.2828369
value: 0.2828446
value: 0.28284454
value: 0.28283688
value: -0.2828369
value: -0.2828446
value: 0.000005528331
value: -0.000005081296
value: 0.33000812
value: 0.3300083
value: 0.000005558133
value: -0.0000050514936
value: 0.33000812
value: 0.3300083
value: -0.000007972121
value: 0.0000056773424
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b9d167a4e71146a883212e4f08bda88, type: 3}

- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000066310167
value: 0.000006839633
value: 0.33000672
value: 0.33000723
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.2828369
value: 0.28284287
value: -0.2828369
value: -0.28284287
value: 0.2828369
value: 0.28284281
value: -0.2828369
value: -0.28284281
value: 0.0000067949295
value: -0.0000064373016
value: 0.33000684
value: 0.33000696
value: 0.000006571412
value: -0.0000062435865
objectReference: {fileID: 0}
- target: {fileID: 3386028170881877093, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028170904845107, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000069588423
value: 0.000007018447
value: 0.33000648
value: 0.33000696
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b9d167a4e71146a883212e4f08bda88, type: 3}

- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.000007897615
value: 0.000005751848
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: 0.28284454
value: 0.28283697
value: 0.2828369
value: 0.28284454
value: -0.28284454
value: -0.28283697
value: -0.2828369
value: -0.28284454
value: -0.28284454
value: -0.28283688
value: 0.2828369
value: 0.2828446
value: 0.28284454
value: 0.28283688
value: -0.2828369
value: -0.2828446
value: 0.000005528331
value: -0.000005081296
value: 0.33000812
value: 0.3300083
value: 0.000005558133
value: -0.0000050514936
value: 0.33000812
value: 0.3300083
value: -0.000007972121
value: 0.0000056773424
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b9d167a4e71146a883212e4f08bda88, type: 3}

- target: {fileID: 3386028169001571294, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.000007897615
value: 0.000005751848
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
- target: {fileID: 3386028169429758299, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}

- target: {fileID: 3386028169665032405, guid: 1b9d167a4e71146a883212e4f08bda88,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: 0.28284454
value: 0.28283697
value: 0.2828369
value: 0.28284454
value: -0.28284454
value: -0.28283697
value: -0.2828369
value: -0.28284454
value: -0.28284454
value: -0.28283688
value: 0.2828369
value: 0.2828446
value: 0.28284454
value: 0.28283688
value: -0.2828369
value: -0.2828446
value: 0.000005528331
value: -0.000005081296
value: 0.33000812
value: 0.3300083
value: 0.000005558133
value: -0.0000050514936
value: 0.33000812
value: 0.3300083
value: -0.000007972121
value: 0.0000056773424
value: 0.33000547
value: 0.33000833
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b9d167a4e71146a883212e4f08bda88, type: 3}

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


//The direction an agent will walk during training.
private Vector3 m_WorldDirToWalk = Vector3.right;
[Header("Target To Walk Towards")]
public Transform targetPrefab; //Target prefab
public Transform target; //Target the agent will walk towards during training.
public Transform dynamicTargetPrefab; //Target prefab
public Transform staticTargetPrefab; //Target prefab
private Transform m_Target; //Target the agent will walk towards during training.
[Header("Body Parts")] [Space(10)] public Transform body;
public Transform leg0Upper;

if(crawlerDyBrain)
m_BehaviorParams.Model = crawlerDyBrain;
randomizeWalkSpeedEachEpisode = false;
target = Instantiate(targetPrefab, transform.position, Quaternion.identity, transform);
m_Target = Instantiate(dynamicTargetPrefab, transform.position, Quaternion.identity, transform);
break;
}
case CrawlerAgentBehaviorType.CrawlerDynamicVariableSpeed :

m_BehaviorParams.Model = crawlerDyVSBrain;
// SetModel("CrawlerDynamicVariableSpeed", crawlerDyVSBrain);
target = Instantiate(targetPrefab, transform.position, Quaternion.identity, transform);
m_Target = Instantiate(dynamicTargetPrefab, transform.position, Quaternion.identity, transform);
randomizeWalkSpeedEachEpisode = true;
break;
}

if(crawlerStBrain)
m_BehaviorParams.Model = crawlerStBrain;
var targetSpawnPos = transform.TransformPoint(new Vector3(0, 0, 1000));
target = Instantiate(targetPrefab, targetSpawnPos, Quaternion.identity, transform);
m_Target = Instantiate(staticTargetPrefab, targetSpawnPos, Quaternion.identity, transform);
randomizeWalkSpeedEachEpisode = false;
break;
}

if(crawlerStVSBrain)
m_BehaviorParams.Model = crawlerStVSBrain;
var targetSpawnPos = transform.TransformPoint(new Vector3(0, 0, 1000));
target = Instantiate(targetPrefab, targetSpawnPos, Quaternion.identity, transform);
m_Target = Instantiate(staticTargetPrefab, targetSpawnPos, Quaternion.identity, transform);
randomizeWalkSpeedEachEpisode = true;
break;
}

sensor.AddObservation(Quaternion.FromToRotation(body.forward, cubeForward));
//Add pos of target relative to orientation cube
sensor.AddObservation(m_OrientationCube.transform.InverseTransformPoint(target.transform.position));
sensor.AddObservation(m_OrientationCube.transform.InverseTransformPoint(m_Target.transform.position));
RaycastHit hit;
float maxRaycastDist = 10;

}
}
// /// <summary>
// /// Loop over body parts to add them to observation.
// /// </summary>
// public override void CollectObservations(VectorSensor sensor)
// {
// //Add pos of target relative to orientation cube
// sensor.AddObservation(m_OrientationCube.transform.InverseTransformPoint(target.transform.position));
//
// RaycastHit hit;
// float maxRaycastDist = 10;
// if (Physics.Raycast(body.position, Vector3.down, out hit, maxRaycastDist))
// {
// sensor.AddObservation(hit.distance / maxRaycastDist);
// }
// else
// sensor.AddObservation(1);
//
// foreach (var bodyPart in m_JdController.bodyPartsList)
// {
// CollectObservationBodyPart(bodyPart, sensor);
// }
// }
public override void OnActionReceived(ActionBuffers actionBuffers)
{
// The dictionary with all the body parts in it are in the jdController

//Update OrientationCube and DirectionIndicator
void UpdateOrientationObjects()
{
m_WorldDirToWalk = target.position - body.position;
m_OrientationCube.UpdateOrientation(body, target);
m_WorldDirToWalk = m_Target.position - body.position;
m_OrientationCube.UpdateOrientation(body, m_Target);
if (m_DirectionIndicator)
{
m_DirectionIndicator.MatchOrientation(m_OrientationCube.transform);

正在加载...
取消
保存