浏览代码

Reset Parameters implemented for Pushblock, Reacher and Walker (#2322)

Pushblock: dynamic_friction, static_friction, block_drag, block_scale
Reacher: Gravity, non-linear goal movement
Walker: Gravity, torso mass
/develop-generalizationTraining-TrainerController
Ervin T 5 年前
当前提交
dba466e3
共有 15 个文件被更改,包括 204 次插入30 次删除
  1. 3
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab
  2. 3
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/StudentArea.prefab
  3. 3
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/TeacherArea.prefab
  4. 3
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/VisualArea.prefab
  5. 10
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlock.unity
  6. 15
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockIL.unity
  7. 10
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/VisualPushBlock.unity
  8. 31
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs
  9. 10
      UnitySDK/Assets/ML-Agents/Examples/Reacher/Scenes/Reacher.unity
  10. 9
      UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAcademy.cs
  11. 40
      UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs
  12. 10
      UnitySDK/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity
  13. 1
      UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs
  14. 28
      UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
  15. 58
      docs/Learning-Environment-Examples.md

3
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1500989011945850}
m_Material: {fileID: 0}
m_Material: {fileID: 13400000, guid: f440cd475293044139739aff331224fb, type: 2}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2

brain: {fileID: 11400000, guid: e8b2d719f6a324b1abb68d8cf2859f5c, type: 2}
agentParameters:
agentCameras: []
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

3
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/StudentArea.prefab


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1132847330634378}
m_Material: {fileID: 0}
m_Material: {fileID: 13400000, guid: f440cd475293044139739aff331224fb, type: 2}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2

brain: {fileID: 11400000, guid: e8b2d719f6a324b1abb68d8cf2859f5c, type: 2}
agentParameters:
agentCameras: []
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

3
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/TeacherArea.prefab


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1492788814869846}
m_Material: {fileID: 0}
m_Material: {fileID: 13400000, guid: f440cd475293044139739aff331224fb, type: 2}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2

brain: {fileID: 11400000, guid: dd07b1953eac4411b81fba032f394726, type: 2}
agentParameters:
agentCameras: []
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

3
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/VisualArea.prefab


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1553741088268304}
m_Material: {fileID: 0}
m_Material: {fileID: 13400000, guid: f440cd475293044139739aff331224fb, type: 2}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2

agentParameters:
agentCameras:
- {fileID: 20223756300728806}
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

10
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlock.unity


timeScale: 1
targetFrameRate: 60
resetParameters:
resetParameters: []
resetParameters:
- key: dynamic_friction
value: 0
- key: static_friction
value: 0
- key: block_drag
value: 0.5
- key: block_scale
value: 2
agentRunSpeed: 2
agentRotationSpeed: 15
spawnAreaMarginMultiplier: 0.5

15
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockIL.unity


propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 65880592586321730, guid: bed6005cc2a1a47edafba27cde6b5538,
type: 2}
propertyPath: m_Material
value:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: bed6005cc2a1a47edafba27cde6b5538, type: 2}
m_IsPrefabParent: 0

timeScale: 1
targetFrameRate: 60
resetParameters:
resetParameters: []
resetParameters:
- key: dynamic_friction
value: 0
- key: static_friction
value: 0
- key: block_drag
value: 0.5
- key: block_scale
value: 2
agentRunSpeed: 2
agentRotationSpeed: 15
spawnAreaMarginMultiplier: 0.5

10
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/VisualPushBlock.unity


timeScale: 1
targetFrameRate: 60
resetParameters:
resetParameters: []
resetParameters:
- key: dynamic_friction
value: 0
- key: static_friction
value: 0
- key: block_drag
value: 0.5
- key: block_scale
value: 2
agentRunSpeed: 2
agentRotationSpeed: 15
spawnAreaMarginMultiplier: 0.5

31
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs


groundRenderer = ground.GetComponent<Renderer>();
// Starting material
groundMaterial = groundRenderer.material;
SetResetParameters();
}
public override void CollectObservations()

