edbeeching HF staff commited on
Commit
c21eb24
1 Parent(s): 7419f6a

Upload . with huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. .godot/exported/133200997/export-013a0ba1f1fdb71b574ef7b36fdde25a-ColorRoom.scn +0 -0
  3. .godot/exported/133200997/export-1222b1ceeacbc57c3f8fe0e4235d9be0-ExampleRaycastSensor3D.scn +0 -0
  4. .godot/exported/133200997/export-1cc1ad7ce1f98ed0c4cee4b060bc26fd-RaycastSensor3D.scn +0 -0
  5. .godot/exported/133200997/export-3f529fed70430038310ab41ff1962c78-Robot.scn +0 -0
  6. .godot/exported/133200997/export-5127fc3fc2907f1e87ac8e869558593d-ExampleRaycastSensor2D.scn +0 -0
  7. .godot/exported/133200997/export-68e5bc47c3f04dcb0c57656d5bbefcb7-VirtualCamera.scn +0 -0
  8. .godot/exported/133200997/export-7454c66d21916090bf5dc7766fa8629a-RaycastSensor2D.scn +0 -0
  9. .godot/exported/133200997/export-7cf3fd67ad9f55210191d77b582b8209-default_env.res +0 -0
  10. .godot/exported/133200997/export-90e1ff3baa03524a506ff0f7a9d78dcf-Player.scn +0 -0
  11. .godot/exported/133200997/export-d1d9cc1906d18d9a32f853b74a4d90f4-RGBCameraSensor3D.scn +0 -0
  12. .godot/exported/133200997/export-d2281d20f16239d336bf933e5fe6cd34-Env2.scn +0 -0
  13. .godot/exported/133200997/export-dcee5a5a254d02ce44ac991a3244aeb2-Env.scn +0 -0
  14. .godot/exported/133200997/file_cache +12 -0
  15. .godot/uid_cache.bin +3 -0
  16. .import/.gdignore +1 -0
  17. .import/icon.png-45a871b53434e556222f5901d598ab34.md5 +3 -0
  18. .import/icon.png-45a871b53434e556222f5901d598ab34.stex +0 -0
  19. .import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 +3 -0
  20. .import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex +0 -0
  21. ColorRoom.tscn +118 -0
  22. Env.tscn +62 -0
  23. Env2.tscn +17 -0
  24. Model.tscn +5 -0
  25. Player.gd +218 -0
  26. Player.tscn +34 -0
  27. README.md +25 -0
  28. Robot.gd +20 -0
  29. Robot.tscn +0 -0
  30. VirtualCamera.gd +26 -0
  31. VirtualCamera.tscn +42 -0
  32. addons/godot_rl_agents/godot_rl_agents.gd +16 -0
  33. addons/godot_rl_agents/icon.png +3 -0
  34. addons/godot_rl_agents/icon.png.import +34 -0
  35. addons/godot_rl_agents/plugin.cfg +7 -0
  36. addons/godot_rl_agents/sensors/sensors_2d/ExampleRaycastSensor2D.tscn +48 -0
  37. addons/godot_rl_agents/sensors/sensors_2d/ISensor2D.gd +20 -0
  38. addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd +94 -0
  39. addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.tscn +6 -0
  40. addons/godot_rl_agents/sensors/sensors_3d/ExampleRaycastSensor3D.tscn +6 -0
  41. addons/godot_rl_agents/sensors/sensors_3d/ISensor3D.gd +20 -0
  42. addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.gd +11 -0
  43. addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.tscn +42 -0
  44. addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd +162 -0
  45. addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.tscn +49 -0
  46. addons/godot_rl_agents/sync.gd +295 -0
  47. bin/VirtualCamera.pck +0 -0
  48. bin/VirtualCamera.x86_64 +3 -0
  49. default_env.tres +7 -0
  50. export_presets.cfg +24 -0
.gitattributes CHANGED
@@ -52,3 +52,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ bin/VirtualCamera.x86_64 filter=lfs diff=lfs merge=lfs -text
.godot/exported/133200997/export-013a0ba1f1fdb71b574ef7b36fdde25a-ColorRoom.scn ADDED
Binary file (4.03 kB). View file
 
.godot/exported/133200997/export-1222b1ceeacbc57c3f8fe0e4235d9be0-ExampleRaycastSensor3D.scn ADDED
Binary file (680 Bytes). View file
 
.godot/exported/133200997/export-1cc1ad7ce1f98ed0c4cee4b060bc26fd-RaycastSensor3D.scn ADDED
Binary file (1.21 kB). View file
 
.godot/exported/133200997/export-3f529fed70430038310ab41ff1962c78-Robot.scn ADDED
Binary file (66.1 kB). View file
 
.godot/exported/133200997/export-5127fc3fc2907f1e87ac8e869558593d-ExampleRaycastSensor2D.scn ADDED
Binary file (1.61 kB). View file
 
.godot/exported/133200997/export-68e5bc47c3f04dcb0c57656d5bbefcb7-VirtualCamera.scn ADDED
Binary file (1.5 kB). View file
 
.godot/exported/133200997/export-7454c66d21916090bf5dc7766fa8629a-RaycastSensor2D.scn ADDED
Binary file (679 Bytes). View file
 
.godot/exported/133200997/export-7cf3fd67ad9f55210191d77b582b8209-default_env.res ADDED
Binary file (2.47 kB). View file
 
.godot/exported/133200997/export-90e1ff3baa03524a506ff0f7a9d78dcf-Player.scn ADDED
Binary file (1.73 kB). View file
 
.godot/exported/133200997/export-d1d9cc1906d18d9a32f853b74a4d90f4-RGBCameraSensor3D.scn ADDED
Binary file (1.67 kB). View file
 
.godot/exported/133200997/export-d2281d20f16239d336bf933e5fe6cd34-Env2.scn ADDED
Binary file (1.03 kB). View file
 
.godot/exported/133200997/export-dcee5a5a254d02ce44ac991a3244aeb2-Env.scn ADDED
Binary file (2.59 kB). View file
 
.godot/exported/133200997/file_cache ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ res://addons/godot_rl_agents/sensors/sensors_2d/ExampleRaycastSensor2D.tscn::633a89120f47fd16d8509d7bf62bdcc6::1667837398::res://.godot/exported/133200997/export-5127fc3fc2907f1e87ac8e869558593d-ExampleRaycastSensor2D.scn
2
+ res://addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.tscn::47f05d8501daa604d78b8ed9fcacbae5::1667837398::res://.godot/exported/133200997/export-7454c66d21916090bf5dc7766fa8629a-RaycastSensor2D.scn
3
+ res://addons/godot_rl_agents/sensors/sensors_3d/ExampleRaycastSensor3D.tscn::5132e3ace4e34f1809af5ab3b83b467f::1671457020::res://.godot/exported/133200997/export-1222b1ceeacbc57c3f8fe0e4235d9be0-ExampleRaycastSensor3D.scn
4
+ res://addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.tscn::cda0f7aad12ff3fe4c995244863b3bf0::1667837398::res://.godot/exported/133200997/export-1cc1ad7ce1f98ed0c4cee4b060bc26fd-RaycastSensor3D.scn
5
+ res://addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.tscn::00bc7933716a6fae1ba344bbd9a386a2::1667837398::res://.godot/exported/133200997/export-d1d9cc1906d18d9a32f853b74a4d90f4-RGBCameraSensor3D.scn
6
+ res://ColorRoom.tscn::a0d7cb60f382d0efa251cae9a475f6ba::1667490278::res://.godot/exported/133200997/export-013a0ba1f1fdb71b574ef7b36fdde25a-ColorRoom.scn
7
+ res://default_env.tres::756de160834ef7cc033c2a79cd80f338::1652447337::res://.godot/exported/133200997/export-7cf3fd67ad9f55210191d77b582b8209-default_env.res
8
+ res://Env2.tscn::577b554f578c15a38a985195cae041d0::1646900665::res://.godot/exported/133200997/export-d2281d20f16239d336bf933e5fe6cd34-Env2.scn
9
+ res://Env.tscn::d114897d479bbbdbfad9f318f6179f59::1667490278::res://.godot/exported/133200997/export-dcee5a5a254d02ce44ac991a3244aeb2-Env.scn
10
+ res://Player.tscn::db7ba5239bf558913f7005697d781af6::1667490278::res://.godot/exported/133200997/export-90e1ff3baa03524a506ff0f7a9d78dcf-Player.scn
11
+ res://Robot.tscn::3fb37de53f67855ead9b5c6d1ef4c68d::1652445904::res://.godot/exported/133200997/export-3f529fed70430038310ab41ff1962c78-Robot.scn
12
+ res://VirtualCamera.tscn::b9cc66968428f3b513867ef6e2ccad3b::1646234274::res://.godot/exported/133200997/export-68e5bc47c3f04dcb0c57656d5bbefcb7-VirtualCamera.scn
.godot/uid_cache.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b0c825d6933b2fec08807f806ddabc28d030f6d78653e9a8a38a1d7fc138392
3
+ size 166
.import/.gdignore ADDED
@@ -0,0 +1 @@
 
 
1
+
.import/icon.png-45a871b53434e556222f5901d598ab34.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ source_md5="46836b07703d0875e7b43542e9eaa687"
2
+ dest_md5="9fbd3845dc461f4cca61f62967b871f8"
3
+
.import/icon.png-45a871b53434e556222f5901d598ab34.stex ADDED
Binary file (204 Bytes). View file
 
