diff --git a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab index 0357bfa2ee..4246a53459 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab +++ b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab @@ -838,7 +838,7 @@ BoxCollider: 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 @@ -905,6 +905,7 @@ MonoBehaviour: brain: {fileID: 11400000, guid: e8b2d719f6a324b1abb68d8cf2859f5c, type: 2} agentParameters: agentCameras: [] + agentRenderTextures: [] maxStep: 5000 resetOnDone: 1 onDemandDecision: 0 diff --git a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/StudentArea.prefab b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/StudentArea.prefab index 1d518d4234..d8ffc62dc9 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/StudentArea.prefab +++ b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/StudentArea.prefab @@ -790,7 +790,7 @@ BoxCollider: 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 @@ -905,6 +905,7 @@ MonoBehaviour: brain: {fileID: 11400000, guid: e8b2d719f6a324b1abb68d8cf2859f5c, type: 2} agentParameters: agentCameras: [] + agentRenderTextures: [] maxStep: 5000 resetOnDone: 1 onDemandDecision: 0 diff --git a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/TeacherArea.prefab b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/TeacherArea.prefab index 6b9bfe7ed6..94a0da4238 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/TeacherArea.prefab +++ b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/TeacherArea.prefab @@ -791,7 +791,7 @@ BoxCollider: 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 @@ -919,6 +919,7 @@ MonoBehaviour: brain: {fileID: 11400000, guid: dd07b1953eac4411b81fba032f394726, type: 2} agentParameters: agentCameras: [] + agentRenderTextures: [] maxStep: 5000 resetOnDone: 1 onDemandDecision: 0 diff --git a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/VisualArea.prefab b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/VisualArea.prefab index 7f35e22ef2..355c957683 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/VisualArea.prefab +++ b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/VisualArea.prefab @@ -870,7 +870,7 @@ BoxCollider: 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 @@ -970,6 +970,7 @@ MonoBehaviour: agentParameters: agentCameras: - {fileID: 20223756300728806} + agentRenderTextures: [] maxStep: 5000 resetOnDone: 1 onDemandDecision: 0 diff --git a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlock.unity b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlock.unity index 7b5c639ab6..66dce0ad69 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlock.unity +++ b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlock.unity @@ -1570,7 +1570,15 @@ MonoBehaviour: 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 diff --git a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockIL.unity b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockIL.unity index 4b732c14ba..99b839a12f 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockIL.unity +++ b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockIL.unity @@ -339,6 +339,11 @@ Prefab: 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 @@ -552,7 +557,15 @@ MonoBehaviour: 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 diff --git a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/VisualPushBlock.unity b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/VisualPushBlock.unity index e573b4c77c..9757c2f31e 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/VisualPushBlock.unity +++ b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/VisualPushBlock.unity @@ -658,7 +658,15 @@ MonoBehaviour: 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 diff --git a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs old mode 100755 new mode 100644 index 94b4ea44e9..89b26954b9 --- a/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs +++ b/UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs @@ -75,6 +75,8 @@ public override void InitializeAgent() groundRenderer = ground.GetComponent(); // Starting material groundMaterial = groundRenderer.material; + + SetResetParameters(); } public override void CollectObservations() @@ -217,5 +219,34 @@ public override void AgentReset() transform.position = GetRandomSpawnPos(); agentRB.velocity = Vector3.zero; agentRB.angularVelocity = Vector3.zero; + + SetResetParameters(); + } + + public void SetGroundMaterialFriction() + { + var resetParams = academy.resetParameters; + + var groundCollider = ground.GetComponent() 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(); } } diff --git a/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scenes/Reacher.unity b/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scenes/Reacher.unity index 5f65e9ed51..04382108ef 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scenes/Reacher.unity +++ b/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scenes/Reacher.unity @@ -38,7 +38,7 @@ RenderSettings: 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 @@ -1122,8 +1122,12 @@ MonoBehaviour: 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 diff --git a/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAcademy.cs b/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAcademy.cs old mode 100755 new mode 100644 index 39f3e36283..32a5c0490d --- a/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAcademy.cs +++ b/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAcademy.cs @@ -3,16 +3,13 @@ using UnityEngine; using MLAgents; -public class ReacherAcademy : Academy { - - public float goalSize; - public float goalSpeed; +public class ReacherAcademy : Academy +{ public override void AcademyReset() { - goalSize = (float)resetParameters["goal_size"]; - goalSpeed = (float)resetParameters["goal_speed"]; + Physics.gravity = new Vector3(0, -resetParameters["gravity"], 0); } public override void AcademyStep() diff --git a/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs b/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs old mode 100755 new mode 100644 index 7715eade38..85e1f5cecc --- a/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs +++ b/UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs @@ -1,7 +1,8 @@ using UnityEngine; using MLAgents; -public class ReacherAgent : Agent { +public class ReacherAgent : Agent +{ public GameObject pendulumA; public GameObject pendulumB; @@ -11,11 +12,17 @@ public class ReacherAgent : Agent { float goalDegree; private Rigidbody rbA; private Rigidbody rbB; + // speed of the goal zone around the arm (in radians) private float goalSpeed; + // radius of the goal zone private float goalSize; + // 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. /// public override void InitializeAgent() @@ -23,6 +30,8 @@ public override void InitializeAgent() rbA = pendulumA.GetComponent(); rbB = pendulumB.GetComponent(); myAcademy = GameObject.Find("Academy").GetComponent(); + + SetResetParameters(); } /// @@ -43,15 +52,15 @@ public override void CollectObservations() AddVectorObs(goal.transform.localPosition); AddVectorObs(hand.transform.localPosition); - + AddVectorObs(goalSpeed); - } + } /// /// The agent's four actions correspond to torques on each of the two joints. /// public override void AgentAction(float[] vectorAction, string textAction) - { + { goalDegree += goalSpeed; UpdateGoalPosition(); @@ -62,17 +71,18 @@ public override void AgentAction(float[] vectorAction, string textAction) torqueX = Mathf.Clamp(vectorAction[2], -1f, 1f) * 150f; torqueZ = Mathf.Clamp(vectorAction[3], -1f, 1f) * 150f; rbB.AddTorque(new Vector3(torqueX, 0f, torqueZ)); - } + } /// /// Used to move the position of the target goal around the agent. /// - void UpdateGoalPosition() + void UpdateGoalPosition() { var radians = goalDegree * Mathf.PI / 180f; var goalX = 8f * Mathf.Cos(radians); var goalY = 8f * Mathf.Sin(radians); - 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; } /// @@ -93,9 +103,19 @@ public override void AgentReset() goalDegree = Random.Range(0, 360); UpdateGoalPosition(); - goalSize = myAcademy.goalSize; - goalSpeed = Random.Range(-1f, 1f) * myAcademy.goalSpeed; + SetResetParameters(); + goal.transform.localScale = new Vector3(goalSize, goalSize, goalSize); } + + + 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"]; + + } } diff --git a/UnitySDK/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity b/UnitySDK/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity index 048e9fe59d..1738095010 100644 --- a/UnitySDK/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity +++ b/UnitySDK/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity @@ -715,7 +715,15 @@ MonoBehaviour: 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 diff --git a/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs b/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs old mode 100755 new mode 100644 index d00b98365a..5d4c5f2f04 --- a/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs +++ b/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs @@ -19,6 +19,7 @@ public override void InitializeAcademy() public override void AcademyReset() { + Physics.gravity = new Vector3(0, -resetParameters["gravity"], 0); } public override void AcademyStep() diff --git a/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs b/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs old mode 100755 new mode 100644 index 5becda615a..56fb6a3246 --- a/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs +++ b/UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs @@ -29,6 +29,12 @@ public class WalkerAgent : Agent bool isNewDecisionStep; int currentDecisionStep; + private Rigidbody hipsRb; + private Rigidbody chestRb; + private Rigidbody spineRb; + + private ResetParameters resetParams; + public override void InitializeAgent() { jdController = GetComponent(); @@ -48,6 +54,15 @@ public override void InitializeAgent() jdController.SetupBodyPart(armR); jdController.SetupBodyPart(forearmR); jdController.SetupBodyPart(handR); + + hipsRb = hips.GetComponent(); + chestRb = chest.GetComponent(); + spineRb = spine.GetComponent(); + + var academy = FindObjectOfType() as WalkerAcademy; + resetParams = academy.resetParameters; + + SetResetParameters(); } /// @@ -184,5 +199,18 @@ public override void AgentReset() 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(); } } diff --git a/docs/Learning-Environment-Examples.md b/docs/Learning-Environment-Examples.md index 2149363ebb..f924b908ae 100644 --- a/docs/Learning-Environment-Examples.md +++ b/docs/Learning-Environment-Examples.md @@ -153,7 +153,23 @@ If you would like to contribute environments, please see our `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`. @@ -197,7 +213,27 @@ If you would like to contribute environments, please see our * 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) @@ -362,7 +398,23 @@ If you would like to contribute environments, please see our * 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