transform.position = GetRandomSpawnPos();
agentRB.velocity = Vector3.zero;
agentRB.angularVelocity = Vector3.zero;
SetResetParameters();
}
public void SetGroundMaterialFriction()
{
var resetParams = academy.resetParameters;
var groundCollider = ground.GetComponent<Collider>() as Collider;
groundCollider.material.dynamicFriction = resetParams["dynamic_friction"];
groundCollider.material.staticFriction = resetParams["static_friction"];
}
public void SetBlockProperties()
{
var resetParams = academy.resetParameters;
//Set the scale of the block
blockRB.transform.localScale = new Vector3(resetParams["block_scale"], 0.75f, resetParams["block_scale"]);
// Set the drag of the block
blockRB.drag = resetParams["block_drag"];
}
public void SetResetParameters()
{
SetGroundMaterialFriction();
SetBlockProperties();
}
}

10
UnitySDK/Assets/ML-Agents/Examples/Reacher/Scenes/Reacher.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 762086411}
m_IndirectSpecularColor: {r: 0.4465934, g: 0.49642956, b: 0.5748249, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.49641287, b: 0.5748173, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

value: 5
- key: goal_speed
value: 1
goalSize: 5
goalSpeed: 1
- key: gravity
value: 9.81
- key: deviation
value: 0
- key: deviation_freq
value: 0
--- !u!4 &1574236049
Transform:
m_ObjectHideFlags: 0

9
UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAcademy.cs


using UnityEngine;
using MLAgents;
public class ReacherAcademy : Academy {
public float goalSize;
public float goalSpeed;
public class ReacherAcademy : Academy
{
goalSize = (float)resetParameters["goal_size"];
goalSpeed = (float)resetParameters["goal_speed"];
Physics.gravity = new Vector3(0, -resetParameters["gravity"], 0);
}
public override void AcademyStep()

40
UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs


using UnityEngine;
using MLAgents;
public class ReacherAgent : Agent {
public class ReacherAgent : Agent
{
public GameObject pendulumA;
public GameObject pendulumB;

float goalDegree;
private Rigidbody rbA;
private Rigidbody rbB;
// speed of the goal zone around the arm (in radians)
// radius of the goal zone
// Magnitude of sinusoidal (cosine) deviation of the goal along the vertical dimension
private float deviation;
// Frequency of the cosine deviation of the goal along the vertical dimension
private float deviationFreq;
/// Collect the rigidbodies of the reacher in order to resue them for
/// Collect the rigidbodies of the reacher in order to resue them for
/// observations and actions.
/// </summary>
public override void InitializeAgent()

myAcademy = GameObject.Find("Academy").GetComponent<ReacherAcademy>();
SetResetParameters();
}
/// <summary>

AddVectorObs(goal.transform.localPosition);
AddVectorObs(hand.transform.localPosition);
}
}
{
{
goalDegree += goalSpeed;
UpdateGoalPosition();

torqueX = Mathf.Clamp(vectorAction[2], -1f, 1f) * 150f;
torqueZ = Mathf.Clamp(vectorAction[3], -1f, 1f) * 150f;
rbB.AddTorque(new Vector3(torqueX, 0f, torqueZ));
}
}
void UpdateGoalPosition()
void UpdateGoalPosition()
goal.transform.position = new Vector3(goalY, -1f, goalX) + transform.position;
var goalZ = deviation * Mathf.Cos(deviationFreq * radians);
goal.transform.position = new Vector3(goalY, goalZ, goalX) + transform.position;
}
/// <summary>

goalDegree = Random.Range(0, 360);
UpdateGoalPosition();
goalSize = myAcademy.goalSize;
goalSpeed = Random.Range(-1f, 1f) * myAcademy.goalSpeed;
SetResetParameters();
}
public void SetResetParameters()
{
goalSize = myAcademy.resetParameters["goal_size"];
goalSpeed = Random.Range(-1f, 1f) * myAcademy.resetParameters["goal_speed"];
deviation = myAcademy.resetParameters["deviation"];
deviationFreq = myAcademy.resetParameters["deviation_freq"];
}
}

10
UnitySDK/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity


timeScale: 1
targetFrameRate: 60
resetParameters:
resetParameters: []
resetParameters:
- key: gravity
value: 9.81
- key: hip_mass
value: 15
- key: chest_mass
value: 8
- key: spine_mass
value: 10
--- !u!4 &1409355322
Transform:
m_ObjectHideFlags: 0