.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
2
+ dest_md5="26ea799ea0a3da9e753b3ebe822e0570"
3
+
.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex ADDED
Binary file (1.5 kB). View file
 
ColorRoom.tscn ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=12 format=2]
2
+
3
+ [ext_resource path="res://Player.tscn" type="PackedScene" id=1]
4
+
5
+ [sub_resource type="CubeMesh" id=1]
6
+ size = Vector3( 20, 0.1, 20 )
7
+
8
+ [sub_resource type="SpatialMaterial" id=9]
9
+ albedo_color = Color( 0.145098, 0.145098, 0.145098, 1 )
10
+
11
+ [sub_resource type="ConcavePolygonShape" id=2]
12
+ data = PoolVector3Array( -10, 0.05, 10, 10, 0.05, 10, -10, -0.05, 10, 10, 0.05, 10, 10, -0.05, 10, -10, -0.05, 10, 10, 0.05, -10, -10, 0.05, -10, 10, -0.05, -10, -10, 0.05, -10, -10, -0.05, -10, 10, -0.05, -10, 10, 0.05, 10, 10, 0.05, -10, 10, -0.05, 10, 10, 0.05, -10, 10, -0.05, -10, 10, -0.05, 10, -10, 0.05, -10, -10, 0.05, 10, -10, -0.05, -10, -10, 0.05, 10, -10, -0.05, 10, -10, -0.05, -10, 10, 0.05, 10, -10, 0.05, 10, 10, 0.05, -10, -10, 0.05, 10, -10, 0.05, -10, 10, 0.05, -10, -10, -0.05, 10, 10, -0.05, 10, -10, -0.05, -10, 10, -0.05, 10, 10, -0.05, -10, -10, -0.05, -10 )
13
+
14
+ [sub_resource type="CubeMesh" id=3]
15
+ size = Vector3( 20, 5, 2 )
16
+
17
+ [sub_resource type="SpatialMaterial" id=8]
18
+ albedo_color = Color( 0.541176, 0.247059, 0.760784, 1 )
19
+
20
+ [sub_resource type="ConcavePolygonShape" id=4]
21
+ data = PoolVector3Array( -10, 2.5, 1, 10, 2.5, 1, -10, -2.5, 1, 10, 2.5, 1, 10, -2.5, 1, -10, -2.5, 1, 10, 2.5, -1, -10, 2.5, -1, 10, -2.5, -1, -10, 2.5, -1, -10, -2.5, -1, 10, -2.5, -1, 10, 2.5, 1, 10, 2.5, -1, 10, -2.5, 1, 10, 2.5, -1, 10, -2.5, -1, 10, -2.5, 1, -10, 2.5, -1, -10, 2.5, 1, -10, -2.5, -1, -10, 2.5, 1, -10, -2.5, 1, -10, -2.5, -1, 10, 2.5, 1, -10, 2.5, 1, 10, 2.5, -1, -10, 2.5, 1, -10, 2.5, -1, 10, 2.5, -1, -10, -2.5, 1, 10, -2.5, 1, -10, -2.5, -1, 10, -2.5, 1, 10, -2.5, -1, -10, -2.5, -1 )
22
+
23
+ [sub_resource type="SpatialMaterial" id=7]
24
+ albedo_color = Color( 0.0627451, 0.670588, 0.215686, 1 )
25
+
26
+ [sub_resource type="SpatialMaterial" id=6]
27
+ albedo_color = Color( 0.137255, 0.34902, 0.909804, 1 )
28
+
29
+ [sub_resource type="SpatialMaterial" id=5]
30
+ albedo_color = Color( 0.784314, 0.129412, 0.129412, 1 )
31
+
32
+ [sub_resource type="BoxShape" id=10]
33
+ extents = Vector3( 0.4, 1, 8.97105 )
34
+
35
+ [node name="ColorRoom" type="Spatial"]
36
+
37
+ [node name="Player" parent="." instance=ExtResource( 1 )]
38
+
39
+ [node name="Camera" type="Camera" parent="Player"]
40
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7, -0.199591 )
41
+
42
+ [node name="Walls" type="Spatial" parent="."]
43
+
44
+ [node name="MeshInstance" type="MeshInstance" parent="Walls"]
45
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0 )
46
+ mesh = SubResource( 1 )
47
+ skeleton = NodePath("../..")
48
+ material/0 = SubResource( 9 )
49
+
50
+ [node name="StaticBody" type="StaticBody" parent="Walls/MeshInstance"]
51
+
52
+ [node name="CollisionShape" type="CollisionShape" parent="Walls/MeshInstance/StaticBody"]
53
+ shape = SubResource( 2 )
54
+
55
+ [node name="MeshInstance2" type="MeshInstance" parent="Walls"]
56
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, -11 )
57
+ mesh = SubResource( 3 )
58
+ skeleton = NodePath("../..")
59
+ material/0 = SubResource( 8 )
60
+
61
+ [node name="StaticBody" type="StaticBody" parent="Walls/MeshInstance2"]
62
+
63
+ [node name="CollisionShape" type="CollisionShape" parent="Walls/MeshInstance2/StaticBody"]
64
+ shape = SubResource( 4 )
65
+
66
+ [node name="MeshInstance3" type="MeshInstance" parent="Walls"]
67
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, 11 )
68
+ mesh = SubResource( 3 )
69
+ skeleton = NodePath("../..")
70
+ material/0 = SubResource( 7 )
71
+
72
+ [node name="StaticBody" type="StaticBody" parent="Walls/MeshInstance3"]
73
+
74
+ [node name="CollisionShape" type="CollisionShape" parent="Walls/MeshInstance3/StaticBody"]
75
+ shape = SubResource( 4 )
76
+
77
+ [node name="MeshInstance4" type="MeshInstance" parent="Walls"]
78
+ transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 11, 2.5, 0 )
79
+ mesh = SubResource( 3 )
80
+ skeleton = NodePath("../..")
81
+ material/0 = SubResource( 6 )
82
+
83
+ [node name="StaticBody" type="StaticBody" parent="Walls/MeshInstance4"]
84
+
85
+ [node name="CollisionShape" type="CollisionShape" parent="Walls/MeshInstance4/StaticBody"]
86
+ shape = SubResource( 4 )
87
+
88
+ [node name="MeshInstance5" type="MeshInstance" parent="Walls"]
89
+ transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -11, 2.5, 0 )
90
+ mesh = SubResource( 3 )
91
+ skeleton = NodePath("../..")
92
+ material/0 = SubResource( 5 )
93
+
94
+ [node name="StaticBody" type="StaticBody" parent="Walls/MeshInstance5"]
95
+
96
+ [node name="CollisionShape" type="CollisionShape" parent="Walls/MeshInstance5/StaticBody"]
97
+ shape = SubResource( 4 )
98
+
99
+ [node name="Goals" type="Spatial" parent="."]
100
+
101
+ [node name="NegativeGoal" type="Area" parent="Goals"]
102
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -8.71839, 0.0416299, -0.292424 )
103
+ collision_layer = 0
104
+
105
+ [node name="CollisionShape" type="CollisionShape" parent="Goals/NegativeGoal"]
106
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.47999, 0 )
107
+ shape = SubResource( 10 )
108
+
109
+ [node name="PositiveGoal" type="Area" parent="Goals"]
110
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8.93574, -0.068549, -0.292424 )
111
+ collision_layer = 0
112
+
113
+ [node name="CollisionShape" type="CollisionShape" parent="Goals/PositiveGoal"]
114
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.47999, 0 )
115
+ shape = SubResource( 10 )
116
+
117
+ [connection signal="body_entered" from="Goals/NegativeGoal" to="Player" method="_on_NegativeGoal_body_entered"]
118
+ [connection signal="body_entered" from="Goals/PositiveGoal" to="Player" method="_on_PositiveGoal_body_entered"]
Env.tscn ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=3 format=2]
2
+
3
+ [ext_resource path="res://ColorRoom.tscn" type="PackedScene" id=1]
4
+ [ext_resource path="res://addons/godot_rl_agents/sync.gd" type="Script" id=2]
5
+
6
+ [node name="Env" type="Spatial"]
7
+
8
+ [node name="ColorRoom" parent="." instance=ExtResource( 1 )]
9
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 0, 25 )
10
+
11
+ [node name="ColorRoom2" parent="." instance=ExtResource( 1 )]
12
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 0, 0 )
13
+
14
+ [node name="ColorRoom3" parent="." instance=ExtResource( 1 )]
15
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 0, -25 )
16
+
17
+ [node name="ColorRoom4" parent="." instance=ExtResource( 1 )]
18
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 0, -50 )
19
+
20
+ [node name="ColorRoom5" parent="." instance=ExtResource( 1 )]
21
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13, 0, 25 )
22
+
23
+ [node name="ColorRoom6" parent="." instance=ExtResource( 1 )]
24
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13, 0, 0 )
25
+
26
+ [node name="ColorRoom7" parent="." instance=ExtResource( 1 )]
27
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13, 0, -25 )
28
+
29
+ [node name="ColorRoom8" parent="." instance=ExtResource( 1 )]
30
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13, 0, -50 )
31
+
32
+ [node name="ColorRoom9" parent="." instance=ExtResource( 1 )]
33
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 38, 0, 25 )
34
+
35
+ [node name="ColorRoom10" parent="." instance=ExtResource( 1 )]
36
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 38, 0, 0 )
37
+
38
+ [node name="ColorRoom11" parent="." instance=ExtResource( 1 )]
39
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 38, 0, -25 )
40
+
41
+ [node name="ColorRoom12" parent="." instance=ExtResource( 1 )]
42
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 38, 0, -50 )
43
+
44
+ [node name="ColorRoom13" parent="." instance=ExtResource( 1 )]
45
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 63, 0, 25 )
46
+
47
+ [node name="ColorRoom14" parent="." instance=ExtResource( 1 )]
48
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 63, 0, 0 )
49
+
50
+ [node name="ColorRoom15" parent="." instance=ExtResource( 1 )]
51
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 63, 0, -25 )
52
+
53
+ [node name="ColorRoom16" parent="." instance=ExtResource( 1 )]
54
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 63, 0, -50 )
55
+
56
+ [node name="Sync" type="Node" parent="."]
57
+ process_priority = -1
58
+ script = ExtResource( 2 )
59
+
60
+ [node name="Camera" type="Camera" parent="."]
61
+ transform = Transform( 1, 0, 0, 0, 0.0220418, 0.999757, 0, -0.999757, 0.0220418, 25.3538, 75.4275, -10.0795 )
62
+ current = true
Env2.tscn ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=3 format=2]
2
+
3
+ [ext_resource path="res://ColorRoom.tscn" type="PackedScene" id=1]
4
+ [ext_resource path="res://addons/godot_rl_agents/sync.gd" type="Script" id=2]
5
+
6
+ [node name="Env" type="Spatial"]
7
+
8
+ [node name="T-Maze" parent="." instance=ExtResource( 1 )]
9
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 0, 25 )
10
+
11
+ [node name="Sync" type="Node" parent="."]
12
+ process_priority = -1
13
+ script = ExtResource( 2 )
14
+
15
+ [node name="Camera" type="Camera" parent="."]
16
+ transform = Transform( 1, 0, 0, 0, 0.0220418, 0.999757, 0, -0.999757, 0.0220418, 25.3538, 75.4275, -10.0795 )
17
+ current = true
Model.tscn ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ [gd_scene load_steps=2 format=2]
2
+
3
+ [ext_resource path="res://90s_dad/scene.gltf" type="PackedScene" id=1]
4
+
5
+ [node name="Model" instance=ExtResource( 1 )]
Player.gd ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends KinematicBody
2
+ class_name Player
3
+ const MOVE_SPEED = 12
4
+ const JUMP_FORCE = 30
5
+ const GRAVITY = 0.98
6
+ const MAX_FALL_SPEED = 30
7
+ const TURN_SENS = 2.0
8
+ const MAX_STEPS = 10000
9
+
10
+ onready var cam = $Camera
11
+ var move_vec = Vector3()
12
+ var y_velo = 0
13
+
14
+ # RL related variables
15
+ onready var robot = $Robot
16
+ onready var virtual_camera = $RGBCameraSensor3D
17
+
18
+ var next = 1
19
+ var done = false
20
+ var needs_reset = false
21
+ var just_reached_negative = false
22
+ var just_reached_positive = false
23
+ var just_fell_off = false
24
+ var best_goal_distance := 10000.0
25
+ var grounded := false
26
+ var _heuristic := "player"
27
+ var move_action := 0.0
28
+ var turn_action := 0.0
29
+ var jump_action := false
30
+ var n_steps = 0
31
+
32
+ var reward = 0.0
33
+
34
+ func _ready():
35
+ return
36
+ #reset()
37
+
38
+ func _physics_process(_delta):
39
+
40
+ n_steps +=1
41
+ if n_steps >= MAX_STEPS:
42
+ done = true
43
+ needs_reset = true
44
+
45
+ if needs_reset:
46
+ needs_reset = false
47
+ reset()
48
+ return
49
+
50
+ move_vec *= 0
51
+ move_vec = get_move_vec()
52
+ #move_vec = move_vec.normalized()
53
+
54
+ move_vec = move_vec.rotated(Vector3(0, 1, 0), rotation.y)
55
+ move_vec *= MOVE_SPEED
56
+ move_vec.y = y_velo
57
+ move_and_slide(move_vec, Vector3(0, 1, 0))
58
+
59
+ # turning
60
+
61
+ var turn_vec = get_turn_vec()
62
+ rotation_degrees.y += turn_vec*TURN_SENS
63
+
64
+ grounded = is_on_floor()
65
+
66
+ y_velo -= GRAVITY
67
+ var just_jumped = false
68
+
69
+ if grounded and y_velo <= 0:
70
+ y_velo = -0.1
71
+ if y_velo < -MAX_FALL_SPEED:
72
+ y_velo = -MAX_FALL_SPEED
73
+
74
+ if y_velo < 0 and !grounded :
75
+ robot.set_animation("falling-cycle")
76
+
77
+ var horizontal_speed = Vector2(move_vec.x, move_vec.z)
78
+ if horizontal_speed.length() < 0.1 and grounded:
79
+ robot.set_animation("idle")
80
+ elif horizontal_speed.length() >=1.0 and grounded:
81
+ robot.set_animation("walk-cycle")
82
+ # elif horizontal_speed.length() >= 1.0 and grounded:
83
+ # robot.set_animation("run-cycle")
84
+
85
+ update_reward()
86
+
87
+ if Input.is_action_just_pressed("r_key"):
88
+ reset()
89
+
90
+
91
+ func get_move_vec() -> Vector3:
92
+ if done:
93
+ move_vec = Vector3.ZERO
94
+ return move_vec
95
+
96
+ if _heuristic == "model":
97
+ return Vector3(
98
+ 0,
99
+ 0,
100
+ clamp(move_action, -1.0, 0.5)
101
+ )
102
+
103
+ var move_vec := Vector3(
104
+ 0,
105
+ 0,
106
+ clamp(Input.get_action_strength("move_backwards") - Input.get_action_strength("move_forwards"),-1.0, 0.5)
107
+
108
+ )
109
+ return move_vec
110
+
111
+ func get_turn_vec() -> float:
112
+ if _heuristic == "model":
113
+ return turn_action
114
+ var rotation_amount = Input.get_action_strength("turn_left") - Input.get_action_strength("turn_right")
115
+
116
+ return rotation_amount
117
+
118
+
119
+ func reset():
120
+ needs_reset = false
121
+ next = 1
122
+ n_steps = 0
123
+ #done = false
124
+ just_reached_negative = false
125
+ just_reached_positive = false
126
+ jump_action = false
127
+ # Replace with function body.
128
+ set_translation(Vector3(0,1.5,0))
129
+ rotation_degrees.y = rand_range(-180,180)
130
+ y_velo = 0.1
131
+
132
+ func set_action(action):
133
+ move_action = action["move"][0]
134
+ turn_action = action["turn"][0]
135
+
136
+ func reset_if_done():
137
+ if done:
138
+ reset()
139
+
140
+ func get_obs():
141
+ #print(virtual_camera.get_camera_pixel_encoding())
142
+ return {
143
+ "camera_2d": virtual_camera.get_camera_pixel_encoding(),
144
+ }
145
+
146
+ func get_obs_space():
147
+ # typs of obs space: box, discrete, repeated
148
+ return {
149
+ "camera_2d":{
150
+ "size": virtual_camera.get_camera_shape(),
151
+ "space":"box"
152
+ },
153
+ }
154
+
155
+
156
+ func update_reward():
157
+ reward -= 0.01 # step penalty
158
+ reward += shaping_reward()
159
+
160
+
161
+
162
+ func get_reward():
163
+ return reward
164
+
165
+ func zero_reward():
166
+ reward = 0.0
167
+
168
+ func shaping_reward():
169
+ var s_reward = 0.0
170
+ return s_reward
171
+
172
+
173
+ func set_heuristic(heuristic):
174
+ self._heuristic = heuristic
175
+
176
+ func get_obs_size():
177
+ return len(get_obs())
178
+
179
+ func get_action_space():
180
+ return {
181
+ "move" : {
182
+ "size": 1,
183
+ "action_type": "continuous"
184
+ },
185
+ "turn" : {
186
+ "size": 1,
187
+ "action_type": "continuous"
188
+ }
189
+ }
190
+
191
+ func get_done():
192
+ return done
193
+
194
+ func set_done_false():
195
+ done = false
196
+
197
+
198
+ func calculate_translation(other_pad_translation : Vector3) -> Vector3:
199
+ var new_translation := Vector3.ZERO
200
+ var distance = rand_range(12,16)
201
+ var angle = rand_range(-180,180)
202
+ new_translation.z = other_pad_translation.z + sin(deg2rad(angle))*distance
203
+ new_translation.x = other_pad_translation.x + cos(deg2rad(angle))*distance
204
+
205
+ return new_translation
206
+
207
+
208
+
209
+ func _on_NegativeGoal_body_entered(body: Node) -> void:
210
+ reward -= 1.0
211
+ done = true
212
+ reset()
213
+
214
+
215
+ func _on_PositiveGoal_body_entered(body: Node) -> void:
216
+ reward += 1.0
217
+ done = true
218
+ reset()
Player.tscn ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=7 format=2]
2
+
3
+ [ext_resource path="res://Player.gd" type="Script" id=1]
4
+ [ext_resource path="res://Robot.tscn" type="PackedScene" id=2]
5
+ [ext_resource path="res://addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.tscn" type="PackedScene" id=3]
6
+
7
+ [sub_resource type="CapsuleShape" id=1]
8
+ radius = 1.6
9
+
10
+ [sub_resource type="CapsuleMesh" id=2]
11
+
12
+ [sub_resource type="SpatialMaterial" id=3]
13
+ albedo_color = Color( 0.109804, 0.317647, 0.458824, 1 )
14
+
15
+ [node name="Player" type="KinematicBody" groups=["AGENT"]]
16
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0 )
17
+ collision_mask = 0
18
+ script = ExtResource( 1 )
19
+
20
+ [node name="CollisionShape" type="CollisionShape" parent="."]
21
+ transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0 )
22
+ shape = SubResource( 1 )
23
+
24
+ [node name="MeshInstance" type="MeshInstance" parent="."]
25
+ transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0 )
26
+ visible = false
27
+ mesh = SubResource( 2 )
28
+ material/0 = SubResource( 3 )
29
+
30
+ [node name="Robot" parent="." instance=ExtResource( 2 )]
31
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.43952, 0.0576344 )
32
+
33
+ [node name="RGBCameraSensor3D" parent="." instance=ExtResource( 3 )]
34
+ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, -1 )
README.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: godot-rl
3
+ tags:
4
+ - deep-reinforcement-learning
5
+ - reinforcement-learning
6
+ - godot-rl
7
+ - environments
8
+ - video-games
9
+ ---
10
+
11
+ A RL environment called VirtualCamera for the Godot Game Engine.
12
+
13
+ This environment was created with: https://github.com/edbeeching/godot_rl_agents
14
+
15
+
16
+ ## Downloading the environment
17
+
18
+ After installing Godot RL Agents, download the environment with:
19
+
20
+ ```
21
+ gdrl.env_from_hub -r edbeeching/godot_rl_VirtualCamera
22
+ ```
23
+
24
+
25
+
Robot.gd ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends Spatial
2
+
3
+
4
+ # Declare member variables here. Examples:
5
+ # var a = 2
6
+ # var b = "text"
7
+
8
+ onready var player = $AnimationPlayer
9
+
10
+ # Called when the node enters the scene tree for the first time.
11
+ func _ready():
12
+ pass # Replace with function body.
13
+
14
+
15
+
16
+ func set_animation(anim):
17
+ if player.current_animation == anim:
18
+ return
19
+
20
+ player.play(anim)
Robot.tscn ADDED
The diff for this file is too large to render. See raw diff
 
