浏览代码

oCube spawining works. ready to train

/docs-update
Hunter-Unity 5 年前
当前提交
b60cd47c
共有 13 个文件被更改,包括 1036 次插入809 次删除
  1. 1
      .gitignore
  2. 4
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/AvgCenterOfMass.cs
  3. 789
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPairDynamic.prefab
  4. 959
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamic.unity
  5. 66
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgentDynamic.cs
  6. 2
      Project/ProjectSettings/DynamicsManager.asset
  7. 2
      Project/ProjectSettings/ProjectVersion.txt
  8. 6
      Project/Assets/ML-Agents/Examples/SharedAssets/Resources/OrientationCube.prefab
  9. 8
      Project/Assets/ML-Agents/Examples/SharedAssets/Resources.meta
  10. 8
      Project/ProjectSettings/NetworkManager.asset
  11. 0
      /Project/Assets/ML-Agents/Examples/SharedAssets/Resources/OrientationCube.prefab
  12. 0
      /Project/Assets/ML-Agents/Examples/SharedAssets/Resources/OrientationCube.prefab.meta

1
.gitignore


# Python virtual environment
venv/
venv1_0/
.mypy_cache/
# Code coverage report

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
// }
// }
void FixedUpdate()
{
if(Application.isPlaying)

if (showInverseTransformPointUnscaledRelToBody)
{
// Debug.DrawRay(body_T.position + body_T.InverseTransformPoint(rb.position), Vector3.up, Color.red,Time.fixedDeltaTime);
Debug.DrawRay(body_T.position + body_T.InverseTransformPointUnscaled(rb.position), Vector3.up, Color.red,Time.fixedDeltaTime);
// Debug.DrawRay(body_T.position + body_T.InverseTransformPointUnscaled(rb.position), Vector3.up, Color.red,Time.fixedDeltaTime);
Debug.DrawRay(body_T.position + body_T.InverseTransformPointUnscaled(rb.transform.position), Vector3.up, Color.red,Time.fixedDeltaTime);
}
if (showInverseTransformPointRelToBody)
{

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

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

66
Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgentDynamic.cs


EnvironmentParameters m_ResetParams;
private GameObject m_OrientationCube;
Vector3 oCubePos = hips.position;
oCubePos.y = -.45f;
m_OrientationCube = Instantiate(Resources.Load<GameObject>("OrientationCube"), oCubePos, Quaternion.identity);
m_OrientationCube.transform.SetParent(transform);
var texture = Resources.Load<Texture2D>("Textures/texture01");
m_JdController = GetComponent<JointDriveController>();
m_JdController.SetupBodyPart(hips);
m_JdController.SetupBodyPart(chest);

//GROUND CHECK
sensor.AddObservation(bp.groundContact.touchingGround ? 1 : 0); // Is this bp touching the ground
//RELATIVE RB VELOCITY
var velocityRelativeToLookRotationToTarget = m_worldPosMatrix.inverse.MultiplyVector(bp.rb.velocity);
sensor.AddObservation(velocityRelativeToLookRotationToTarget);
// //RELATIVE RB VELOCITY
// var velocityRelativeToLookRotationToTarget = m_worldPosMatrix.inverse.MultiplyVector(bp.rb.velocity);
// sensor.AddObservation(velocityRelativeToLookRotationToTarget);
//
// //RELATIVE RB ANGULAR VELOCITY
// var angularVelocityRelativeToLookRotationToTarget = m_worldPosMatrix.inverse.MultiplyVector(bp.rb.angularVelocity);
// sensor.AddObservation(angularVelocityRelativeToLookRotationToTarget);
//RELATIVE RB ANGULAR VELOCITY
var angularVelocityRelativeToLookRotationToTarget = m_worldPosMatrix.inverse.MultiplyVector(bp.rb.angularVelocity);
sensor.AddObservation(angularVelocityRelativeToLookRotationToTarget);
//RELATIVE RB VELOCITIES
sensor.AddObservation(m_OrientationCube.transform.InverseTransformVector(bp.rb.velocity));
sensor.AddObservation(m_OrientationCube.transform.InverseTransformVector(bp.rb.angularVelocity));
// sensor.AddObservation(rb.velocity);
// sensor.AddObservation(rb.angularVelocity);

m_JdController.GetCurrentJointForces();
// Update pos to target
m_WalkDir = target.position - hips.position;
// m_WalkDir = target.position - hips.position;
m_WalkDir = target.position - m_OrientationCube.transform.position;
//FACING DIR
m_WalkDirLookRot = Quaternion.LookRotation(m_WalkDir);

//ORIENTATION MATRIX
Vector3 worldPosMatrixPos = hips.position;
worldPosMatrixPos.y = .5f;
m_worldPosMatrix = Matrix4x4.TRS(worldPosMatrixPos, Quaternion.identity, Vector3.one);
//UPDATE ORIENTATION CUBE POS & ROT
Vector3 oCubePos = hips.position;
oCubePos.y = -.45f;
m_OrientationCube.transform.position = oCubePos;
m_OrientationCube.transform.rotation = m_WalkDirLookRot;
//HIP RAYCAST FOR HEIGHT
RaycastHit hit;
if (Physics.Raycast(hips.position, Vector3.down, out hit, 10.0f))
{
sensor.AddObservation(hit.distance);
}
else
sensor.AddObservation(10.0f);
// //ORIENTATION MATRIX
// Vector3 worldPosMatrixPos = hips.position;
// worldPosMatrixPos.y = .5f;
// m_worldPosMatrix = Matrix4x4.TRS(worldPosMatrixPos, Quaternion.identity, Vector3.one);
sensor.AddObservation(hips.position - worldPosMatrixPos);
// sensor.AddObservation(hips.position - worldPosMatrixPos);
sensor.AddObservation(hips.position - m_OrientationCube.transform.position);
// sensor.AddObservation(m_JdController.bodyPartsDict[hips].rb.position);
// sensor.AddObservation(hips.forward);

// b. Rotation alignment with goal direction.
// c. Encourage head height.
// d. Discourage head movement.
m_WalkDir = target.position - m_JdController.bodyPartsDict[hips].rb.position;
m_WalkDir = target.position - m_OrientationCube.transform.position;
+ 0.01f * Vector3.Dot(m_WalkDir.normalized, hips.forward)
+ 0.01f * Quaternion.Dot(m_OrientationCube.transform.rotation, hips.rotation)
// m_WalkDir = target.position - m_JdController.bodyPartsDict[hips].rb.position;
// AddReward(
// +0.03f * Vector3.Dot(m_WalkDir.normalized, m_JdController.bodyPartsDict[hips].rb.velocity)
// + 0.01f * Vector3.Dot(m_WalkDir.normalized, hips.forward)
// + 0.02f * (head.position.y - hips.position.y)
// - 0.01f * Vector3.Distance(m_JdController.bodyPartsDict[head].rb.velocity,
// m_JdController.bodyPartsDict[hips].rb.velocity)
// );
}
/// <summary>

2
Project/ProjectSettings/DynamicsManager.asset


m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffebffffffddffffffeffffffff5fffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_AutoSimulation: 1
m_AutoSyncTransforms: 1
m_ReuseCollisionCallbacks: 0
m_ReuseCollisionCallbacks: 1
m_ClothInterCollisionSettingsToggle: 0
m_ContactPairsMode: 0
m_BroadphaseType: 0

2
Project/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2018.4.17f1
m_EditorVersion: 2018.4.18f1

6
Project/Assets/ML-Agents/Examples/SharedAssets/Resources/OrientationCube.prefab


m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2591864627374185740}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.012, y: 0.10131, z: 0}
m_LocalRotation: {x: -0, y: -0.7071066, z: -0, w: 0.707107}
m_LocalPosition: {x: 0.08911133, y: 0.101310015, z: -0.07713318}
m_LocalScale: {x: 0.7764428, y: 0.7764428, z: 0.7764428}
m_Children:
- {fileID: 3256674261123397973}

m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: -90.00001, z: 0}
--- !u!1 &3258603775602446353
GameObject:
m_ObjectHideFlags: 0

8
Project/Assets/ML-Agents/Examples/SharedAssets/Resources.meta


fileFormatVersion: 2
guid: 3b63a14f8a9a948358ebb9db367bf43f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Project/ProjectSettings/NetworkManager.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!149 &1
NetworkManager:
m_ObjectHideFlags: 0
m_DebugLevel: 0
m_Sendrate: 15
m_AssetToPrefab: {}

/Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/OrientationCube.prefab → /Project/Assets/ML-Agents/Examples/SharedAssets/Resources/OrientationCube.prefab

/Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/OrientationCube.prefab.meta → /Project/Assets/ML-Agents/Examples/SharedAssets/Resources/OrientationCube.prefab.meta

正在加载...
取消
保存