Skip to content

Commit 75f1a9a

Browse files
sankalp04Ervin T
authored andcommitted
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
1 parent d5bfa89 commit 75f1a9a

File tree

15 files changed

+204
-30
lines changed

15 files changed

+204
-30
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ BoxCollider:
838838
m_PrefabParentObject: {fileID: 0}
839839
m_PrefabInternal: {fileID: 100100000}
840840
m_GameObject: {fileID: 1500989011945850}
841-
m_Material: {fileID: 0}
841+
m_Material: {fileID: 13400000, guid: f440cd475293044139739aff331224fb, type: 2}
842842
m_IsTrigger: 0
843843
m_Enabled: 1
844844
serializedVersion: 2
@@ -905,6 +905,7 @@ MonoBehaviour:
905905
brain: {fileID: 11400000, guid: e8b2d719f6a324b1abb68d8cf2859f5c, type: 2}
906906
agentParameters:
907907
agentCameras: []
908+
agentRenderTextures: []
908909
maxStep: 5000
909910
resetOnDone: 1
910911
onDemandDecision: 0

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ BoxCollider:
790790
m_PrefabParentObject: {fileID: 0}
791791
m_PrefabInternal: {fileID: 100100000}
792792
m_GameObject: {fileID: 1132847330634378}
793-
m_Material: {fileID: 0}
793+
m_Material: {fileID: 13400000, guid: f440cd475293044139739aff331224fb, type: 2}
794794
m_IsTrigger: 0
795795
m_Enabled: 1
796796
serializedVersion: 2
@@ -905,6 +905,7 @@ MonoBehaviour:
905905
brain: {fileID: 11400000, guid: e8b2d719f6a324b1abb68d8cf2859f5c, type: 2}
906906
agentParameters:
907907
agentCameras: []
908+
agentRenderTextures: []
908909
maxStep: 5000
909910
resetOnDone: 1
910911
onDemandDecision: 0

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ BoxCollider:
791791
m_PrefabParentObject: {fileID: 0}
792792
m_PrefabInternal: {fileID: 100100000}
793793
m_GameObject: {fileID: 1492788814869846}
794-
m_Material: {fileID: 0}
794+
m_Material: {fileID: 13400000, guid: f440cd475293044139739aff331224fb, type: 2}
795795
m_IsTrigger: 0
796796
m_Enabled: 1
797797
serializedVersion: 2
@@ -919,6 +919,7 @@ MonoBehaviour:
919919
brain: {fileID: 11400000, guid: dd07b1953eac4411b81fba032f394726, type: 2}
920920
agentParameters:
921921
agentCameras: []
922+
agentRenderTextures: []
922923
maxStep: 5000
923924
resetOnDone: 1
924925
onDemandDecision: 0

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ BoxCollider:
870870
m_PrefabParentObject: {fileID: 0}
871871
m_PrefabInternal: {fileID: 100100000}
872872
m_GameObject: {fileID: 1553741088268304}
873-
m_Material: {fileID: 0}
873+
m_Material: {fileID: 13400000, guid: f440cd475293044139739aff331224fb, type: 2}
874874
m_IsTrigger: 0
875875
m_Enabled: 1
876876
serializedVersion: 2
@@ -970,6 +970,7 @@ MonoBehaviour:
970970
agentParameters:
971971
agentCameras:
972972
- {fileID: 20223756300728806}
973+
agentRenderTextures: []
973974
maxStep: 5000
974975
resetOnDone: 1
975976
onDemandDecision: 0

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,15 @@ MonoBehaviour:
15701570
timeScale: 1
15711571
targetFrameRate: 60
15721572
resetParameters:
1573-
resetParameters: []
1573+
resetParameters:
1574+
- key: dynamic_friction
1575+
value: 0
1576+
- key: static_friction
1577+
value: 0
1578+
- key: block_drag
1579+
value: 0.5
1580+
- key: block_scale
1581+
value: 2
15741582
agentRunSpeed: 2
15751583
agentRotationSpeed: 15
15761584
spawnAreaMarginMultiplier: 0.5

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ Prefab:
339339
propertyPath: m_RootOrder
340340
value: 4
341341
objectReference: {fileID: 0}
342+
- target: {fileID: 65880592586321730, guid: bed6005cc2a1a47edafba27cde6b5538,
343+
type: 2}
344+
propertyPath: m_Material
345+
value:
346+
objectReference: {fileID: 0}
342347
m_RemovedComponents: []
343348
m_ParentPrefab: {fileID: 100100000, guid: bed6005cc2a1a47edafba27cde6b5538, type: 2}
344349
m_IsPrefabParent: 0
@@ -552,7 +557,15 @@ MonoBehaviour:
552557
timeScale: 1
553558
targetFrameRate: 60
554559
resetParameters:
555-
resetParameters: []
560+
resetParameters:
561+
- key: dynamic_friction
562+
value: 0
563+
- key: static_friction
564+
value: 0
565+
- key: block_drag
566+
value: 0.5
567+
- key: block_scale
568+
value: 2
556569
agentRunSpeed: 2
557570
agentRotationSpeed: 15
558571
spawnAreaMarginMultiplier: 0.5

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,15 @@ MonoBehaviour:
658658
timeScale: 1
659659
targetFrameRate: 60
660660
resetParameters:
661-
resetParameters: []
661+
resetParameters:
662+
- key: dynamic_friction
663+
value: 0
664+
- key: static_friction
665+
value: 0
666+
- key: block_drag
667+
value: 0.5
668+
- key: block_scale
669+
value: 2
662670
agentRunSpeed: 2
663671
agentRotationSpeed: 15
664672
spawnAreaMarginMultiplier: 0.5

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