VirtualCamera.gd ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends Spatial
2
+
3
+
4
+ var steps = 0
5
+ var camera_pixels = null
6
+
7
+ onready var camera_texture := $Control/TextureRect/CameraTexture as Sprite
8
+ onready var viewport := $Viewport
9
+
10
+ func get_camera_pixel_encoding():
11
+ return camera_texture.get_texture().get_data().data["data"].hex_encode()
12
+
13
+ func get_camera_shape()-> Array:
14
+ return [viewport.size[0], viewport.size[1], 4]
15
+
16
+ func _physics_process(delta):
17
+ steps += 1
18
+ # if steps % 120:
19
+ # print(camera_texture.get_texture().get_data().data.format)
20
+ # print(camera_texture.get_texture().get_data().data.keys(),
21
+ # len(camera_texture.get_texture().get_data().data["data"]), " ",
22
+ # camera_texture.get_texture().get_data().data["data"],
23
+ # camera_texture.get_texture().get_data().data["data"].hex_encode()
24
+ #
25
+ # )
26
+ #camera_pixels = camera_texture.get_texture().get_data().data["data"].hex_encode()
VirtualCamera.tscn ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=3 format=2]
2
+
3
+ [ext_resource path="res://VirtualCamera.gd" type="Script" id=1]
4
+
5
+ [sub_resource type="ViewportTexture" id=1]
6
+ viewport_path = NodePath("Viewport")
7
+
8
+ [node name="VirtualCamera" type="Spatial"]
9
+ script = ExtResource( 1 )
10
+
11
+ [node name="RemoteTransform" type="RemoteTransform" parent="."]
12
+ remote_path = NodePath("../Viewport/Camera")
13
+
14
+ [node name="Viewport" type="Viewport" parent="."]
15
+ size = Vector2( 16, 16 )
16
+ render_target_update_mode = 3
17
+
18
+ [node name="Camera" type="Camera" parent="Viewport"]
19
+ near = 0.5
20
+
21
+ [node name="Control" type="Control" parent="."]
22
+ anchor_right = 1.0
23
+ anchor_bottom = 1.0
24
+ __meta__ = {
25
+ "_edit_use_anchors_": false
26
+ }
27
+
28
+ [node name="TextureRect" type="ColorRect" parent="Control"]
29
+ margin_left = 1096.0
30
+ margin_top = 534.0
31
+ margin_right = 1114.0
32
+ margin_bottom = 552.0
33
+ rect_scale = Vector2( 10, 10 )
34
+ color = Color( 0.00784314, 0.00784314, 0.00784314, 1 )
35
+ __meta__ = {
36
+ "_edit_use_anchors_": false
37
+ }
38
+
39
+ [node name="CameraTexture" type="Sprite" parent="Control/TextureRect"]
40
+ texture = SubResource( 1 )
41
+ offset = Vector2( 9, 9 )
42
+ flip_v = true
addons/godot_rl_agents/godot_rl_agents.gd ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @tool
2
+ extends EditorPlugin
3
+
4
+
5
+ func _enter_tree():
6
+ # Initialization of the plugin goes here.
7
+ # Add the new type with a name, a parent type, a script and an icon.
8
+ add_custom_type("Sync", "Node", preload("sync.gd"), preload("icon.png"))
9
+ #add_custom_type("RaycastSensor2D2", "Node", preload("raycast_sensor_2d.gd"), preload("icon.png"))
10
+
11
+
12
+ func _exit_tree():
13
+ # Clean-up of the plugin goes here.
14
+ # Always remember to remove it from the engine when deactivated.
15
+ remove_custom_type("Sync")
16
+ #remove_custom_type("RaycastSensor2D2")
addons/godot_rl_agents/icon.png ADDED

