edbeeching HF staff commited on
Commit
5915f7a
1 Parent(s): e97dffc

Upload folder using huggingface_hub

Browse files
GridSensor3DExample.csproj ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <Project Sdk="Godot.NET.Sdk/4.2.1">
2
+ <PropertyGroup>
3
+ <TargetFramework>net6.0</TargetFramework>
4
+ <EnableDynamicLoading>true</EnableDynamicLoading>
5
+ <RootNamespace>GodotRLAgents</RootNamespace>
6
+ </PropertyGroup>
7
+ <ItemGroup>
8
+ <PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.15.1" />
9
+ </ItemGroup>
10
+ </Project>
GridSensor3DExample.csproj.old ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <Project Sdk="Godot.NET.Sdk/4.2.0">
2
+ <PropertyGroup>
3
+ <TargetFramework>net6.0</TargetFramework>
4
+ <EnableDynamicLoading>true</EnableDynamicLoading>
5
+ <RootNamespace>GodotRLAgents</RootNamespace>
6
+ </PropertyGroup>
7
+ <ItemGroup>
8
+ <PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.15.1" />
9
+ </ItemGroup>
10
+ </Project>
Ships.sln ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 
2
+ Microsoft Visual Studio Solution File, Format Version 12.00
3
+ # Visual Studio Version 17
4
+ VisualStudioVersion = 17.5.002.0
5
+ MinimumVisualStudioVersion = 10.0.40219.1
6
+ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GridSensor3DExample", "GridSensor3DExample.csproj", "{A868A006-56AC-4F69-96E4-F5035575497C}"
7
+ EndProject
8
+ Global
9
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+ Debug|Any CPU = Debug|Any CPU
11
+ Release|Any CPU = Release|Any CPU
12
+ EndGlobalSection
13
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+ {A868A006-56AC-4F69-96E4-F5035575497C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+ {A868A006-56AC-4F69-96E4-F5035575497C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16
+ {A868A006-56AC-4F69-96E4-F5035575497C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17
+ {A868A006-56AC-4F69-96E4-F5035575497C}.Release|Any CPU.Build.0 = Release|Any CPU
18
+ EndGlobalSection
19
+ GlobalSection(SolutionProperties) = preSolution
20
+ HideSolutionNode = FALSE
21
+ EndGlobalSection
22
+ GlobalSection(ExtensibilityGlobals) = postSolution
23
+ SolutionGuid = {CE243986-53C0-46FC-BBE8-16608759C311}
24
+ EndGlobalSection
25
+ EndGlobal
addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd CHANGED
@@ -61,11 +61,15 @@ 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")
 
61
 
62
  func _update():
63
  if Engine.is_editor_hint():
64
+ if is_node_ready():
65
+ _spawn_nodes()
66
 
67
  func _ready() -> void:
68
+ if Engine.is_editor_hint():
69
+ if get_child_count() == 0:
70
+ _spawn_nodes()
71
+ else:
72
+ _spawn_nodes()
73
 
74
  func _spawn_nodes():
75
  print("spawning nodes")
addons/godot_rl_agents/sync.gd CHANGED
@@ -1,5 +1,9 @@
1
  extends Node
 
2
  # --fixed-fps 2000 --disable-render-loop
 
 
 
3
  @export_range(1, 10, 1, "or_greater") var action_repeat := 8
4
  @export_range(1, 10, 1, "or_greater") var speed_up = 1
5
  @export var onnx_model_path := ""
@@ -26,7 +30,6 @@ var _action_space : Dictionary
26
  var _obs_space : Dictionary
27
 
28
  # Called when the node enters the scene tree for the first time.
29
-
30
  func _ready():
31
  await get_tree().root.ready
32
  get_tree().set_pause(true)
@@ -43,26 +46,27 @@ func _initialize():
43
  Engine.time_scale = _get_speedup() * 1.0
44
  prints("physics ticks", Engine.physics_ticks_per_second, Engine.time_scale, _get_speedup(), speed_up)
45
 
46
- # Run inference if onnx model path is set, otherwise wait for server connection
47
- var run_onnx_model_inference : bool = onnx_model_path != ""
48
- if run_onnx_model_inference:
49
- assert(FileAccess.file_exists(onnx_model_path), "Onnx Model Path set on Sync node does not exist: " + onnx_model_path)
50
- onnx_model = ONNXModel.new(onnx_model_path, 1)
51
- _set_heuristic("model")
52
- else:
53
- connected = connect_to_server()
54
- if connected:
55
- _set_heuristic("model")
56
- _handshake()
57
- _send_env_info()
58
- else:
59
- _set_heuristic("human")
60
-
 
61
  _set_seed()
62
  _set_action_repeat()
63
  initialized = true
64
 
65
- func _physics_process(delta):
66
  # two modes, human control, agent control
67
  # pause tree, send obs, get actions, set actions, unpause tree
68
  if n_action_steps % action_repeat != 0:
 
1
  extends Node
2
+
3
  # --fixed-fps 2000 --disable-render-loop
4
+
5
+ enum ControlModes {HUMAN, TRAINING, ONNX_INFERENCE}
6
+ @export var control_mode: ControlModes = ControlModes.TRAINING
7
  @export_range(1, 10, 1, "or_greater") var action_repeat := 8
8
  @export_range(1, 10, 1, "or_greater") var speed_up = 1
9
  @export var onnx_model_path := ""
 
30
  var _obs_space : Dictionary
31
 
32
  # Called when the node enters the scene tree for the first time.
 
33
  func _ready():
34
  await get_tree().root.ready
35
  get_tree().set_pause(true)
 
46
  Engine.time_scale = _get_speedup() * 1.0
47
  prints("physics ticks", Engine.physics_ticks_per_second, Engine.time_scale, _get_speedup(), speed_up)
48
 
49
+ _set_heuristic("human")
50
+ match control_mode:
51
+ ControlModes.TRAINING:
52
+ connected = connect_to_server()
53
+ if connected:
54
+ _set_heuristic("model")
55
+ _handshake()
56
+ _send_env_info()
57
+ else:
58
+ push_warning("Couldn't connect to Python server, using human controls instead. ",
59
+ "Did you start the training server using e.g. `gdrl` from the console?")
60
+ ControlModes.ONNX_INFERENCE:
61
+ assert(FileAccess.file_exists(onnx_model_path), "Onnx Model Path set on Sync node does not exist: %s" % onnx_model_path)
62
+ onnx_model = ONNXModel.new(onnx_model_path, 1)
63
+ _set_heuristic("model")
64
+
65
  _set_seed()
66
  _set_action_repeat()
67
  initialized = true
68
 
69
+ func _physics_process(_delta):
70
  # two modes, human control, agent control
71
  # pause tree, send obs, get actions, set actions, unpause tree
72
  if n_action_steps % action_repeat != 0:
bin/Ships.console.exe CHANGED
Binary files a/bin/Ships.console.exe and b/bin/Ships.console.exe differ
 
bin/Ships.exe CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2de407f42a3db0dece9ff075b69219a30493b90c67f0a14bc450b414fba39125
3
- size 71425536
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:910d1661cf406eb788be65369b4784b8bde02dd16e327fac690b501d08e9e886
3
+ size 69051392
bin/Ships.pck CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1ba3c3f08ad9b3b0b750fd116ffa92683db8db2a39fb1acb457a5f88abb91c6c
3
- size 3509200
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:263f8fcb2b07f49d3ea0f8b9e417b39cb07f1f2e93653d1e49f98e9ecf8f4268
3
+ size 3509248
bin/Ships.x86_64 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:843a1e5f8df1e6b2fe57ff86ca637436c7e1216f8409f2b079090c373548e86f
3
- size 72784744
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb6fa01639dd98489aac3e0dd5f9ecf0691b25b37a717f7380b1350d91ed23a4
3
+ size 61637496
health_bar.gd CHANGED
@@ -2,10 +2,10 @@ extends Sprite3D
2
 
3
  @onready var health_bar_2d = $SubViewport/HealthBar2D
4
 
 
5
  func _ready():
6
- #texture = $SubViewport.get_texture()
7
  update_health(3.0)
8
- pass
9
 
10
  func update_health(value):
11
  health_bar_2d.update_health(value, 3.0)
 
2
 
3
  @onready var health_bar_2d = $SubViewport/HealthBar2D
4
 
5
+
6
  func _ready():
 
7
  update_health(3.0)
8
+
9
 
10
  func update_health(value):
11
  health_bar_2d.update_health(value, 3.0)
mine.gd CHANGED
@@ -2,14 +2,6 @@ extends Node3D
2
 
3
  @onready var area_3d = $Area3D
4
 
5
- # Called when the node enters the scene tree for the first time.
6
- func _ready():
7
- pass # Replace with function body.
8
-
9
- # Called every frame. 'delta' is the elapsed time since the previous frame.
10
- func _process(delta):
11
- pass
12
-
13
  func _on_area_3d_body_entered(body):
14
  if body is Player:
15
  body.mine_hit()
 
2
 
3
  @onready var area_3d = $Area3D
4
 
 
 
 
 
 
 
 
 
5
  func _on_area_3d_body_entered(body):
6
  if body is Player:
7
  body.mine_hit()