1
UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs


public override void AcademyReset()
{
Physics.gravity = new Vector3(0, -resetParameters["gravity"], 0);
}
public override void AcademyStep()

28
UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs


bool isNewDecisionStep;
int currentDecisionStep;
private Rigidbody hipsRb;
private Rigidbody chestRb;
private Rigidbody spineRb;
private ResetParameters resetParams;
public override void InitializeAgent()
{
jdController = GetComponent<JointDriveController>();

jdController.SetupBodyPart(armR);
jdController.SetupBodyPart(forearmR);
jdController.SetupBodyPart(handR);
hipsRb = hips.GetComponent<Rigidbody>();
chestRb = chest.GetComponent<Rigidbody>();
spineRb = spine.GetComponent<Rigidbody>();
var academy = FindObjectOfType<WalkerAcademy>() as WalkerAcademy;
resetParams = academy.resetParameters;
SetResetParameters();
}
/// <summary>

isNewDecisionStep = true;
currentDecisionStep = 1;
SetResetParameters();
}
public void SetTorsoMass()
{
chestRb.mass = resetParams["chest_mass"];
spineRb.mass = resetParams["spine_mass"];
hipsRb.mass = resetParams["hip_mass"];
}
public void SetResetParameters()
{
SetTorsoMass();
}
}

58
docs/Learning-Environment-Examples.md


`VisualPushBlock` scene. __The visual observation version of
this environment does not train with the provided default
training parameters.__
* Reset Parameters: None.
* Reset Parameters: Four, corresponding to the following:
* block_scale: Scale of the block along the x and z dimensions
* Default: 2
* Recommended Minimum: 0.5
* Recommended Maximum: 4
* dynamic_friction: Coefficient of friction for the ground material acting on moving objects
* Default: 0
* Recommended Minimum: 0
* Recommended Maximum: 1
* static_friction: Coefficient of friction for the ground material acting on stationary objects
* Default: 0
* Recommended Minimum: 0
* Recommended Maximum: 1
* block_drag: Effect of air resistance on block
* Default: 0.5
* Recommended Minimum: 0
* Recommended Maximum: 2000
* Benchmark Mean Reward: 4.5
* Optional Imitation Learning scene: `PushBlockIL`.

* Vector Action space: (Continuous) Size of 4, corresponding to torque
applicable to two joints.
* Visual Observations: None.
* Reset Parameters: Two, corresponding to goal size, and goal movement speed.
* Reset Parameters: Five, corresponding to the following
* goal_size: radius of the goal zone
* Default: 5
* Recommended Minimum: 1
* Recommended Maximum: 10
* goal_speed: speed of the goal zone around the arm (in radians)
* Default: 1
* Recommended Minimum: 0.2
* Recommended Maximum: 4
* gravity
* Default: 9.81
* Recommended Minimum: 4
* Recommended Maximum: 20
* deviation: Magnitude of sinusoidal (cosine) deviation of the goal along the vertical dimension
* Default: 0
* Recommended Minimum: 0
* Recommended Maximum: 5
* deviation_freq: Frequency of the cosine deviation of the goal along the vertical dimension
* Default: 0
* Recommended Minimum: 0
* Recommended Maximum: 3
* Benchmark Mean Reward: 30
## [Crawler](https://youtu.be/ftLliaeooYI)

* Vector Action space: (Continuous) Size of 39, corresponding to target
rotations applicable to the joints.
* Visual Observations: None.
* Reset Parameters: None.
* Reset Parameters: Four, corresponding to the following
* gravity: Magnitude of gravity
* Default: 9.81
* Recommended Minimum:
* Recommended Maximum:
* hip_mass: Mass of the hip component of the walker
* Default: 15
* Recommended Minimum: 7
* Recommended Maximum: 28
* chest_mass: Mass of the chest component of the walker
* Default: 8
* Recommended Minimum: 3
* Recommended Maximum: 20
* spine_mass: Mass of the spine component of the walker
* Default: 10
* Recommended Minimum: 3
* Recommended Maximum: 20
* Benchmark Mean Reward: 1000
## Pyramids

正在加载...
取消
保存