100755100644
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public override void InitializeAgent()
7575
groundRenderer = ground.GetComponent<Renderer>();
7676
// Starting material
7777
groundMaterial = groundRenderer.material;
78+
79+
SetResetParameters();
7880
}
7981

8082
public override void CollectObservations()
@@ -217,5 +219,34 @@ public override void AgentReset()
217219
transform.position = GetRandomSpawnPos();
218220
agentRB.velocity = Vector3.zero;
219221
agentRB.angularVelocity = Vector3.zero;
222+
223+
SetResetParameters();
224+
}
225+
226+
public void SetGroundMaterialFriction()
227+
{
228+
var resetParams = academy.resetParameters;
229+
230+
var groundCollider = ground.GetComponent<Collider>() as Collider;
231+
232+
groundCollider.material.dynamicFriction = resetParams["dynamic_friction"];
233+
groundCollider.material.staticFriction = resetParams["static_friction"];
234+
}
235+
236+
public void SetBlockProperties()
237+
{
238+
var resetParams = academy.resetParameters;
239+
240+
//Set the scale of the block
241+
blockRB.transform.localScale = new Vector3(resetParams["block_scale"], 0.75f, resetParams["block_scale"]);
242+
243+
// Set the drag of the block
244+
blockRB.drag = resetParams["block_drag"];
245+
}
246+
247+
public void SetResetParameters()
248+
{
249+
SetGroundMaterialFriction();
250+
SetBlockProperties();
220251
}
221252
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 762086411}
41-
m_IndirectSpecularColor: {r: 0.4465934, g: 0.49642956, b: 0.5748249, a: 1}
41+
m_IndirectSpecularColor: {r: 0.44657898, g: 0.49641287, b: 0.5748173, a: 1}
4242
--- !u!157 &3
4343
LightmapSettings:
4444
m_ObjectHideFlags: 0
@@ -1122,8 +1122,12 @@ MonoBehaviour:
11221122
value: 5
11231123
- key: goal_speed
11241124
value: 1
1125-
goalSize: 5
1126-
goalSpeed: 1
1125+
- key: gravity
1126+
value: 9.81
1127+
- key: deviation
1128+
value: 0
1129+
- key: deviation_freq
1130+
value: 0
11271131
--- !u!4 &1574236049
11281132
Transform:
11291133
m_ObjectHideFlags: 0

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

100755100644
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
using UnityEngine;
44
using MLAgents;
55

6-
public class ReacherAcademy : Academy {
7-
8-
public float goalSize;
9-
public float goalSpeed;
6+
public class ReacherAcademy : Academy
7+
{
108

119

1210
public override void AcademyReset()
1311
{
14-
goalSize = (float)resetParameters["goal_size"];
15-
goalSpeed = (float)resetParameters["goal_speed"];
12+
Physics.gravity = new Vector3(0, -resetParameters["gravity"], 0);
1613
}
1714

1815
public override void AcademyStep()

0 commit comments

Comments
 (0)