浏览代码

added trained 6 leg creature

/hh-develop-gridsensor-tests/static
HH 4 年前
当前提交
4d720feb
共有 17 个文件被更改,包括 5879 次插入269 次删除
  1. 999
      Project/Assets/ML-Agents/Examples/Crawler/Prefabs/CreaturePlatform.prefab
  2. 950
      Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerGRAVEYARD.unity
  3. 74
      Project/Assets/ML-Agents/Examples/Crawler/Scripts/CreatureAgent.cs
  4. 16
      Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/Targets/DynamicTarget.prefab
  5. 4
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/AvgCenterOfMass.cs
  6. 7
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs
  7. 7
      Project/Assets/ML-Agents/Examples/WallJump/Materials/spawnVolumeMaterial.mat
  8. 1001
      Project/Assets/ML-Agents/Examples/Crawler/TFModels/CrawlerDynamicVariableSpeedUpsideDownPenGroundPen.nn
  9. 11
      Project/Assets/ML-Agents/Examples/Crawler/TFModels/CrawlerDynamicVariableSpeedUpsideDownPenGroundPen.nn.meta
  10. 1001
      Project/Assets/ML-Agents/Examples/Crawler/TFModels/Creature6Legs.nn
  11. 11
      Project/Assets/ML-Agents/Examples/Crawler/TFModels/Creature6Legs.nn.meta
  12. 1001
      Project/Assets/ML-Agents/Examples/Crawler/TFModels/Creature6LegsOld.nn
  13. 11
      Project/Assets/ML-Agents/Examples/Crawler/TFModels/Creature6LegsOld.nn.meta
  14. 1001
      Project/Assets/ML-Agents/Examples/Crawler/TFModels/CreatureMaster.nn
  15. 11
      Project/Assets/ML-Agents/Examples/Crawler/TFModels/CreatureMaster.nn.meta
  16. 32
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RandomTorqueEveryXSec.cs
  17. 11
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RandomTorqueEveryXSec.cs.meta

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

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

74
Project/Assets/ML-Agents/Examples/Crawler/Scripts/CreatureAgent.cs


//The walking speed to try and achieve
private float m_TargetWalkingSpeed = m_maxWalkingSpeed;
const float m_minWalkingSpeed = 5; //The max walking speed
const float m_minWalkingSpeed = .01f; //The max walking speed
const float m_maxWalkingSpeed = 15; //The max walking speed
//The current target walking speed. Clamped because a value of zero will cause NaNs

public Transform m_Target; //Target the agent will walk towards during training.
[Header("Body Parts")] [Space(10)] public Transform body;
public Transform bodyMiddle;
public Transform body1;
public Transform leg0Upper;
public Transform leg0Lower;
public Transform leg1Upper;

public Transform leg3Upper;
public Transform leg3Lower;
public Transform leg4Upper;
public Transform leg4Lower;
public Transform leg5Upper;
public Transform leg5Lower;
//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

//Setup each body part
m_JdController.SetupBodyPart(body);
m_JdController.SetupBodyPart(bodyMiddle, false);
m_JdController.SetupBodyPart(body1, false);
m_JdController.SetupBodyPart(leg0Upper);
m_JdController.SetupBodyPart(leg0Lower);
m_JdController.SetupBodyPart(leg1Upper);

m_JdController.SetupBodyPart(leg3Upper);
m_JdController.SetupBodyPart(leg3Lower);
m_JdController.SetupBodyPart(leg4Upper);
m_JdController.SetupBodyPart(leg4Lower);
m_JdController.SetupBodyPart(leg5Upper);
m_JdController.SetupBodyPart(leg5Lower);
}
/// <summary>

