|
|
|
|
|
|
{ |
|
|
|
jdController = GetComponent<JointDriveController>(); |
|
|
|
currentDecisionStep = 1; |
|
|
|
dirToTarget = target.position - body.position; |
|
|
|
|
|
|
|
|
|
|
|
//Setup each body part
|
|
|
|
jdController.SetupBodyPart(body); |
|
|
|
|
|
|
public override void CollectObservations() |
|
|
|
{ |
|
|
|
jdController.GetCurrentJointForces(); |
|
|
|
// Normalize dir vector to help generalize
|
|
|
|
// Update pos to target
|
|
|
|
dirToTarget = target.position - body.position; |
|
|
|
// Forward & up to help with orientation
|
|
|
|
RaycastHit hit; |
|
|
|
if (Physics.Raycast(body.position, Vector3.down, out hit, 10.0f)) |
|
|
|
{ |
|
|
|
|
|
|
AddVectorObs(10.0f); |
|
|
|
|
|
|
|
// Forward & up to help with orientation
|
|
|
|
Vector3 bodyForwardRelativeToLookRotationToTarget = targetDirMatrix.inverse.MultiplyVector(body.forward); |
|
|
|
AddVectorObs(bodyForwardRelativeToLookRotationToTarget); |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Update pos to target
|
|
|
|
dirToTarget = target.position - jdController.bodyPartsDict[body].rb.position; |
|
|
|
|
|
|
|
// If enabled the feet will light up green when the foot is grounded.
|
|
|
|
// This is just a visualization and isn't necessary for function
|
|
|
|