Git LFS Details

  • SHA256: e3a8bc372d3313ce1ede4e7554472e37b322178b9488bfb709e296585abd3c44
  • Pointer size: 128 Bytes
  • Size of remote file: 198 Bytes
addons/godot_rl_agents/icon.png.import ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [remap]
2
+
3
+ importer="texture"
4
+ type="CompressedTexture2D"
5
+ uid="uid://b7lwg3uk8v3pr"
6
+ path="res://.godot/imported/icon.png-45a871b53434e556222f5901d598ab34.ctex"
7
+ metadata={
8
+ "vram_texture": false
9
+ }
10
+
11
+ [deps]
12
+
13
+ source_file="res://addons/godot_rl_agents/icon.png"
14
+ dest_files=["res://.godot/imported/icon.png-45a871b53434e556222f5901d598ab34.ctex"]
15
+
16
+ [params]
17
+
18
+ compress/mode=0
19
+ compress/lossy_quality=0.7
20
+ compress/hdr_compression=1
21
+ compress/bptc_ldr=0
22
+ compress/normal_map=0
23
+ compress/channel_pack=0
24
+ mipmaps/generate=false
25
+ mipmaps/limit=-1
26
+ roughness/mode=0
27
+ roughness/src_normal=""
28
+ process/fix_alpha_border=true
29
+ process/premult_alpha=false
30
+ process/normal_map_invert_y=false
31
+ process/hdr_as_srgb=false
32
+ process/hdr_clamp_exposure=false
33
+ process/size_limit=0
34
+ detect_3d/compress_to=1
addons/godot_rl_agents/plugin.cfg ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ [plugin]
2
+
3
+ name="GodotRLAgents"
4
+ description="Custom nodes for the godot rl agents toolkit "
5
+ author="Edward Beeching"
6
+ version="0.1"
7
+ script="godot_rl_agents.gd"
addons/godot_rl_agents/sensors/sensors_2d/ExampleRaycastSensor2D.tscn ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=5 format=2]
2
+
3
+ [ext_resource path="res://sensors/sensors_2d/RaycastSensor2D.gd" type="Script" id=1]
4
+
5
+ [sub_resource type="GDScript" id=2]
6
+ script/source = "extends Node2D
7
+
8
+
9
+
10
+ func _physics_process(delta: float) -> void:
11
+ print(\"step start\")
12
+
13
+ "
14
+
15
+ [sub_resource type="GDScript" id=1]
16
+ script/source = "extends RayCast2D
17
+
18
+ var steps = 1
19
+
20
+ func _physics_process(delta: float) -> void:
21
+ print(\"processing raycast\")
22
+ steps += 1
23
+ if steps % 2:
24
+ force_raycast_update()
25
+
26
+ print(is_colliding())
27
+ "
28
+
29
+ [sub_resource type="CircleShape2D" id=3]
30
+
31
+ [node name="ExampleRaycastSensor2D" type="Node2D"]
32
+ script = SubResource( 2 )
33
+
34
+ [node name="ExampleAgent" type="Node2D" parent="."]
35
+ position = Vector2( 573, 314 )
36
+ rotation = 0.286234
37
+
38
+ [node name="RaycastSensor2D" type="Node2D" parent="ExampleAgent"]
39
+ script = ExtResource( 1 )
40
+
41
+ [node name="TestRayCast2D" type="RayCast2D" parent="."]
42
+ script = SubResource( 1 )
43
+
44
+ [node name="StaticBody2D" type="StaticBody2D" parent="."]
45
+ position = Vector2( 1, 52 )
46
+
47
+ [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
48
+ shape = SubResource( 3 )
addons/godot_rl_agents/sensors/sensors_2d/ISensor2D.gd ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends Node2D
2
+ class_name ISensor2D
3
+
4
+ var _obs : Array
5
+ var _active := false
6
+
7
+ func get_observation():
8
+ pass
9
+
10
+ func activate():
11
+ _active = true
12
+
13
+ func deactivate():
14
+ _active = false
15
+
16
+ func _update_observation():
17
+ pass
18
+
19
+ func reset():
20
+ pass
addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends ISensor2D
2
+ class_name RaycastSensor2D
3
+ @tool
4
+
5
+ @export var n_rays := 16.0:
6
+ get: return n_rays
7
+ set(value):
8
+ n_rays = value
9
+ _update()
10
+
11
+ @export var ray_length := 200:# (float,5,200,5.0)
12
+ get: return ray_length
13
+ set(value):
14
+ ray_length = value
15
+ _update()
16
+ @export var cone_width := 360.0:# (float,5,360,5.0)
17
+ get: return cone_width
18
+ set(value):
19
+ cone_width = value
20
+ _update()
21
+
22
+ @export var debug_draw := false :
23
+ get: return debug_draw
24
+ set(value):
25
+ debug_draw = value
26
+ _update()
27
+
28
+
29
+ var _angles = []
30
+ var rays := []
31
+
32
+ func _update():
33
+ if Engine.is_editor_hint():
34
+ _spawn_nodes()
35
+
36
+ func _ready() -> void:
37
+ _spawn_nodes()
38
+
39
+
40
+ func _spawn_nodes():
41
+ for ray in rays:
42
+ ray.queue_free()
43
+ rays = []
44
+
45
+ _angles = []
46
+ var step = cone_width / (n_rays)
47
+ var start = step/2 - cone_width/2
48
+
49
+ for i in n_rays:
50
+ var angle = start + i * step
51
+ var ray = RayCast2D.new()
52
+ ray.set_target_position(Vector2(
53
+ ray_length*cos(deg_to_rad(angle)),
54
+ ray_length*sin(deg_to_rad(angle))
55
+ ))
56
+ ray.set_name("node_"+str(i))
57
+ ray.enabled = true
58
+ ray.collide_with_areas = true
59
+ add_child(ray)
60
+ rays.append(ray)
61
+
62
+
63
+ _angles.append(start + i * step)
64
+
65
+
66
+ func _physics_process(delta: float) -> void:
67
+ if self._active:
68
+ self._obs = calculate_raycasts()
69
+
70
+ func get_observation() -> Array:
71
+ if len(self._obs) == 0:
72
+ print("obs was null, forcing raycast update")
73
+ return self.calculate_raycasts()
74
+ return self._obs
75
+
76
+
77
+ func calculate_raycasts() -> Array:
78
+ var result = []
79
+ for ray in rays:
80
+ ray.force_raycast_update()
81
+ var distance = _get_raycast_distance(ray)
82
+ result.append(distance)
83
+ return result
84
+
85
+ func _get_raycast_distance(ray : RayCast2D) -> float :
86
+ if !ray.is_colliding():
87
+ return 0.0
88
+
89
+ var distance = (global_position - ray.get_collision_point()).length()
90
+ distance = clamp(distance, 0.0, ray_length)
91
+ return (ray_length - distance) / ray_length
92
+
93
+
94
+
addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.tscn ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=2 format=2]
2
+
3
+ [ext_resource path="res://addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd" type="Script" id=1]
4
+
5
+ [node name="RaycastSensor2D" type="Node2D"]
6
+ script = ExtResource( 1 )
addons/godot_rl_agents/sensors/sensors_3d/ExampleRaycastSensor3D.tscn ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [gd_scene format=3 uid="uid://biu787qh4woik"]
2
+
3
+ [node name="ExampleRaycastSensor3D" type="Node3D"]
4
+
5
+ [node name="Camera3D" type="Camera3D" parent="."]
6
+ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.804183, 0, 2.70146)
addons/godot_rl_agents/sensors/sensors_3d/ISensor3D.gd ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends Node3D
2
+ class_name ISensor3D
3
+
4
+ var _obs : Array
5
+ var _active := false
6
+
7
+ func get_observation():
8
+ pass
9
+
10
+ func activate():
11
+ _active = true
12
+
13
+ func deactivate():
14
+ _active = false
15
+
16
+ func _update_observation():
17
+ pass
18
+
19
+ func reset():
20
+ pass
addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.gd ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends Node3D
2
+ class_name RGBCameraSensor3D
3
+ var camera_pixels = null
4
+
5
+ @onready var camera_texture := $Control/TextureRect/CameraTexture as Sprite2D
6
+
7
+ func get_camera_pixel_encoding():
8
+ return camera_texture.get_texture().get_data().data["data"].hex_encode()
9
+
10
+ func get_camera_shape()-> Array:
11
+ return [$SubViewport.size[0], $SubViewport.size[1], 4]
addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.tscn ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=3 format=2]
2
+
3
+ [ext_resource path="res://addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.gd" type="Script" id=1]
4
+
5
+ [sub_resource type="ViewportTexture" id=1]
6
+ viewport_path = NodePath("SubViewport")
7
+
8
+ [node name="RGBCameraSensor3D" type="Node3D"]
9
+ script = ExtResource( 1 )
10
+
11
+ [node name="RemoteTransform3D" type="RemoteTransform3D" parent="."]
12
+ remote_path = NodePath("../SubViewport/Camera3D")
13
+
14
+ [node name="SubViewport" type="SubViewport" parent="."]
15
+ size = Vector2( 32, 32 )
16
+ render_target_update_mode = 3
17
+
18
+ [node name="Camera3D" type="Camera3D" parent="SubViewport"]
19
+ near = 0.5
20
+
21
+ [node name="Control" type="Control" parent="."]
22
+ anchor_right = 1.0
23
+ anchor_bottom = 1.0
24
+ __meta__ = {
25
+ "_edit_use_anchors_": false
26
+ }
27
+
28
+ [node name="TextureRect" type="ColorRect" parent="Control"]
29
+ offset_left = 1096.0
30
+ offset_top = 534.0
31
+ offset_right = 1114.0
32
+ offset_bottom = 552.0
33
+ scale = Vector2( 10, 10 )
34
+ color = Color( 0.00784314, 0.00784314, 0.00784314, 1 )
35
+ __meta__ = {
36
+ "_edit_use_anchors_": false
37
+ }
38
+
39
+ [node name="CameraTexture" type="Sprite2D" parent="Control/TextureRect"]
40
+ texture = SubResource( 1 )
41
+ offset = Vector2( 9, 9 )
42
+ flip_v = true
addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends ISensor3D
2
+ class_name RayCastSensor3D
3
+ @tool
4
+ @export_flags_3d_physics var collision_mask = 1:
5
+ get: return collision_mask
6
+ set(value):
7
+ collision_mask = value
8
+ _update()
9
+ @export_flags_3d_physics var boolean_class_mask = 1:
10
+ get: return boolean_class_mask
11
+ set(value):
12
+ boolean_class_mask = value
13
+ _update()
14
+
15
+ @export var n_rays_width := 6.0:
16
+ get: return n_rays_width
17
+ set(value):
18
+ n_rays_width = value
19
+ _update()
20
+
21
+ @export var n_rays_height := 6.0:
22
+ get: return n_rays_height
23
+ set(value):
24
+ n_rays_height = value
25
+ _update()
26
+
27
+ @export var ray_length := 10.0:
28
+ get: return ray_length
29
+ set(value):
30
+ ray_length = value
31
+ _update()
32
+
33
+ @export var cone_width := 60.0:
34
+ get: return cone_width
35
+ set(value):
36
+ cone_width = value
37
+ _update()
38
+
39
+ @export var cone_height := 60.0:
40
+ get: return cone_height
41
+ set(value):
42
+ cone_height = value
43
+ _update()
44
+
45
+ @export var collide_with_bodies := true:
46
+ get: return collide_with_bodies
47
+ set(value):
48
+ collide_with_bodies = value
49
+ _update()
50
+
51
+ @export var collide_with_areas := false:
52
+ get: return collide_with_areas
53
+ set(value):
54
+ collide_with_areas = value
55
+ _update()
56
+
57
+ @export var class_sensor := false
58
+
59
+ var rays := []
60
+ var geo = null
61
+
62
+ func _update():
63
+ if Engine.is_editor_hint():
64
+ _spawn_nodes()
65
+
66
+
67
+ func _ready() -> void:
68
+ _spawn_nodes()
69
+
70
+ func _spawn_nodes():
71
+ print("spawning nodes")
72
+ for ray in get_children():
73
+ ray.queue_free()
74
+ if geo:
75
+ geo.clear()
76
+ #$Lines.remove_points()
77
+ rays = []
78
+
79
+ var horizontal_step = cone_width / (n_rays_width)
80
+ var vertical_step = cone_height / (n_rays_height)
81
+
82
+ var horizontal_start = horizontal_step/2 - cone_width/2
83
+ var vertical_start = vertical_step/2 - cone_height/2
84
+
85
+ var points = []
86
+
87
+ for i in n_rays_width:
88
+ for j in n_rays_height:
89
+ var angle_w = horizontal_start + i * horizontal_step
90
+ var angle_h = vertical_start + j * vertical_step
91
+ #angle_h = 0.0
92
+ var ray = RayCast3D.new()
93
+ var cast_to = to_spherical_coords(ray_length, angle_w, angle_h)
94
+ ray.set_target_position(cast_to)
95
+
96
+ points.append(cast_to)
97
+
98
+ ray.set_name("node_"+str(i)+" "+str(j))
99
+ ray.enabled = true
100
+ ray.collide_with_bodies = collide_with_bodies
101
+ ray.collide_with_areas = collide_with_areas
102
+ ray.collision_mask = collision_mask
103
+ add_child(ray)
104
+ ray.set_owner(get_tree().edited_scene_root)
105
+ rays.append(ray)
106
+ ray.force_raycast_update()
107
+
108
+ # if Engine.editor_hint:
109
+ # _create_debug_lines(points)
110
+
111
+ func _create_debug_lines(points):
112
+ if not geo:
113
+ geo = ImmediateMesh.new()
114
+ add_child(geo)
115
+
116
+ geo.clear()
117
+ geo.begin(Mesh.PRIMITIVE_LINES)
118
+ for point in points:
119
+ geo.set_color(Color.AQUA)
120
+ geo.add_vertex(Vector3.ZERO)
121
+ geo.add_vertex(point)
122
+ geo.end()
123
+
124
+ func display():
125
+ if geo:
126
+ geo.display()
127
+
128
+ func to_spherical_coords(r, inc, azimuth) -> Vector3:
129
+ return Vector3(
130
+ r*sin(deg_to_rad(inc))*cos(deg_to_rad(azimuth)),
131
+ r*sin(deg_to_rad(azimuth)),
132
+ r*cos(deg_to_rad(inc))*cos(deg_to_rad(azimuth))
133
+ )
134
+
135
+ func get_observation() -> Array:
136
+ return self.calculate_raycasts()
137
+
138
+ func calculate_raycasts() -> Array:
139
+ var result = []
140
+ for ray in rays:
141
+ ray.set_enabled(true)
142
+ ray.force_raycast_update()
143
+ var distance = _get_raycast_distance(ray)
144
+
145
+ result.append(distance)
146
+ if class_sensor:
147
+ var hit_class = 0
148
+ if ray.get_collider():
149
+ var hit_collision_layer = ray.get_collider().collision_layer
150
+ hit_collision_layer = hit_collision_layer & collision_mask
151
+ hit_class = (hit_collision_layer & boolean_class_mask) > 0
152
+ result.append(hit_class)
153
+ ray.set_enabled(false)
154
+ return result
155
+
156
+ func _get_raycast_distance(ray : RayCast3D) -> float :
157
+ if !ray.is_colliding():
158
+ return 0.0
159
+
160
+ var distance = (global_transform.origin - ray.get_collision_point()).length()
161
+ distance = clamp(distance, 0.0, ray_length)
162
+ return (ray_length - distance) / ray_length
addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.tscn ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gd_scene load_steps=2 format=2]
2
+
3
+ [ext_resource path="res://addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd" type="Script" id=1]
4
+
5
+ [node name="RaycastSensor3D" type="Node3D"]
6
+ script = ExtResource( 1 )
7
+ n_rays_width = 4.0
8
+ n_rays_height = 2.0
9
+ ray_length = 11.0
10
+
11
+ [node name="node_0 2" type="RayCast3D" parent="."]
12
+ enabled = true
13
+ cast_to = Vector3( -4.06608, -2.84701, 9.81639 )
14
+ collide_with_areas = true
15
+
16
+ [node name="node_0 3" type="RayCast3D" parent="."]
17
+ enabled = true
18
+ cast_to = Vector3( -4.06608, 2.84701, 9.81639 )
19
+ collide_with_areas = true
20
+
21
+ [node name="node_1 0" type="RayCast3D" parent="."]
22
+ enabled = true
23
+ cast_to = Vector3( -1.38686, -2.84701, 10.5343 )
24
+ collide_with_areas = true
25
+
26
+ [node name="node_1 1" type="RayCast3D" parent="."]
27
+ enabled = true
28
+ cast_to = Vector3( -1.38686, 2.84701, 10.5343 )
29
+ collide_with_areas = true
30
+
31
+ [node name="node_2 0" type="RayCast3D" parent="."]
32
+ enabled = true
33
+ cast_to = Vector3( 1.38686, -2.84701, 10.5343 )
34
+ collide_with_areas = true
35
+
36
+ [node name="node_2 1" type="RayCast3D" parent="."]
37
+ enabled = true
38
+ cast_to = Vector3( 1.38686, 2.84701, 10.5343 )
39
+ collide_with_areas = true
40
+
41
+ [node name="node_3 0" type="RayCast3D" parent="."]
42
+ enabled = true
43
+ cast_to = Vector3( 4.06608, -2.84701, 9.81639 )
44
+ collide_with_areas = true
45
+
46
+ [node name="node_3 1" type="RayCast3D" parent="."]
47
+ enabled = true
48
+ cast_to = Vector3( 4.06608, 2.84701, 9.81639 )
49
+ collide_with_areas = true
addons/godot_rl_agents/sync.gd ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ extends Node
2
+ # --fixed-fps 2000 --disable-render-loop
3
+ @export var action_repeat := 8
4
+ @export var speed_up = 1
5
+ var n_action_steps = 0
6
+
7
+ const MAJOR_VERSION := "0"
8
+ const MINOR_VERSION := "3"
9
+ const DEFAULT_PORT := "11008"
10
+ const DEFAULT_SEED := "1"
11
+ const DEFAULT_ACTION_REPEAT := "8"
12
+ var stream : StreamPeerTCP = null
13
+ var connected = false
14
+ var message_center
15
+ var should_connect = true
16
+ var agents
17
+ var need_to_send_obs = false
18
+ var args = null
19
+ @onready var start_time = Time.get_ticks_msec()
20
+ var initialized = false
21
+ var just_reset = false
22
+
23
+
24
+ # Called when the node enters the scene tree for the first time.
25
+
26
+ func _ready():
27
+
28
+ await get_tree().root.ready
29
+ get_tree().set_pause(true)
30
+ _initialize()
31
+ await get_tree().create_timer(1.0).timeout
32
+ get_tree().set_pause(false)
33
+
34
+ func _get_agents():
35
+ agents = get_tree().get_nodes_in_group("AGENT")
36
+
37
+ func _set_heuristic(heuristic):
38
+ for agent in agents:
39
+ agent.set_heuristic(heuristic)
40
+
41
+ func _handshake():
42
+ print("performing handshake")
43
+
44
+ var json_dict = _get_dict_json_message()
45
+ assert(json_dict["type"] == "handshake")
46
+ var major_version = json_dict["major_version"]
47
+ var minor_version = json_dict["minor_version"]
48
+ if major_version != MAJOR_VERSION:
49
+ print("WARNING: major verison mismatch ", major_version, " ", MAJOR_VERSION)
50
+ if minor_version != MINOR_VERSION:
51
+ print("WARNING: minor verison mismatch ", minor_version, " ", MINOR_VERSION)
52
+
53
+ print("handshake complete")
54
+
55
+ func _get_dict_json_message():
56
+ # returns a dictionary from of the most recent message
57
+ # this is not waiting
58
+ while stream.get_available_bytes() == 0:
59
+ stream.poll()
60
+ if stream.get_status() != 2:
61
+ print("server disconnected status, closing")
62
+ get_tree().quit()
63
+ return null
64
+
65
+ OS.delay_usec(10)
66
+
67
+ var message = stream.get_string()
68
+ var json_data = JSON.parse_string(message)
69
+
70
+ return json_data
71
+
72
+ func _send_dict_as_json_message(dict):
73
+ stream.put_string(JSON.stringify(dict))
74
+
75
+ func _send_env_info():
76
+ var json_dict = _get_dict_json_message()
77
+ assert(json_dict["type"] == "env_info")
78
+
79
+ var message = {
80
+ "type" : "env_info",
81
+ #"obs_size": agents[0].get_obs_size(),
82
+ "observation_space": agents[0].get_obs_space(),
83
+ "action_space":agents[0].get_action_space(),
84
+ "n_agents": len(agents)
85
+ }
86
+ _send_dict_as_json_message(message)
87
+
88
+
89
+ func connect_to_server():
90
+ print("Waiting for one second to allow server to start")
91
+ OS.delay_msec(1000)
92
+ print("trying to connect to server")
93
+ stream = StreamPeerTCP.new()
94
+
95
+ # "localhost" was not working on windows VM, had to use the IP
96
+ var ip = "127.0.0.1"
97
+ var port = _get_port()
98
+ var connect = stream.connect_to_host(ip, port)
99
+ stream.set_no_delay(true) # TODO check if this improves performance or not
100
+ stream.poll()
101
+ return stream.get_status() == 2
102
+
103
+ func _get_args():
104
+ print("getting command line arguments")
105
+ # var arguments = {}
106
+ # for argument in OS.get_cmdline_args():
107
+ # # Parse valid command-line arguments into a dictionary
108
+ # if argument.find("=") > -1:
109
+ # var key_value = argument.split("=")
110
+ # arguments[key_value[0].lstrip("--")] = key_value[1]
111
+
112
+ var arguments = {}
113
+ for argument in OS.get_cmdline_args():
114
+ print(argument)
115
+ if argument.find("=") > -1:
116
+ var key_value = argument.split("=")
117
+ arguments[key_value[0].lstrip("--")] = key_value[1]
118
+ else:
119
+ # Options without an argument will be present in the dictionary,
120
+ # with the value set to an empty string.
121
+ arguments[argument.lstrip("--")] = ""
122
+
123
+ return arguments
124
+
125
+ func _get_speedup():
126
+ print(args)
127
+ return args.get("speedup", str(speed_up)).to_int()
128
+
129
+ func _get_port():
130
+ return args.get("port", DEFAULT_PORT).to_int()
131
+
132
+ func _set_seed():
133
+ var _seed = args.get("env_seed", DEFAULT_SEED).to_int()
134
+ seed(_seed)
135
+
136
+ func _set_action_repeat():
137
+ action_repeat = args.get("action_repeat", DEFAULT_ACTION_REPEAT).to_int()
138
+
139
+ func disconnect_from_server():
140
+ stream.disconnect_from_host()
141
+
142
+ func _initialize():
143
+ _get_agents()
144
+
145
+ args = _get_args()
146
+ Engine.physics_ticks_per_second = _get_speedup() * 60 # Replace with function body.
147
+ Engine.time_scale = _get_speedup() * 1.0
148
+ prints("physics ticks", Engine.physics_ticks_per_second, Engine.time_scale, _get_speedup(), speed_up)
149
+
150
+ connected = connect_to_server()
151
+ if connected:
152
+ _set_heuristic("model")
153
+ _handshake()
154
+ _send_env_info()
155
+ else:
156
+ _set_heuristic("human")
157
+
158
+ _set_seed()
159
+ _set_action_repeat()
160
+ initialized = true
161
+
162
+ func _physics_process(delta):
163
+ # two modes, human control, agent control
164
+ # pause tree, send obs, get actions, set actions, unpause tree
165
+ if n_action_steps % action_repeat != 0:
166
+ n_action_steps += 1
167
+ return
168
+
169
+ n_action_steps += 1
170
+
171
+ if connected:
172
+ get_tree().set_pause(true)
173
+
174
+ if just_reset:
175
+ just_reset = false
176
+ var obs = _get_obs_from_agents()
177
+
178
+ var reply = {
179
+ "type": "reset",
180
+ "obs": obs
181
+ }
182
+ _send_dict_as_json_message(reply)
183
+ # this should go straight to getting the action and setting it checked the agent, no need to perform one phyics tick
184
+ get_tree().set_pause(false)
185
+ return
186
+
187
+ if need_to_send_obs:
188
+ need_to_send_obs = false
189
+ var reward = _get_reward_from_agents()
190
+ var done = _get_done_from_agents()
191
+ #_reset_agents_if_done() # this ensures the new observation is from the next env instance : NEEDS REFACTOR
192
+
193
+ var obs = _get_obs_from_agents()
194
+
195
+ var reply = {
196
+ "type": "step",
197
+ "obs": obs,
198
+ "reward": reward,
199
+ "done": done
200
+ }
201
+ _send_dict_as_json_message(reply)
202
+
203
+ var handled = handle_message()
204
+ else:
205
+ _reset_agents_if_done()
206
+
207
+ func handle_message() -> bool:
208
+ # get json message: reset, step, close
209
+ var message = _get_dict_json_message()
210
+ if message["type"] == "close":
211
+ print("received close message, closing game")
212
+ get_tree().quit()
213
+ get_tree().set_pause(false)
214
+ return true
215
+
216
+ if message["type"] == "reset":
217
+ print("resetting all agents")
218
+ _reset_all_agents()
219
+ just_reset = true
220
+ get_tree().set_pause(false)
221
+ #print("resetting forcing draw")
222
+ # RenderingServer.force_draw()
223
+ # var obs = _get_obs_from_agents()
224
+ # print("obs ", obs)
225
+ # var reply = {
226
+ # "type": "reset",
227
+ # "obs": obs
228
+ # }
229
+ # _send_dict_as_json_message(reply)
230
+ return true
231
+
232
+ if message["type"] == "call":
233
+ var method = message["method"]
234
+ var returns = _call_method_on_agents(method)
235
+ var reply = {
236
+ "type": "call",
237
+ "returns": returns
238
+ }
239
+ print("calling method from Python")
240
+ _send_dict_as_json_message(reply)
241
+ return handle_message()
242
+
243
+ if message["type"] == "action":
244
+ var action = message["action"]
245
+ _set_agent_actions(action)
246
+ need_to_send_obs = true
247
+ get_tree().set_pause(false)
248
+ return true
249
+
250
+ print("message was not handled")
251
+ return false
252
+
253
+ func _call_method_on_agents(method):
254
+ var returns = []
255
+ for agent in agents:
256
+ returns.append(agent.call(method))
257
+
258
+ return returns
259
+
260
+
261
+ func _reset_agents_if_done():
262
+ for agent in agents:
263
+ if agent.get_done():
264
+ agent.set_done_false()
265
+
266
+ func _reset_all_agents():
267
+ for agent in agents:
268
+ agent.needs_reset = true
269
+ #agent.reset()
270
+
271
+ func _get_obs_from_agents():
272
+ var obs = []
273
+ for agent in agents:
274
+ obs.append(agent.get_obs())
275
+ return obs
276
+
277
+ func _get_reward_from_agents():
278
+ var rewards = []
279
+ for agent in agents:
280
+ rewards.append(agent.get_reward())
281
+ agent.zero_reward()
282
+ return rewards
283
+
284
+ func _get_done_from_agents():
285
+ var dones = []
286
+ for agent in agents:
287
+ var done = agent.get_done()
288
+ if done: agent.set_done_false()
289
+ dones.append(done)
290
+ return dones
291
+
292
+ func _set_agent_actions(actions):
293
+ for i in range(len(actions)):
294
+ agents[i].set_action(actions[i])
295
+
bin/VirtualCamera.pck ADDED
Binary file (121 kB). View file
 