//Add pos of target relative to orientation cube
sensor.AddObservation(m_OrientationCube.transform.InverseTransformPoint(m_Target.transform.position));
// RaycastHit hit;
// float maxRaycastDist = 10;
//// if (Physics.Raycast(body.position, Vector3.down, out hit, maxRaycastDist))
// if (Physics.Raycast(body.position, -body.up, out hit, maxRaycastDist))
// {
// sensor.AddObservation(hit.distance / maxRaycastDist);
// }
// else
// sensor.AddObservation(1);
RaycastHit hit;
float maxRaycastDist = 10;
// if (Physics.Raycast(body.position, Vector3.down, out hit, maxRaycastDist))
if (Physics.Raycast(body.position, -body.up, out hit, maxRaycastDist))
{
sensor.AddObservation(hit.distance / maxRaycastDist);
}
else
sensor.AddObservation(1);
foreach (var bodyPart in m_JdController.bodyPartsList)
{

bpDict[leg1Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
bpDict[leg2Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
bpDict[leg3Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
bpDict[leg4Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
bpDict[leg5Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
bpDict[leg4Lower].SetJointTargetRotation(continuousActions[++i], 0, 0);
bpDict[leg5Lower].SetJointTargetRotation(continuousActions[++i], 0, 0);
// Update joint strength
bpDict[leg0Upper].SetJointStrength(continuousActions[++i]);

bpDict[leg4Upper].SetJointStrength(continuousActions[++i]);
bpDict[leg5Upper].SetJointStrength(continuousActions[++i]);
bpDict[leg4Lower].SetJointStrength(continuousActions[++i]);
bpDict[leg5Lower].SetJointStrength(continuousActions[++i]);
//Reset if Worm fell through floor;
if (body.position.y < m_StartingPos.y - 5)

}
// public override void OnActionReceived(ActionBuffers actionBuffers)
// {
// // The dictionary with all the body parts in it are in the jdController
// var bpDict = m_JdController.bodyPartsDict;
//
// var continuousActions = actionBuffers.ContinuousActions;
// var i = -1;
// // Pick a new target joint rotation
// bpDict[leg0Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
// bpDict[leg1Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
// bpDict[leg2Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
// bpDict[leg3Upper].SetJointTargetRotation(continuousActions[++i], continuousActions[++i], 0);
// bpDict[leg0Lower].SetJointTargetRotation(continuousActions[++i], 0, 0);
// bpDict[leg1Lower].SetJointTargetRotation(continuousActions[++i], 0, 0);
// bpDict[leg2Lower].SetJointTargetRotation(continuousActions[++i], 0, 0);
// bpDict[leg3Lower].SetJointTargetRotation(continuousActions[++i], 0, 0);
//
// // Update joint strength
// bpDict[leg0Upper].SetJointStrength(continuousActions[++i]);
// bpDict[leg1Upper].SetJointStrength(continuousActions[++i]);
// bpDict[leg2Upper].SetJointStrength(continuousActions[++i]);
// bpDict[leg3Upper].SetJointStrength(continuousActions[++i]);
// bpDict[leg0Lower].SetJointStrength(continuousActions[++i]);
// bpDict[leg1Lower].SetJointStrength(continuousActions[++i]);
// bpDict[leg2Lower].SetJointStrength(continuousActions[++i]);
// bpDict[leg3Lower].SetJointStrength(continuousActions[++i]);
//
// //Reset if Worm fell through floor;
// if (body.position.y < m_StartingPos.y - 5)
// {
// EndEpisode();
// }
// }
// public override void OnActionReceived(ActionBuffers actionBuffers)
// {
// // The dictionary with all the body parts in it are in the jdController

16
Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/Targets/DynamicTarget.prefab


- component: {fileID: 3826955612593018128}
- component: {fileID: 3858402326794362026}
- component: {fileID: 3631016866778687563}
- component: {fileID: 114455976044412662}
m_Layer: 0
m_Name: DynamicTarget
m_TagString: target

onCollisionExitEvent:
m_PersistentCalls:
m_Calls: []
--- !u!114 &114455976044412662
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: 1d08fceed19554884bcef5f0c316ca2d, type: 3}
m_Name:
m_EditorClassIdentifier:
maxTorque: {x: 111, y: 111, z: 0}
randomizeTorqueEveryXSec: 10
forceMode: 0

4
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/AvgCenterOfMass.cs


// avgCOMWorldSpace /= rbList.Count; //divide by num of rb's to get avg in WORLD space
float avgCOMRadius = 0.5f; //radius of gizmo
Gizmos.color = avgCOMColor;
Gizmos.DrawSphere(avgCOMWorldSpace, avgCOMRadius);
Gizmos.DrawWireSphere(avgCOMWorldSpace, avgCOMRadius);
}
}
else

// avgCOMWorldSpace /= rbList.Count; //divide by num of rb's to get avg in WORLD space
float avgCOMGizmoRadius = 0.5f; //radius of gizmo
Gizmos.color = avgCOMColor;
Gizmos.DrawSphere(avgCOMWorldSpace, avgCOMGizmoRadius);
Gizmos.DrawWireSphere(avgCOMWorldSpace, avgCOMGizmoRadius);

7
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs


/// <summary>
/// Create BodyPart object and add it to dictionary.
/// </summary>
public void SetupBodyPart(Transform t)
// public void SetupBodyPart(Transform t)
public void SetupBodyPart(Transform t, bool includeJoint = true)
{
var bp = new BodyPart
{

startingRot = t.rotation
};
if (!includeJoint)
{
bp.joint = null;
}
bp.rb.maxAngularVelocity = k_MaxAngularVelocity;
// Add & setup the ground contact script

7
Project/Assets/ML-Agents/Examples/WallJump/Materials/spawnVolumeMaterial.mat


Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: spawnVolumeMaterial
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHABLEND_ON

- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 0, g: 0.83448315, b: 1, a: 0.303}
- _Color: {r: 0, g: 0.568055, b: 0.77254903, a: 0.303}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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

11
Project/Assets/ML-Agents/Examples/Crawler/TFModels/CrawlerDynamicVariableSpeedUpsideDownPenGroundPen.nn.meta


fileFormatVersion: 2
guid: b3d07320d22564caca58080db23a0e90
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj
11400002: model data
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 19ed1486aa27d4903b34839f37b8f69f, type: 3}

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

11
Project/Assets/ML-Agents/Examples/Crawler/TFModels/Creature6Legs.nn.meta


fileFormatVersion: 2
guid: f658581214f5a446986ebfa0de5884d6
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj
11400002: model data
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 19ed1486aa27d4903b34839f37b8f69f, type: 3}

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

