浏览代码

ready for training

/docs-update
Hunter-Unity 5 年前
当前提交
b7ce8a65
共有 3 个文件被更改,包括 42 次插入35 次删除
  1. 2
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/AvgCenterOfMass.cs
  2. 2
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPairDynamic.prefab
  3. 73
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgentDynamic.cs

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


public bool showInverseTransformVectorRelToBody;
public bool showInverseTransformDirRelToBody;
public Transform body_T;
void Start()
void OnEnable()
{
SetUpRigidbodies();
}

2
Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPairDynamic.prefab


m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
VectorObservationSize: 223
VectorObservationSize: 224
NumStackedVectorObservations: 1
VectorActionSize: 27000000
VectorActionDescriptions: []

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


// Update pos to target
// m_WalkDir = target.position - hips.position;
m_WalkDir = target.position - m_OrientationCube.transform.position;
// m_WalkDir = target.position - m_OrientationCube.transform.position;
m_WalkDirLookRot = Quaternion.LookRotation(m_WalkDir);
// m_WalkDirLookRot = Quaternion.LookRotation(m_WalkDir);
sensor.AddObservation(RagdollHelpers.GetRotationDelta(m_WalkDirLookRot, head.rotation));
//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;

//HIP POS REL TO MATRIX
// sensor.AddObservation(hips.position - worldPosMatrixPos);
sensor.AddObservation(hips.position - m_OrientationCube.transform.position);
// sensor.AddObservation(hips.position - m_OrientationCube.transform.position);
// sensor.AddObservation(m_JdController.bodyPartsDict[hips].rb.position);
// sensor.AddObservation(hips.forward);

CollectObservationBodyPart(bodyPart, sensor);
}
// Set reward for this step according to mixture of the following elements.
// a. Velocity alignment with goal direction.
// b. Rotation alignment with goal direction.
// c. Encourage head height.
// d. Discourage head movement.
m_WalkDir = target.position - m_OrientationCube.transform.position;
AddReward(
+0.03f * Vector3.Dot(m_WalkDir.normalized, m_JdController.bodyPartsDict[hips].rb.velocity)
+ 0.01f * Quaternion.Dot(m_OrientationCube.transform.rotation, hips.rotation)
+ 0.02f * (head.position.y - hips.position.y)
- 0.01f * Vector3.Distance(m_JdController.bodyPartsDict[head].rb.velocity,
m_JdController.bodyPartsDict[hips].rb.velocity)
);
}
public override void OnActionReceived(float[] vectorAction)

bpDict[forearmR].SetJointStrength(vectorAction[++i]);
}
// void FixedUpdate()
// {
void FixedUpdate()
{
//UPDATE ORIENTATION CUBE POS & ROT
Vector3 oCubePos = hips.position;
oCubePos.y = -.45f;
m_OrientationCube.transform.position = oCubePos;
m_OrientationCube.transform.rotation = m_WalkDirLookRot;
// Set reward for this step according to mixture of the following elements.
// a. Velocity alignment with goal direction.
// b. Rotation alignment with goal direction.
// c. Encourage head height.
// d. Discourage head movement.
m_WalkDir = target.position - m_OrientationCube.transform.position;
AddReward(
+0.02f * Vector3.Dot(m_WalkDir.normalized, m_JdController.bodyPartsDict[hips].rb.velocity)
+ 0.01f * Quaternion.Dot(m_OrientationCube.transform.rotation, hips.rotation)
+ 0.01f * Quaternion.Dot(m_OrientationCube.transform.rotation, head.rotation)
+ 0.02f * (head.position.y - hips.position.y)
- 0.01f * Vector3.Distance(m_JdController.bodyPartsDict[head].rb.velocity,
m_JdController.bodyPartsDict[hips].rb.velocity)
);
// // Set reward for this step according to mixture of the following elements.
// // a. Velocity alignment with goal direction.
// // b. Rotation alignment with goal direction.

// - 0.01f * Vector3.Distance(m_JdController.bodyPartsDict[head].rb.velocity,
// m_JdController.bodyPartsDict[hips].rb.velocity)
// );
//
//// 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)
//// );
// }
// 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>
/// Loop over body parts and reset them to initial conditions.

正在加载...
取消
保存