bin/VirtualCamera.x86_64 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed68d749a5bc6e3e78fdf5764fcbf5493e8b9ebdb629f470be3c64c1f205b58f
3
+ size 64865512
default_env.tres ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ [gd_resource type="Environment" load_steps=2 format=2]
2
+
3
+ [sub_resource type="ProceduralSky" id=1]
4
+
5
+ [resource]
6
+ background_mode = 2
7
+ background_sky = SubResource( 1 )
export_presets.cfg ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [preset.0]
2
+
3
+ name="Linux/X11"
4
+ platform="Linux/X11"
5
+ runnable=true
6
+ custom_features=""
7
+ export_filter="all_resources"
8
+ include_filter=""
9
+ exclude_filter=""
10
+ export_path="../../builds/VirtualCamera/virtual_camera.x86_64"
11
+ script_export_mode=1
12
+ script_encryption_key=""
13
+
14
+ [preset.0.options]
15
+
16
+ custom_template/debug=""
17
+ custom_template/release=""
18
+ binary_format/64_bits=true
19
+ binary_format/embed_pck=false
20
+ texture_format/bptc=false
21
+ texture_format/s3tc=true
22
+ texture_format/etc=false
23
+ texture_format/etc2=false
24
+ texture_format/no_bptc_fallbacks=true