11
Project/Assets/ML-Agents/Examples/Crawler/TFModels/Creature6LegsOld.nn.meta


fileFormatVersion: 2
guid: 873e61595007a498081e505cf9c05a2e
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj
11400002: model data
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 19ed1486aa27d4903b34839f37b8f69f, type: 3}

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

11
Project/Assets/ML-Agents/Examples/Crawler/TFModels/CreatureMaster.nn.meta


fileFormatVersion: 2
guid: 4ed852db9b6714c93833898bc7e91f54
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj
11400002: model data
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 19ed1486aa27d4903b34839f37b8f69f, type: 3}

32
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RandomTorqueEveryXSec.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomTorqueEveryXSec : MonoBehaviour
{
public Vector3 maxTorque;
private Vector3 torqueToUse;
public float randomizeTorqueEveryXSec = 10;
public ForceMode forceMode;
private Rigidbody rb;
// Start is called before the first frame update
void OnEnable()
{
rb = GetComponent<Rigidbody>();
InvokeRepeating("SetRandomTorque", 0, randomizeTorqueEveryXSec);
}
void SetRandomTorque()
{
torqueToUse = new Vector3(Random.Range(-maxTorque.x, maxTorque.x), Random.Range(-maxTorque.y, maxTorque.y),
Random.Range(-maxTorque.z, maxTorque.z));
}
// Update is called once per frame
void FixedUpdate()
{
rb.AddRelativeTorque(torqueToUse, forceMode);
}
}

11
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RandomTorqueEveryXSec.cs.meta


fileFormatVersion: 2
guid: 1d08fceed19554884bcef5f0c316ca2d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存