From 6e6daf8028a1cfa0f00ac367fa7a482d781e3f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Che=CC=81nier?= Date: Tue, 1 Sep 2026 15:35:51 -0400 Subject: [PATCH 1/9] [68-create-a-new-biofeedback-module-for-the-propulsion-force] Added the multimesh for the total force. Kind of work, but sometimes stops. --- src/config.gd | 8 +++- src/devices/python_bridge/python_bridge.gd | 11 +++-- src/main.tscn | 3 ++ .../biofeedback_pushrim_kinetics.gd | 32 +++++++++++++ .../biofeedback_pushrim_kinetics.gd.uid | 1 + .../biofeedback_pushrim_kinetics.tscn | 48 +++++++++++++++++++ 6 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd create mode 100644 src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd.uid create mode 100644 src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn diff --git a/src/config.gd b/src/config.gd index 425799e..a70d4f5 100644 --- a/src/config.gd +++ b/src/config.gd @@ -37,7 +37,8 @@ var _defaults: Dictionary[String, Dictionary] = { "type": "float", "default": 0.62, "min": 0.40, - "max": 0.80 + "max": 0.80, + "step": 0.01, }, "player.pushrim_diameter": { @@ -47,7 +48,8 @@ var _defaults: Dictionary[String, Dictionary] = { "type": "float", "default": 0.54, "min": 0.40, - "max": 0.80 + "max": 0.80, + "step": 0.01, }, "player.camera.fov": { @@ -142,6 +144,8 @@ var _defaults: Dictionary[String, Dictionary] = { "min": 1, "max": 5 }, + "overlays.biofeedback_pushrim_kinetics.enabled": + {"order": 3.07, "label": "Biofeedback Pushrim Kinetics", "type": "bool", "default": false}, "devices.screens.front_floor_screens": {"order": 4.3, "label": "Front+floor screens"}, "devices.screens.front_floor_screens.enabled": {"order": 4.31, "label": "Enabled", "type": "bool", "default": false}, diff --git a/src/devices/python_bridge/python_bridge.gd b/src/devices/python_bridge/python_bridge.gd index 4fd13de..c337b9e 100644 --- a/src/devices/python_bridge/python_bridge.gd +++ b/src/devices/python_bridge/python_bridge.gd @@ -19,6 +19,8 @@ var _udp_receiver = PacketPeerUDP.new() var _udp_sender = PacketPeerUDP.new() var _udp_receiver_connected = false +var _python_process_id : int + func _ready(): # Launch Python app @@ -33,7 +35,7 @@ func _ready(): print("Cannot launch Python because Python app script is unset.") return - OS.create_process(python_app_path, [python_script_path], true) + _python_process_id = OS.create_process(python_app_path, [python_script_path], true) # Set UDP receiver and UDP sender _udp_receiver.bind(udp_receive_port) @@ -114,8 +116,11 @@ func send(command: String, args: Dictionary, run_mode: String): ## Debug overlay func get_debug_text() -> String: - var text = "" - text += "Python " + var text = "\n" + text += "Python PID: " + text += str(_python_process_id) + + text += "\nPython " if not _udp_receiver_connected: text += "not " text += "connected.\n" diff --git a/src/main.tscn b/src/main.tscn index 48af036..6d669f8 100644 --- a/src/main.tscn +++ b/src/main.tscn @@ -11,6 +11,7 @@ [ext_resource type="PackedScene" uid="uid://ck2thoxwmsujy" path="res://devices/d_box/d_box.tscn" id="5_5vw27"] [ext_resource type="PackedScene" uid="uid://c5tbnk1yth8r8" path="res://overlays/biofeedback_push_frequency/biofeedback_push_frequency.tscn" id="5_ycdy4"] [ext_resource type="PackedScene" uid="uid://utxy2vmv4wo7" path="res://devices/optitrack/optitrack.tscn" id="6_kek77"] +[ext_resource type="PackedScene" uid="uid://ccudr43mvulkw" path="res://overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn" id="6_vivmo"] [ext_resource type="PackedScene" uid="uid://k18bpclv0qnw" path="res://devices/screens/single_screen.tscn" id="8_efxa6"] [ext_resource type="PackedScene" uid="uid://bvnocfmlki4nf" path="res://devices/screens/front_floor_screens.tscn" id="9_dg77c"] [ext_resource type="PackedScene" uid="uid://x4hefxmnqe41" path="res://devices/python_bridge/python_bridge.tscn" id="10_dg77c"] @@ -18,8 +19,10 @@ [node name="main" type="Node" unique_id=502567777] script = ExtResource("1_0xm2m") available_overlays = Dictionary[String, PackedScene]({ +"": null, "overlays.biofeedback_push_frequency.enabled": ExtResource("5_ycdy4"), "overlays.biofeedback_push_pattern.enabled": ExtResource("4_dg77c"), +"overlays.biofeedback_pushrim_kinetics.enabled": ExtResource("6_vivmo"), "overlays.debug.enabled": ExtResource("4_272bh"), "overlays.speed_indicator.enabled": ExtResource("2_efxa6") }) diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd new file mode 100644 index 0000000..4a13956 --- /dev/null +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd @@ -0,0 +1,32 @@ +extends Node2D + +const N_POINTS := 100 + +@onready var multimesh_instance : MultiMeshInstance2D = %MultiMeshInstance2D + +var f_tot_curve : Array[float] = [] + +func _ready() -> void: + # Set initial curve to 0 + for i in N_POINTS: + f_tot_curve.append(0.0) + multimesh_instance.multimesh.instance_count = N_POINTS + + if Globals.main.has_node("PythonBridge"): + Globals.main.get_node("PythonBridge").send("biofeedback_pushrim_kinetics_connect", {"ip": "dummy"}, "once") + Globals.main.get_node("PythonBridge").send("biofeedback_pushrim_kinetics_process", {}, "start") + +func _process(_delta): + + # Check if received something + if Globals.main.has_node("PythonBridge"): + var result = Globals.main.get_node("PythonBridge").receive("biofeedback_pushrim_kinetics") + if result != {} and result["command"] == "biofeedback_pushrim_kinetics_process": + for i in N_POINTS: + f_tot_curve[i] = result["data"]["FtotCurve"][i] + + # Update the multimesh + for i in N_POINTS: + multimesh_instance.multimesh.set_instance_transform_2d(i, + Transform2D(0.0, Vector2(i, -f_tot_curve[i]))) + multimesh_instance.multimesh.set_instance_color(i, Color(1,0,0)) diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd.uid b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd.uid new file mode 100644 index 0000000..3d0dfd3 --- /dev/null +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd.uid @@ -0,0 +1 @@ +uid://ihas823kxmv8 diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn new file mode 100644 index 0000000..413492d --- /dev/null +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn @@ -0,0 +1,48 @@ +[gd_scene format=3 uid="uid://ccudr43mvulkw"] + +[ext_resource type="Script" uid="uid://ihas823kxmv8" path="res://overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd" id="1_vub0q"] + +[sub_resource type="QuadMesh" id="QuadMesh_6fgjp"] +size = Vector2(2, 2) + +[sub_resource type="MultiMesh" id="MultiMesh_knsph"] +use_colors = true +mesh = SubResource("QuadMesh_6fgjp") + +[sub_resource type="Theme" id="Theme_2n6hd"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hiv0f"] +bg_color = Color(0, 0, 0, 0.392157) +border_width_left = 4 +border_width_top = 4 +border_width_right = 4 +border_width_bottom = 4 +border_color = Color(1, 1, 1, 0.392157) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 + +[node name="BiofeedbackPushrimKinetics" type="Node2D" unique_id=2135710720] +script = ExtResource("1_vub0q") + +[node name="MultiMeshInstance2D" type="MultiMeshInstance2D" parent="." unique_id=1491659974] +unique_name_in_owner = true +position = Vector2(419, 227) +scale = Vector2(2, 2) +multimesh = SubResource("MultiMesh_knsph") + +[node name="OverlayFrame" type="PanelContainer" parent="." unique_id=1522539722] +offset_left = 390.0 +offset_top = 74.0 +offset_right = 750.0 +offset_bottom = 254.0 +theme = SubResource("Theme_2n6hd") +theme_override_styles/panel = SubResource("StyleBoxFlat_hiv0f") + +[node name="Label" type="Label" parent="." unique_id=1917131834] +offset_left = 393.0 +offset_top = 53.0 +offset_right = 444.0 +offset_bottom = 76.0 +text = "Forces" From cfc2837cb44c41e996da32657b4c5d42cb2dee33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Che=CC=81nier?= Date: Wed, 2 Sep 2026 11:30:25 -0400 Subject: [PATCH 2/9] [68-create-a-new-biofeedback-module-for-the-propulsion-force] Working, and started working on #78 --- src/devices/python_bridge/python_bridge.gd | 46 ++++++++++++------- .../biofeedback_pushrim_kinetics.gd | 40 ++++++++-------- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/devices/python_bridge/python_bridge.gd b/src/devices/python_bridge/python_bridge.gd index c337b9e..ad326e4 100644 --- a/src/devices/python_bridge/python_bridge.gd +++ b/src/devices/python_bridge/python_bridge.gd @@ -18,9 +18,7 @@ var queue_requests_by_id = {} # Queue storing received request data per id var _udp_receiver = PacketPeerUDP.new() var _udp_sender = PacketPeerUDP.new() var _udp_receiver_connected = false - -var _python_process_id : int - +var _signal_counter : int = 0 func _ready(): # Launch Python app @@ -35,7 +33,12 @@ func _ready(): print("Cannot launch Python because Python app script is unset.") return - _python_process_id = OS.create_process(python_app_path, [python_script_path], true) + if OS.get_name() == "macOS": + print("Launching a terminal window for Python Bridge...") + OS.create_process("/usr/bin/osascript", ["-e", 'tell app "Terminal" to do script "' + python_app_path + " " + python_script_path + '"']) + else: + OS.create_process(python_app_path, [python_script_path], true) + # Set UDP receiver and UDP sender _udp_receiver.bind(udp_receive_port) @@ -45,8 +48,7 @@ func _ready(): while _udp_receiver.get_available_packet_count() == 0: await get_tree().create_timer(1.0).timeout _udp_receiver_connected = true - if Config.get_value("devices.data_logging.enabled") == true: - SignalBus.python_connected.emit(_udp_receiver_connected) + SignalBus.python_connected.emit(_udp_receiver_connected) func _process(_delta): @@ -56,9 +58,6 @@ func _process(_delta): if _udp_receiver_connected: _process_received_packets() - if Config.get_value("devices.data_logging.enabled") == true: - SignalBus.python_connected.emit(_udp_receiver_connected) - ## Receive and save JSON data from Python bridge in requests queues func _process_received_packets(): @@ -67,9 +66,13 @@ func _process_received_packets(): var json_string = data.get_string_from_utf8() var json = JSON.new() json.parse(json_string) - - for id in queue_requests_by_id: - queue_requests_by_id[id].append(json.get_data()) + + if json.get_data() == {"id": "ready"}: + return + + var data_dict : Dictionary = json.get_data() + emit_signal(data_dict["id"], data_dict["value"]) + remove_user_signal(data_dict["id"]) ## Receive data from Python. @@ -110,17 +113,26 @@ func receive(id: String) -> Dictionary: ## "once" to launch the command once, "start" to run it continuously, and "stop" to ## stop from running it continuously. func send(command: String, args: Dictionary, run_mode: String): + #!TODO Remove var request = {"command": command, "args": args, "run_mode": run_mode} _udp_sender.put_packet(JSON.stringify(request).to_utf8_buffer()) +func run(command: String, args: Array, kwargs: Dictionary) -> Signal: + #!TODO Remove run_mode and change args when it's done in the python counterpart. + var id : String = command + "_" + str(Time.get_ticks_usec()) + "_" + str(_signal_counter) + _signal_counter += 1 + if _signal_counter >= 1000000: + _signal_counter = 0 + + var request = {"command": command, "kwargs": kwargs, "id": id} + _udp_sender.put_packet(JSON.stringify(request).to_utf8_buffer()) + add_user_signal(id) + return Signal(self, id) # Reference to the created signal + ## Debug overlay func get_debug_text() -> String: - var text = "\n" - text += "Python PID: " - text += str(_python_process_id) - - text += "\nPython " + var text = "\nPython " if not _udp_receiver_connected: text += "not " text += "connected.\n" diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd index 4a13956..cd2300a 100644 --- a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd @@ -2,31 +2,33 @@ extends Node2D const N_POINTS := 100 +@onready var n_answers := 0 @onready var multimesh_instance : MultiMeshInstance2D = %MultiMeshInstance2D var f_tot_curve : Array[float] = [] func _ready() -> void: - # Set initial curve to 0 + # Set initial curve to 0 for i in N_POINTS: f_tot_curve.append(0.0) multimesh_instance.multimesh.instance_count = N_POINTS - - if Globals.main.has_node("PythonBridge"): - Globals.main.get_node("PythonBridge").send("biofeedback_pushrim_kinetics_connect", {"ip": "dummy"}, "once") - Globals.main.get_node("PythonBridge").send("biofeedback_pushrim_kinetics_process", {}, "start") + await SignalBus.python_connected + await Globals.main.get_node("PythonBridge").run( + "biofeedback_pushrim_kinetics_connect", [], {"ip": "dummy"} + ) + update_loop() -func _process(_delta): - - # Check if received something - if Globals.main.has_node("PythonBridge"): - var result = Globals.main.get_node("PythonBridge").receive("biofeedback_pushrim_kinetics") - if result != {} and result["command"] == "biofeedback_pushrim_kinetics_process": - for i in N_POINTS: - f_tot_curve[i] = result["data"]["FtotCurve"][i] - - # Update the multimesh - for i in N_POINTS: - multimesh_instance.multimesh.set_instance_transform_2d(i, - Transform2D(0.0, Vector2(i, -f_tot_curve[i]))) - multimesh_instance.multimesh.set_instance_color(i, Color(1,0,0)) + +func update_loop() -> void: + while true: + var result = await Globals.main.get_node("PythonBridge").run( + "biofeedback_pushrim_kinetics_process", [], {} + ) + for i in N_POINTS: + f_tot_curve[i] = result["FtotCurve"][i] + + # Update the multimesh + for i in N_POINTS: + multimesh_instance.multimesh.set_instance_transform_2d(i, + Transform2D(0.0, Vector2(i, -f_tot_curve[i]))) + multimesh_instance.multimesh.set_instance_color(i, Color(1,0,0)) From eb8cbdc9fd251c0d49cc3c91793ccce593b0730b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Che=CC=81nier?= Date: Wed, 2 Sep 2026 12:15:32 -0400 Subject: [PATCH 3/9] [68-create-a-new-biofeedback-module-for-the-propulsion-force] New python_bridge functional for biofeedback_pushrim_kinetics --- src/config.gd | 2 +- src/devices/python_bridge/python_bridge.gd | 108 +++++++----------- .../biofeedback_pushrim_kinetics.gd | 28 ++--- src/signal_bus.gd | 17 ++- 4 files changed, 68 insertions(+), 87 deletions(-) diff --git a/src/config.gd b/src/config.gd index a70d4f5..ea27a0a 100644 --- a/src/config.gd +++ b/src/config.gd @@ -145,7 +145,7 @@ var _defaults: Dictionary[String, Dictionary] = { "max": 5 }, "overlays.biofeedback_pushrim_kinetics.enabled": - {"order": 3.07, "label": "Biofeedback Pushrim Kinetics", "type": "bool", "default": false}, + {"order": 3.07, "label": "Biofeedback Pushrim Kinetics", "type": "bool", "default": false}, "devices.screens.front_floor_screens": {"order": 4.3, "label": "Front+floor screens"}, "devices.screens.front_floor_screens.enabled": {"order": 4.31, "label": "Enabled", "type": "bool", "default": false}, diff --git a/src/devices/python_bridge/python_bridge.gd b/src/devices/python_bridge/python_bridge.gd index ad326e4..98be8ef 100644 --- a/src/devices/python_bridge/python_bridge.gd +++ b/src/devices/python_bridge/python_bridge.gd @@ -14,11 +14,10 @@ extends Node3D @export var udp_send_port: int = 4243 # Python port @export var udp_receive_port: int = 4242 # Godot port -var queue_requests_by_id = {} # Queue storing received request data per id var _udp_receiver = PacketPeerUDP.new() var _udp_sender = PacketPeerUDP.new() -var _udp_receiver_connected = false -var _signal_counter : int = 0 +var _signal_counter: int = 0 + func _ready(): # Launch Python app @@ -35,113 +34,88 @@ func _ready(): if OS.get_name() == "macOS": print("Launching a terminal window for Python Bridge...") - OS.create_process("/usr/bin/osascript", ["-e", 'tell app "Terminal" to do script "' + python_app_path + " " + python_script_path + '"']) + OS.create_process( + "/usr/bin/osascript", + [ + "-e", + ( + 'tell app "Terminal" to do script "' + + python_app_path + + " " + + python_script_path + + '"' + ) + ] + ) else: OS.create_process(python_app_path, [python_script_path], true) - # Set UDP receiver and UDP sender _udp_receiver.bind(udp_receive_port) _udp_sender.connect_to_host(udp_send_ip, udp_send_port) - # Waiting ping request from Python bridge - while _udp_receiver.get_available_packet_count() == 0: - await get_tree().create_timer(1.0).timeout - _udp_receiver_connected = true - SignalBus.python_connected.emit(_udp_receiver_connected) - func _process(_delta): if Globals.main: if not Config.get_value("devices.python_bridge.enabled"): queue_free() - if _udp_receiver_connected: - _process_received_packets() - -## Receive and save JSON data from Python bridge in requests queues -func _process_received_packets(): while _udp_receiver.get_available_packet_count() > 0: # We received something var data = _udp_receiver.get_packet() var json_string = data.get_string_from_utf8() var json = JSON.new() json.parse(json_string) - - if json.get_data() == {"id": "ready"}: + var data_dict: Dictionary = json.get_data() + + if data_dict["id"] == "ready": + # This is the only "return value" not associated to a call from + # Godot. Therefore there is no signal to emit or value to return. + SignalBus.python_bridge_connected.emit(true) + _signal_counter += 1 return - - var data_dict : Dictionary = json.get_data() + emit_signal(data_dict["id"], data_dict["value"]) remove_user_signal(data_dict["id"]) -## Receive data from Python. +## Run a Python command +## +## To use: +## result = await python_bridge.run(python_command, kwargs) ## ## Parameters ## ---------- -## id -## Name of the receive queue. If the receive queue does not exist yet, it is created. Each -## received data is appended to every receive queue, which ensures that calling receive() with -## a unique queue gives access to every received packets. +## command +## Python command, as defined in the COMMAND_DICT dictionary of main.py +## kwargs +## Optional. Arguments of the command, in the form {"argname": value, ...} ## ## Returns ## ------- -## Dictionary -## If no data is available, returns an empty dictionary. -## If data is available, returns a dictionary with keys "command", which is the name of the -## python command that sent this data, and "data", which is a dictionary with the actual -## data. -func receive(id: String) -> Dictionary: - if id not in queue_requests_by_id: - queue_requests_by_id[id] = [] - return {} - if queue_requests_by_id[id].size() > 0: - var last_data = queue_requests_by_id[id].pop_at(-1) - return last_data - return {} - - -## Run a Python command. -## -## Parameters -## ---------- -## command -## One of the available commands in the python_bridge.py's COMMAND_MAPPING -## args -## A dictionary containing any information required by the command -## run_mode -## "once" to launch the command once, "start" to run it continuously, and "stop" to -## stop from running it continuously. -func send(command: String, args: Dictionary, run_mode: String): - #!TODO Remove - var request = {"command": command, "args": args, "run_mode": run_mode} - _udp_sender.put_packet(JSON.stringify(request).to_utf8_buffer()) - - -func run(command: String, args: Array, kwargs: Dictionary) -> Signal: - #!TODO Remove run_mode and change args when it's done in the python counterpart. - var id : String = command + "_" + str(Time.get_ticks_usec()) + "_" + str(_signal_counter) +## signal +## A signal to await. The result of the Python function is returned with the +## signal. +func run(command: String, kwargs: Dictionary = {}) -> Signal: + var id: String = command + "_" + str(Time.get_ticks_usec()) + "_" + str(_signal_counter) _signal_counter += 1 if _signal_counter >= 1000000: - _signal_counter = 0 + _signal_counter = 1 var request = {"command": command, "kwargs": kwargs, "id": id} _udp_sender.put_packet(JSON.stringify(request).to_utf8_buffer()) add_user_signal(id) return Signal(self, id) # Reference to the created signal + ## Debug overlay func get_debug_text() -> String: - var text = "\nPython " - if not _udp_receiver_connected: - text += "not " - text += "connected.\n" + var text = "Received " + str(_signal_counter) + " UDP packets." return text ## Close the python app when the node exits the scene tree func _exit_tree(): - SignalBus.python_connected.emit(null) - send("close", {}, "once") + SignalBus.python_bridge_connected.emit() + await run("close") # Delay to allow other overlays/devices to shut down before this device await get_tree().create_timer(0.1).timeout diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd index cd2300a..4339107 100644 --- a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd @@ -2,33 +2,33 @@ extends Node2D const N_POINTS := 100 +var f_tot_curve: Array[float] = [] +var python_bridge: Node + @onready var n_answers := 0 -@onready var multimesh_instance : MultiMeshInstance2D = %MultiMeshInstance2D +@onready var multimesh_instance: MultiMeshInstance2D = %MultiMeshInstance2D -var f_tot_curve : Array[float] = [] func _ready() -> void: - # Set initial curve to 0 + # Set initial curve to 0 for i in N_POINTS: f_tot_curve.append(0.0) multimesh_instance.multimesh.instance_count = N_POINTS - await SignalBus.python_connected - await Globals.main.get_node("PythonBridge").run( - "biofeedback_pushrim_kinetics_connect", [], {"ip": "dummy"} - ) + await SignalBus.python_bridge_connected + python_bridge = Globals.main.get_node("PythonBridge") + await python_bridge.run("biofeedback_pushrim_kinetics_connect", {"ip": "dummy"}) update_loop() func update_loop() -> void: while true: - var result = await Globals.main.get_node("PythonBridge").run( - "biofeedback_pushrim_kinetics_process", [], {} - ) + var result = await python_bridge.run("biofeedback_pushrim_kinetics_process", {}) for i in N_POINTS: f_tot_curve[i] = result["FtotCurve"][i] - + # Update the multimesh for i in N_POINTS: - multimesh_instance.multimesh.set_instance_transform_2d(i, - Transform2D(0.0, Vector2(i, -f_tot_curve[i]))) - multimesh_instance.multimesh.set_instance_color(i, Color(1,0,0)) + multimesh_instance.multimesh.set_instance_transform_2d( + i, Transform2D(0.0, Vector2(i, -f_tot_curve[i])) + ) + multimesh_instance.multimesh.set_instance_color(i, Color(1, 0, 0)) diff --git a/src/signal_bus.gd b/src/signal_bus.gd index 099d470..1771989 100644 --- a/src/signal_bus.gd +++ b/src/signal_bus.gd @@ -1,11 +1,18 @@ -## This script sets up a Global Variable of type Autoload -## It can hold instances of different signals. Each receives information -## from a single script of interest +## This script sets up a signal bus used to communicate events between modules +## without having to manage if a module is loaded or not. +## +## Please do not add new signals before discussing on the WheelSims issue +## tracker, so that this signal bus stays clean. extends Node -# signal pertaining to python ping (python_bridge.gd) +# Global signals generated by python_bridge + +## Sent when Godot receives "ready" from Python. Each module that requires +## python_bridge should await SignalBus.python_bridge_connected in its +## _ready() function, to be sure that its commands will then be received by +## Python. @warning_ignore("unused_signal") -signal python_connected +signal python_bridge_connected # signal pertaining to the current scene (main.gd) @warning_ignore("unused_signal") From 4489e92bdf24f6de5ef4ece730e2a11c63c0c5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Che=CC=81nier?= Date: Wed, 2 Sep 2026 12:34:03 -0400 Subject: [PATCH 4/9] [68-create-a-new-biofeedback-module-for-the-propulsion-force] Adapted data_logging to new python_bridge --- src/devices/data_logging/data_logging.gd | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/devices/data_logging/data_logging.gd b/src/devices/data_logging/data_logging.gd index c451bb6..3dc3688 100644 --- a/src/devices/data_logging/data_logging.gd +++ b/src/devices/data_logging/data_logging.gd @@ -26,7 +26,7 @@ func _scene_signal_received(scene_name): # If a trial was in progress (i.e. previous scene is not blank), end it if scenes["current"] != "": if logging["current"] == true and Globals.main.has_node("PythonBridge"): - Globals.main.get_node("PythonBridge").send("end_trial", data, "once") + Globals.main.get_node("PythonBridge").run("end_trial", data) player_trajectory["position"] = NAN player_trajectory["rotation"] = NAN @@ -39,7 +39,7 @@ func _scene_signal_received(scene_name): and scene_name != "" and Globals.main.has_node("PythonBridge") ): - Globals.main.get_node("PythonBridge").send("create_trial", data, "once") + Globals.main.get_node("PythonBridge").run("create_trial", data) # called everytime a signal is received from player.gd to save it @@ -60,7 +60,7 @@ func _python_signal_received(connection): if Config.get_value("devices.data_logging.enabled"): update_logging() - Globals.main.get_node("PythonBridge").send(connection_command, data, "once") + Globals.main.get_node("PythonBridge").run(connection_command, data) # Update logging on/off variables @@ -85,8 +85,8 @@ func update_data(): func _ready() -> void: update_logging() - if SignalBus.python_connected.is_connected(_python_signal_received) == false: - SignalBus.python_connected.connect(_python_signal_received) + if SignalBus.python_bridge_connected.is_connected(_python_signal_received) == false: + SignalBus.python_bridge_connected.connect(_python_signal_received) if Config.get_value("devices.data_logging.player_trajectory") == true: SignalBus.player_trajectory.connect(_player_signal_received) @@ -111,18 +111,18 @@ func _process(_delta: float) -> void: if logging["current"] == true: # Start logging if this is the first frame for which current_logging is enabled if logging["past"] == false: - Globals.main.get_node("PythonBridge").send("start_logging", data, "once") + Globals.main.get_node("PythonBridge").run("start_logging", data) # If a scene was already initiated before logging, start a trial and update scene if scenes["current"] != "": - Globals.main.get_node("PythonBridge").send("create_trial", data, "once") + Globals.main.get_node("PythonBridge").run("create_trial", data) # If any scene is running, send player data at each frame if scenes["current"] != "": - Globals.main.get_node("PythonBridge").send("data_logging", data, "once") + Globals.main.get_node("PythonBridge").run("data_logging", data) # Otherwise, if logging is not currently on but was in the previous frame, end the process elif logging["past"] == true: - Globals.main.get_node("PythonBridge").send("end_trial", data, "once") + Globals.main.get_node("PythonBridge").run("end_trial", data) player_trajectory["position"] = NAN player_trajectory["rotation"] = NAN From 58f93cf77417d5095f7cab90ebb2fa84fd449d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Che=CC=81nier?= Date: Thu, 10 Sep 2026 09:34:17 -0400 Subject: [PATCH 5/9] [68-create-a-new-biofeedback-module-for-the-propulsion-force] Changing kinematic biofeedback for one module --- src/config.gd | 18 ++++-- src/main.tscn | 6 +- .../angle_contact.gd | 0 .../angle_contact.gd.uid | 0 .../biofeedback_kinematics.gd | 13 ++++ .../biofeedback_kinematics.gd.uid | 1 + .../biofeedback_kinematics.tscn | 12 ++++ .../biofeedback_push_frequency.gd | 0 .../biofeedback_push_frequency.gd.uid | 0 .../biofeedback_push_frequency.tscn | 2 +- .../biofeedback_push_pattern.gd | 0 .../biofeedback_push_pattern.gd.uid | 0 .../biofeedback_push_pattern.tscn | 14 ++--- .../biofeedback_push_pattern_gui.gd | 0 .../biofeedback_push_pattern_gui.gd.uid | 0 .../biofeedback_push_pattern_gui.tscn | 2 +- .../hand.gd | 0 .../hand.gd.uid | 0 .../last_push_pattern.gd | 0 .../last_push_pattern.gd.uid | 0 .../rear_wheel.gd | 0 .../rear_wheel.gd.uid | 0 .../trail_hand.gd | 0 .../trail_hand.gd.uid | 0 .../biofeedback_pushrim_kinetics.gd | 31 +++++++--- .../biofeedback_pushrim_kinetics.tscn | 59 +++++++++++++------ src/project.godot | 2 +- 27 files changed, 114 insertions(+), 46 deletions(-) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/angle_contact.gd (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/angle_contact.gd.uid (100%) create mode 100644 src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd create mode 100644 src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd.uid create mode 100644 src/overlays/biofeedback_kinematics/biofeedback_kinematics.tscn rename src/overlays/{biofeedback_push_frequency => biofeedback_kinematics}/biofeedback_push_frequency.gd (100%) rename src/overlays/{biofeedback_push_frequency => biofeedback_kinematics}/biofeedback_push_frequency.gd.uid (100%) rename src/overlays/{biofeedback_push_frequency => biofeedback_kinematics}/biofeedback_push_frequency.tscn (98%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/biofeedback_push_pattern.gd (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/biofeedback_push_pattern.gd.uid (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/biofeedback_push_pattern.tscn (97%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/biofeedback_push_pattern_gui.gd (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/biofeedback_push_pattern_gui.gd.uid (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/biofeedback_push_pattern_gui.tscn (97%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/hand.gd (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/hand.gd.uid (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/last_push_pattern.gd (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/last_push_pattern.gd.uid (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/rear_wheel.gd (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/rear_wheel.gd.uid (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/trail_hand.gd (100%) rename src/overlays/{biofeedback_push_pattern => biofeedback_kinematics}/trail_hand.gd.uid (100%) diff --git a/src/config.gd b/src/config.gd index ea27a0a..142c4a7 100644 --- a/src/config.gd +++ b/src/config.gd @@ -11,6 +11,10 @@ ## and user modifications to the configuration panel calls its corresponding set_value. extends Node +## Emitted with the config id as argument on configuration change. +signal modified + + # ------------------------------------------------------------------- # Private variables and functions # ------------------------------------------------------------------- @@ -104,8 +108,10 @@ var _defaults: Dictionary[String, Dictionary] = { "overlays.speed_indicator.enabled": {"order": 3.01, "label": "Speed indicator", "type": "bool", "default": true}, "overlays.debug.enabled": {"order": 3.02, "label": "Debug", "type": "bool", "default": false}, + "overlays.biofeedback_kinematics.enabled": + {"order": 3.02, "label": "Biofeedback: Kinematics", "type": "bool", "default": false}, "overlays.biofeedback_push_pattern.enabled": - {"order": 3.03, "label": "Biofeedback Push pattern", "type": "bool", "default": false}, + {"order": 3.03, "label": "Push Pattern", "type": "bool", "default": false}, "overlays.contact_angle_start": { "order": 3.04, @@ -127,7 +133,11 @@ var _defaults: Dictionary[String, Dictionary] = { "max": 140.0 }, "overlays.biofeedback_push_frequency.enabled": - {"order": 3.06, "label": "Biofeedback Push Frequency", "type": "bool", "default": false}, + {"order": 3.06, "label": "Push Frequency", "type": "bool", "default": false}, + "overlays.biofeedback_pushrim_kinetics.enabled": + {"order": 3.07, "label": "Biofeedback: Pushrim Kinetics", "type": "bool", "default": false}, + "overlays.biofeedback_pushrim_kinetics.target_force": + {"order": 3.08, "label": "Target Force", "type": "float", "default": 50.0, "min": 25.0, "max": 125.0}, "devices": {"order": 4, "label": "DEVICE SETTINGS"}, "devices.screens": {"order": 4.1, "label": "Screens"}, "devices.screens.single_screen": {"order": 4.2, "label": "Single screen"}, @@ -144,8 +154,6 @@ var _defaults: Dictionary[String, Dictionary] = { "min": 1, "max": 5 }, - "overlays.biofeedback_pushrim_kinetics.enabled": - {"order": 3.07, "label": "Biofeedback Pushrim Kinetics", "type": "bool", "default": false}, "devices.screens.front_floor_screens": {"order": 4.3, "label": "Front+floor screens"}, "devices.screens.front_floor_screens.enabled": {"order": 4.31, "label": "Enabled", "type": "bool", "default": false}, @@ -357,6 +365,8 @@ func set_value(key: String, value): # Tell everyone that config has been modified for caller_id in _modified: _modified[caller_id][key] = true + # Send the modified signal for other modules to react to it + modified.emit(key) ## Has value been changed since last call with a given caller_id? diff --git a/src/main.tscn b/src/main.tscn index 6d669f8..19cb857 100644 --- a/src/main.tscn +++ b/src/main.tscn @@ -7,9 +7,8 @@ [ext_resource type="Script" uid="uid://db602oks11677" path="res://config.gd" id="3_h2yge"] [ext_resource type="PackedScene" uid="uid://xwtfx6p27vlm" path="res://devices/motorized_rollers/motorized_rollers.tscn" id="4_5vw27"] [ext_resource type="PackedScene" uid="uid://f24s3bar65fp" path="res://overlays/debug/debug.tscn" id="4_272bh"] -[ext_resource type="PackedScene" uid="uid://bm1b5ewq26kcl" path="res://overlays/biofeedback_push_pattern/biofeedback_push_pattern.tscn" id="4_dg77c"] [ext_resource type="PackedScene" uid="uid://ck2thoxwmsujy" path="res://devices/d_box/d_box.tscn" id="5_5vw27"] -[ext_resource type="PackedScene" uid="uid://c5tbnk1yth8r8" path="res://overlays/biofeedback_push_frequency/biofeedback_push_frequency.tscn" id="5_ycdy4"] +[ext_resource type="PackedScene" uid="uid://dkk1u1dxvshbj" path="res://overlays/biofeedback_kinematics/biofeedback_kinematics.tscn" id="5_w48qg"] [ext_resource type="PackedScene" uid="uid://utxy2vmv4wo7" path="res://devices/optitrack/optitrack.tscn" id="6_kek77"] [ext_resource type="PackedScene" uid="uid://ccudr43mvulkw" path="res://overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn" id="6_vivmo"] [ext_resource type="PackedScene" uid="uid://k18bpclv0qnw" path="res://devices/screens/single_screen.tscn" id="8_efxa6"] @@ -20,8 +19,7 @@ script = ExtResource("1_0xm2m") available_overlays = Dictionary[String, PackedScene]({ "": null, -"overlays.biofeedback_push_frequency.enabled": ExtResource("5_ycdy4"), -"overlays.biofeedback_push_pattern.enabled": ExtResource("4_dg77c"), +"overlays.biofeedback_kinematics.enabled": ExtResource("5_w48qg"), "overlays.biofeedback_pushrim_kinetics.enabled": ExtResource("6_vivmo"), "overlays.debug.enabled": ExtResource("4_272bh"), "overlays.speed_indicator.enabled": ExtResource("2_efxa6") diff --git a/src/overlays/biofeedback_push_pattern/angle_contact.gd b/src/overlays/biofeedback_kinematics/angle_contact.gd similarity index 100% rename from src/overlays/biofeedback_push_pattern/angle_contact.gd rename to src/overlays/biofeedback_kinematics/angle_contact.gd diff --git a/src/overlays/biofeedback_push_pattern/angle_contact.gd.uid b/src/overlays/biofeedback_kinematics/angle_contact.gd.uid similarity index 100% rename from src/overlays/biofeedback_push_pattern/angle_contact.gd.uid rename to src/overlays/biofeedback_kinematics/angle_contact.gd.uid diff --git a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd new file mode 100644 index 0000000..c239aec --- /dev/null +++ b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd @@ -0,0 +1,13 @@ +extends Node2D + +var python_bridge: Node + +func _ready() -> void: + await SignalBus.python_bridge_connected + python_bridge = Globals.main.get_node("PythonBridge") + await python_bridge.run("biofeedback_kinematics_connect", {}) + update_loop() + +func update_loop() -> void: + #!TODO Call Python and the update functions from both overlays + pass diff --git a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd.uid b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd.uid new file mode 100644 index 0000000..753accb --- /dev/null +++ b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd.uid @@ -0,0 +1 @@ +uid://cgmtlqtd2o0ny diff --git a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.tscn b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.tscn new file mode 100644 index 0000000..cd6dd0a --- /dev/null +++ b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.tscn @@ -0,0 +1,12 @@ +[gd_scene format=3 uid="uid://dkk1u1dxvshbj"] + +[ext_resource type="PackedScene" uid="uid://c5tbnk1yth8r8" path="res://overlays/biofeedback_kinematics/biofeedback_push_frequency.tscn" id="1_boggs"] +[ext_resource type="Script" uid="uid://cgmtlqtd2o0ny" path="res://overlays/biofeedback_kinematics/biofeedback_kinematics.gd" id="1_ib00y"] +[ext_resource type="PackedScene" uid="uid://bm1b5ewq26kcl" path="res://overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn" id="2_ib00y"] + +[node name="BiofeedbackKinematics" type="Node2D" unique_id=905171298] +script = ExtResource("1_ib00y") + +[node name="BiofeedbackPushFrequency" parent="." unique_id=1961947020 instance=ExtResource("1_boggs")] + +[node name="BiofeedbackPushPattern" parent="." unique_id=2135710720 instance=ExtResource("2_ib00y")] diff --git a/src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.gd b/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd similarity index 100% rename from src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.gd rename to src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd diff --git a/src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.gd.uid b/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd.uid similarity index 100% rename from src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.gd.uid rename to src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd.uid diff --git a/src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.tscn b/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.tscn similarity index 98% rename from src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.tscn rename to src/overlays/biofeedback_kinematics/biofeedback_push_frequency.tscn index ffae989..ddb06cf 100644 --- a/src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.tscn +++ b/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://c5tbnk1yth8r8"] -[ext_resource type="Script" uid="uid://dshp4p67kpaqf" path="res://overlays/biofeedback_push_frequency/biofeedback_push_frequency.gd" id="1_1j4x4"] +[ext_resource type="Script" uid="uid://dshp4p67kpaqf" path="res://overlays/biofeedback_kinematics/biofeedback_push_frequency.gd" id="1_1j4x4"] [sub_resource type="Theme" id="Theme_lgowx"] diff --git a/src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.gd b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd similarity index 100% rename from src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.gd rename to src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd diff --git a/src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.gd.uid b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd.uid similarity index 100% rename from src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.gd.uid rename to src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd.uid diff --git a/src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.tscn b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn similarity index 97% rename from src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.tscn rename to src/overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn index b05773a..bdaee2b 100644 --- a/src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.tscn +++ b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn @@ -2,16 +2,16 @@ [ext_resource type="PackedScene" uid="uid://bi4w50l5uqado" path="res://objects/optitrack/forearm_cluster_right/forearm_cluster_right.tscn" id="1_2n6hd"] [ext_resource type="PackedScene" uid="uid://dwlinbk7uaug" path="res://objects/wheelchair/rear_wheel.tscn" id="1_hiv0f"] -[ext_resource type="Script" uid="uid://xko3m2vsf5ak" path="res://overlays/biofeedback_push_pattern/biofeedback_push_pattern.gd" id="1_j7inm"] +[ext_resource type="Script" uid="uid://xko3m2vsf5ak" path="res://overlays/biofeedback_kinematics/biofeedback_push_pattern.gd" id="1_j7inm"] [ext_resource type="PackedScene" uid="uid://c1ynlvcc8h1vj" path="res://objects/optitrack/forearm_cluster_left/forearm_cluster_left.tscn" id="2_hiv0f"] -[ext_resource type="PackedScene" uid="uid://dplhvslsrr6oi" path="res://overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.tscn" id="2_jxkd3"] -[ext_resource type="Script" uid="uid://bffbdeose3vjm" path="res://overlays/biofeedback_push_pattern/hand.gd" id="2_l04ny"] +[ext_resource type="PackedScene" uid="uid://dplhvslsrr6oi" path="res://overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.tscn" id="2_jxkd3"] +[ext_resource type="Script" uid="uid://bffbdeose3vjm" path="res://overlays/biofeedback_kinematics/hand.gd" id="2_l04ny"] [ext_resource type="PackedScene" uid="uid://bcfu5sx4m6hm3" path="res://objects/wheelchair/angle_contact.tscn" id="3_ss2qs"] [ext_resource type="PackedScene" uid="uid://ds06t01fw7lcb" path="res://objects/wheelchair/handrim.tscn" id="4_8bgme"] -[ext_resource type="Script" uid="uid://b8g4t15ows352" path="res://overlays/biofeedback_push_pattern/rear_wheel.gd" id="5_nqdaa"] -[ext_resource type="Script" uid="uid://dkxhvcukp6fi2" path="res://overlays/biofeedback_push_pattern/angle_contact.gd" id="8_tdhcr"] -[ext_resource type="Script" uid="uid://dyf4x7j1o2k7q" path="res://overlays/biofeedback_push_pattern/trail_hand.gd" id="10_tdhcr"] -[ext_resource type="Script" uid="uid://c4ps4n81cxcfr" path="res://overlays/biofeedback_push_pattern/last_push_pattern.gd" id="11_itwwm"] +[ext_resource type="Script" uid="uid://b8g4t15ows352" path="res://overlays/biofeedback_kinematics/rear_wheel.gd" id="5_nqdaa"] +[ext_resource type="Script" uid="uid://dkxhvcukp6fi2" path="res://overlays/biofeedback_kinematics/angle_contact.gd" id="8_tdhcr"] +[ext_resource type="Script" uid="uid://dyf4x7j1o2k7q" path="res://overlays/biofeedback_kinematics/trail_hand.gd" id="10_tdhcr"] +[ext_resource type="Script" uid="uid://c4ps4n81cxcfr" path="res://overlays/biofeedback_kinematics/last_push_pattern.gd" id="11_itwwm"] [sub_resource type="Theme" id="Theme_2n6hd"] diff --git a/src/overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.gd b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.gd similarity index 100% rename from src/overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.gd rename to src/overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.gd diff --git a/src/overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.gd.uid b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.gd.uid similarity index 100% rename from src/overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.gd.uid rename to src/overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.gd.uid diff --git a/src/overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.tscn b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.tscn similarity index 97% rename from src/overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.tscn rename to src/overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.tscn index 0b2a6cd..c0313a4 100644 --- a/src/overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.tscn +++ b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://dplhvslsrr6oi"] -[ext_resource type="Script" uid="uid://bbwd1obrx2ctc" path="res://overlays/biofeedback_push_pattern/biofeedback_push_pattern_gui.gd" id="1_tlu87"] +[ext_resource type="Script" uid="uid://bbwd1obrx2ctc" path="res://overlays/biofeedback_kinematics/biofeedback_push_pattern_gui.gd" id="1_tlu87"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rspjr"] bg_color = Color(0, 0, 0, 1) diff --git a/src/overlays/biofeedback_push_pattern/hand.gd b/src/overlays/biofeedback_kinematics/hand.gd similarity index 100% rename from src/overlays/biofeedback_push_pattern/hand.gd rename to src/overlays/biofeedback_kinematics/hand.gd diff --git a/src/overlays/biofeedback_push_pattern/hand.gd.uid b/src/overlays/biofeedback_kinematics/hand.gd.uid similarity index 100% rename from src/overlays/biofeedback_push_pattern/hand.gd.uid rename to src/overlays/biofeedback_kinematics/hand.gd.uid diff --git a/src/overlays/biofeedback_push_pattern/last_push_pattern.gd b/src/overlays/biofeedback_kinematics/last_push_pattern.gd similarity index 100% rename from src/overlays/biofeedback_push_pattern/last_push_pattern.gd rename to src/overlays/biofeedback_kinematics/last_push_pattern.gd diff --git a/src/overlays/biofeedback_push_pattern/last_push_pattern.gd.uid b/src/overlays/biofeedback_kinematics/last_push_pattern.gd.uid similarity index 100% rename from src/overlays/biofeedback_push_pattern/last_push_pattern.gd.uid rename to src/overlays/biofeedback_kinematics/last_push_pattern.gd.uid diff --git a/src/overlays/biofeedback_push_pattern/rear_wheel.gd b/src/overlays/biofeedback_kinematics/rear_wheel.gd similarity index 100% rename from src/overlays/biofeedback_push_pattern/rear_wheel.gd rename to src/overlays/biofeedback_kinematics/rear_wheel.gd diff --git a/src/overlays/biofeedback_push_pattern/rear_wheel.gd.uid b/src/overlays/biofeedback_kinematics/rear_wheel.gd.uid similarity index 100% rename from src/overlays/biofeedback_push_pattern/rear_wheel.gd.uid rename to src/overlays/biofeedback_kinematics/rear_wheel.gd.uid diff --git a/src/overlays/biofeedback_push_pattern/trail_hand.gd b/src/overlays/biofeedback_kinematics/trail_hand.gd similarity index 100% rename from src/overlays/biofeedback_push_pattern/trail_hand.gd rename to src/overlays/biofeedback_kinematics/trail_hand.gd diff --git a/src/overlays/biofeedback_push_pattern/trail_hand.gd.uid b/src/overlays/biofeedback_kinematics/trail_hand.gd.uid similarity index 100% rename from src/overlays/biofeedback_push_pattern/trail_hand.gd.uid rename to src/overlays/biofeedback_kinematics/trail_hand.gd.uid diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd index 4339107..7b1becc 100644 --- a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd @@ -1,19 +1,24 @@ extends Node2D -const N_POINTS := 100 +const N_POINTS := 300 var f_tot_curve: Array[float] = [] var python_bridge: Node @onready var n_answers := 0 -@onready var multimesh_instance: MultiMeshInstance2D = %MultiMeshInstance2D + +## Set FlimitCurve and FlimitValue to a given value. +func _set_f_limit(value:float): + %FtargetCurve.position.y = -value + %FtargetValue.text = str(int(value)) func _ready() -> void: - # Set initial curve to 0 + # Set initial values for i in N_POINTS: f_tot_curve.append(0.0) - multimesh_instance.multimesh.instance_count = N_POINTS + _set_f_limit(Config.get_value("overlays.biofeedback_pushrim_kinetics.target_force")) + await SignalBus.python_bridge_connected python_bridge = Globals.main.get_node("PythonBridge") await python_bridge.run("biofeedback_pushrim_kinetics_connect", {"ip": "dummy"}) @@ -23,12 +28,20 @@ func _ready() -> void: func update_loop() -> void: while true: var result = await python_bridge.run("biofeedback_pushrim_kinetics_process", {}) + var f_peak = str(int(result["Fpeak"])) + if f_peak == "0": + f_peak = "" + %FpeakLabel.text = f_peak for i in N_POINTS: f_tot_curve[i] = result["FtotCurve"][i] - # Update the multimesh + var new_points : Array[Vector2] = [] for i in N_POINTS: - multimesh_instance.multimesh.set_instance_transform_2d( - i, Transform2D(0.0, Vector2(i, -f_tot_curve[i])) - ) - multimesh_instance.multimesh.set_instance_color(i, Color(1, 0, 0)) + new_points.append(Vector2(i, -f_tot_curve[i])) + %FtotCurve.points = PackedVector2Array(new_points) + +func _process(_delta) -> void: + if Config.value_changed("biofeedback_pushrim_kinetics", "overlays.biofeedback_pushrim_kinetics.target_force"): + _set_f_limit(Config.get_value("overlays.biofeedback_pushrim_kinetics.target_force")) + if not Config.get_value("overlays.biofeedback_pushrim_kinetics.enabled"): + queue_free() diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn index 413492d..eaecfac 100644 --- a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn @@ -2,13 +2,6 @@ [ext_resource type="Script" uid="uid://ihas823kxmv8" path="res://overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd" id="1_vub0q"] -[sub_resource type="QuadMesh" id="QuadMesh_6fgjp"] -size = Vector2(2, 2) - -[sub_resource type="MultiMesh" id="MultiMesh_knsph"] -use_colors = true -mesh = SubResource("QuadMesh_6fgjp") - [sub_resource type="Theme" id="Theme_2n6hd"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hiv0f"] @@ -23,15 +16,12 @@ corner_radius_top_right = 10 corner_radius_bottom_right = 10 corner_radius_bottom_left = 10 +[sub_resource type="LabelSettings" id="LabelSettings_rpek1"] +font_color = Color(1, 1, 0, 1) + [node name="BiofeedbackPushrimKinetics" type="Node2D" unique_id=2135710720] script = ExtResource("1_vub0q") -[node name="MultiMeshInstance2D" type="MultiMeshInstance2D" parent="." unique_id=1491659974] -unique_name_in_owner = true -position = Vector2(419, 227) -scale = Vector2(2, 2) -multimesh = SubResource("MultiMesh_knsph") - [node name="OverlayFrame" type="PanelContainer" parent="." unique_id=1522539722] offset_left = 390.0 offset_top = 74.0 @@ -40,9 +30,40 @@ offset_bottom = 254.0 theme = SubResource("Theme_2n6hd") theme_override_styles/panel = SubResource("StyleBoxFlat_hiv0f") -[node name="Label" type="Label" parent="." unique_id=1917131834] -offset_left = 393.0 -offset_top = 53.0 -offset_right = 444.0 -offset_bottom = 76.0 -text = "Forces" +[node name="Origin" type="Node2D" parent="OverlayFrame" unique_id=2062605545] +position = Vector2(36.78, 155) + +[node name="FtargetCurve" type="Line2D" parent="OverlayFrame/Origin" unique_id=599340807] +unique_name_in_owner = true +points = PackedVector2Array(0, 0, 300, 0) +width = 1.0 +default_color = Color(1, 1, 0, 1) + +[node name="FtargetValue" type="Label" parent="OverlayFrame/Origin/FtargetCurve" unique_id=688906635] +unique_name_in_owner = true +offset_left = -42.78 +offset_top = -12.0 +offset_right = -6.779999 +offset_bottom = 11.0 +text = "50" +label_settings = SubResource("LabelSettings_rpek1") +horizontal_alignment = 2 + +[node name="XAxis" type="Line2D" parent="OverlayFrame/Origin" unique_id=802459769] +points = PackedVector2Array(0, 0, 300, 0) +width = 1.0 + +[node name="FtotCurve" type="Line2D" parent="OverlayFrame/Origin" unique_id=192410465] +unique_name_in_owner = true +points = PackedVector2Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 299, 0) +width = 1.0 +default_color = Color(0, 1, 0, 1) + +[node name="FpeakLabel" type="Label" parent="OverlayFrame/Origin" unique_id=116549456] +unique_name_in_owner = true +offset_left = 271.22003 +offset_top = -151.0 +offset_right = 319.22003 +offset_bottom = -110.0 +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/src/project.godot b/src/project.godot index 8114511..d32ae37 100644 --- a/src/project.godot +++ b/src/project.godot @@ -16,7 +16,7 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true config/name="WheelSims" run/main_scene="uid://c5y4tat5hrad0" -config/features=PackedStringArray("4.6", "Forward Plus") +config/features=PackedStringArray("4.7", "Forward Plus") config/icon="res://icon.svg" [audio] From 0d94ef55765c8d05db52d479263cb4dc71521e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laboratoire=20de=20recherche=20en=20mobilit=C3=A9=20et=20s?= =?UTF-8?q?yst=C3=A8mes=20adapt=C3=A9s?= Date: Thu, 10 Sep 2026 11:34:36 -0400 Subject: [PATCH 6/9] Now launches python script in its conda environment (importing kineticstoolkit_extensions crashed on Windows without using conda) --- src/config.gd | 14 ++++++--- src/devices/python_bridge/python_bridge.gd | 30 ++++++++++--------- .../biofeedback_kinematics.gd | 2 ++ .../biofeedback_pushrim_kinetics.gd | 12 +++++--- src/project.godot | 2 +- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/config.gd b/src/config.gd index 142c4a7..2259c57 100644 --- a/src/config.gd +++ b/src/config.gd @@ -12,8 +12,7 @@ extends Node ## Emitted with the config id as argument on configuration change. -signal modified - +signal modified # ------------------------------------------------------------------- # Private variables and functions @@ -137,7 +136,14 @@ var _defaults: Dictionary[String, Dictionary] = { "overlays.biofeedback_pushrim_kinetics.enabled": {"order": 3.07, "label": "Biofeedback: Pushrim Kinetics", "type": "bool", "default": false}, "overlays.biofeedback_pushrim_kinetics.target_force": - {"order": 3.08, "label": "Target Force", "type": "float", "default": 50.0, "min": 25.0, "max": 125.0}, + { + "order": 3.08, + "label": "Target Force", + "type": "float", + "default": 50.0, + "min": 25.0, + "max": 125.0 + }, "devices": {"order": 4, "label": "DEVICE SETTINGS"}, "devices.screens": {"order": 4.1, "label": "Screens"}, "devices.screens.single_screen": {"order": 4.2, "label": "Single screen"}, @@ -186,7 +192,7 @@ var _defaults: Dictionary[String, Dictionary] = { "devices.python_bridge.enabled": {"order": 4.8, "label": "Python Bridge", "type": "bool", "default": false}, "devices.python_bridge.python_path": - {"order": 4.81, "label": "Python app path", "type": "file", "default": ""}, + {"order": 4.81, "label": "Python or conda path", "type": "file", "default": ""}, "devices.python_bridge.script_path": {"order": 4.82, "label": "Python script path", "type": "file", "default": ""}, "devices.data_logging": {"order": 4.9, "label": "DATA LOGGING"}, diff --git a/src/devices/python_bridge/python_bridge.gd b/src/devices/python_bridge/python_bridge.gd index 98be8ef..8363e0b 100644 --- a/src/devices/python_bridge/python_bridge.gd +++ b/src/devices/python_bridge/python_bridge.gd @@ -23,6 +23,7 @@ func _ready(): # Launch Python app var python_app_path: String = Config.get_value("devices.python_bridge.python_path") var python_script_path: String = Config.get_value("devices.python_bridge.script_path") + var conda_environment: String = "wheelsims" if python_app_path == "": print("Cannot launch Python because Python app path is unset.") @@ -32,23 +33,24 @@ func _ready(): print("Cannot launch Python because Python app script is unset.") return + var parameters: Array[String] + if conda_environment == "": # Bare Python environment + parameters = [python_script_path] + else: + parameters = [ + "run", "-n", conda_environment, "--no-capture-output", "python", python_script_path + ] + if OS.get_name() == "macOS": print("Launching a terminal window for Python Bridge...") - OS.create_process( - "/usr/bin/osascript", - [ - "-e", - ( - 'tell app "Terminal" to do script "' - + python_app_path - + " " - + python_script_path - + '"' - ) - ] - ) + var cmd: String = 'tell app "Terminal" to do script "' + python_app_path + " " + for parameter in parameters: + cmd += parameter + cmd += '"' + OS.create_process("/usr/bin/osascript", ["-e", cmd]) else: - OS.create_process(python_app_path, [python_script_path], true) + print(python_app_path, parameters) + OS.create_process(python_app_path, parameters, true) # Set UDP receiver and UDP sender _udp_receiver.bind(udp_receive_port) diff --git a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd index c239aec..5b42a43 100644 --- a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd +++ b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd @@ -2,12 +2,14 @@ extends Node2D var python_bridge: Node + func _ready() -> void: await SignalBus.python_bridge_connected python_bridge = Globals.main.get_node("PythonBridge") await python_bridge.run("biofeedback_kinematics_connect", {}) update_loop() + func update_loop() -> void: #!TODO Call Python and the update functions from both overlays pass diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd index 7b1becc..a81dc6d 100644 --- a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd @@ -7,8 +7,9 @@ var python_bridge: Node @onready var n_answers := 0 + ## Set FlimitCurve and FlimitValue to a given value. -func _set_f_limit(value:float): +func _set_f_limit(value: float): %FtargetCurve.position.y = -value %FtargetValue.text = str(int(value)) @@ -18,7 +19,7 @@ func _ready() -> void: for i in N_POINTS: f_tot_curve.append(0.0) _set_f_limit(Config.get_value("overlays.biofeedback_pushrim_kinetics.target_force")) - + await SignalBus.python_bridge_connected python_bridge = Globals.main.get_node("PythonBridge") await python_bridge.run("biofeedback_pushrim_kinetics_connect", {"ip": "dummy"}) @@ -35,13 +36,16 @@ func update_loop() -> void: for i in N_POINTS: f_tot_curve[i] = result["FtotCurve"][i] - var new_points : Array[Vector2] = [] + var new_points: Array[Vector2] = [] for i in N_POINTS: new_points.append(Vector2(i, -f_tot_curve[i])) %FtotCurve.points = PackedVector2Array(new_points) + func _process(_delta) -> void: - if Config.value_changed("biofeedback_pushrim_kinetics", "overlays.biofeedback_pushrim_kinetics.target_force"): + if Config.value_changed( + "biofeedback_pushrim_kinetics", "overlays.biofeedback_pushrim_kinetics.target_force" + ): _set_f_limit(Config.get_value("overlays.biofeedback_pushrim_kinetics.target_force")) if not Config.get_value("overlays.biofeedback_pushrim_kinetics.enabled"): queue_free() diff --git a/src/project.godot b/src/project.godot index d32ae37..8114511 100644 --- a/src/project.godot +++ b/src/project.godot @@ -16,7 +16,7 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true config/name="WheelSims" run/main_scene="uid://c5y4tat5hrad0" -config/features=PackedStringArray("4.7", "Forward Plus") +config/features=PackedStringArray("4.6", "Forward Plus") config/icon="res://icon.svg" [audio] From ecb8291dfb25a0d672dd19e891c16692d12b3b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laboratoire=20de=20recherche=20en=20mobilit=C3=A9=20et=20s?= =?UTF-8?q?yst=C3=A8mes=20adapt=C3=A9s?= Date: Thu, 10 Sep 2026 14:52:31 -0400 Subject: [PATCH 7/9] Every feedbacks work at the same time, but deactivation and reactivation crashes. --- src/config.gd | 2 +- .../biofeedback_kinematics.gd | 38 +++++++++- .../biofeedback_kinematics.tscn | 4 +- .../biofeedback_push_frequency.gd | 59 ++------------ .../biofeedback_push_pattern.gd | 25 ++---- .../biofeedback_push_pattern.tscn | 76 +++++++++---------- .../last_push_pattern.gd | 61 ++------------- 7 files changed, 94 insertions(+), 171 deletions(-) diff --git a/src/config.gd b/src/config.gd index 2259c57..d42c347 100644 --- a/src/config.gd +++ b/src/config.gd @@ -106,7 +106,7 @@ var _defaults: Dictionary[String, Dictionary] = { "overlays": {"order": 3, "label": "OVERLAYS"}, "overlays.speed_indicator.enabled": {"order": 3.01, "label": "Speed indicator", "type": "bool", "default": true}, - "overlays.debug.enabled": {"order": 3.02, "label": "Debug", "type": "bool", "default": false}, + "overlays.debug.enabled": {"order": 3.15, "label": "Debug", "type": "bool", "default": false}, "overlays.biofeedback_kinematics.enabled": {"order": 3.02, "label": "Biofeedback: Kinematics", "type": "bool", "default": false}, "overlays.biofeedback_push_pattern.enabled": diff --git a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd index 5b42a43..d5f6234 100644 --- a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd +++ b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd @@ -2,14 +2,46 @@ extends Node2D var python_bridge: Node +## Results from wheelsims_analysis/biofeedback_kinematics, updated regularly +var analysis_results: Dictionary + func _ready() -> void: await SignalBus.python_bridge_connected python_bridge = Globals.main.get_node("PythonBridge") - await python_bridge.run("biofeedback_kinematics_connect", {}) +# await python_bridge.run("biofeedback_kinematics_connect", {}) update_loop() func update_loop() -> void: - #!TODO Call Python and the update functions from both overlays - pass + while true: + var temp + + temp = await ( + python_bridge + . run( + "biofeedback_kinematics", + { + "coordinates_left_wheel_center": + Config.get_value("coordinates.left_wheel_center"), + "coordinates_right_wheel_center": + Config.get_value("coordinates.right_wheel_center"), + "coordinates_left_hand": Config.get_value("coordinates.left_hand"), + "coordinates_right_hand": Config.get_value("coordinates.right_hand"), + "wheel_diameter": Config.get_value("player.pushrim_diameter"), + } + ) + ) + if temp != null: + analysis_results = temp + + # set local variable analysis_results of every decendent node that has + # such variable. + propagate_call("set", ["analysis_results", analysis_results]) + + +func _process(_delta) -> void: + $BiofeedbackPushPattern.visible = Config.get_value("overlays.biofeedback_push_pattern.enabled") + $BiofeedbackPushFrequency.visible = Config.get_value( + "overlays.biofeedback_push_frequency.enabled" + ) diff --git a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.tscn b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.tscn index cd6dd0a..d6e9f2f 100644 --- a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.tscn +++ b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.tscn @@ -7,6 +7,6 @@ [node name="BiofeedbackKinematics" type="Node2D" unique_id=905171298] script = ExtResource("1_ib00y") -[node name="BiofeedbackPushFrequency" parent="." unique_id=1961947020 instance=ExtResource("1_boggs")] - [node name="BiofeedbackPushPattern" parent="." unique_id=2135710720 instance=ExtResource("2_ib00y")] + +[node name="BiofeedbackPushFrequency" parent="." unique_id=1961947020 instance=ExtResource("1_boggs")] diff --git a/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd b/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd index bc1eb39..2d79253 100644 --- a/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd +++ b/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd @@ -33,51 +33,13 @@ var current_value = 0.0 var connected = false var biofeedback_args - -func _process(_delta) -> void: - # Once start the analysis by sending a request to the python bridge - if Globals.main.has_node("PythonBridge"): - if Globals.main.get_node("PythonBridge")._udp_receiver_connected and not connected: - connected = true - _update_arg() - Globals.main.get_node("PythonBridge").send( - "biofeedback_update", biofeedback_args, "start" - ) - # Reset the connected flag if the python bridge is disconnected - else: - if connected: - connected = false - - # Update the slider if the process is connected - if connected: - if Globals.main.has_node("PythonBridge"): - var data = Globals.main.get_node("PythonBridge").receive("biofeedback_push_frequency") - _update_slider(data) - - # Should we quit - if not Config.get_value("overlays.biofeedback_push_frequency.enabled"): - # Stop the biofeedback from python bridge if this overlays is shut down - if ( - Globals.main.has_node("PythonBridge") - and connected - and not Config.get_value("overlays.biofeedback_push_pattern.enabled") - ): - # Tell the python bridge to stop the repeating update process - Globals.main.get_node("PythonBridge").send("biofeedback_update", {}, "stop") - # Send a final request to reset the biofeedback script data - _update_arg() - Globals.main.get_node("PythonBridge").send("biofeedback_stop", biofeedback_args, "once") - # Remove the overlay node from the scene tree - queue_free() +## Results from wheelsims_analysis (python) - Updated by parent node +var analysis_results := {} -# Update the slider with slider parameters and the received mean push frequency -func _update_slider(data): - if data is Dictionary and data.has("data") and data["data"].size() > 0: - if data["command"] == "biofeedback_update": - var side = data["data"].keys()[0] - if data["data"][side].has("mean_push_frequency"): - current_value = data["data"][side]["mean_push_frequency"] +func _process(_delta) -> void: + if "right" in analysis_results and "mean_push_frequency" in analysis_results["right"]: + current_value = analysis_results["right"]["mean_push_frequency"] node_min_value.text = str(min_value) node_max_value.text = str(max_value) @@ -101,14 +63,3 @@ func _update_slider(data): node_max_target_value.text = str(max_target_value) node_max_target_value.position.y = node_green_zone.size.y - - -# Update the arguments to send the requests to the python bridge -func _update_arg(): - biofeedback_args = { - "coordinates_left_wheel_center": Config.get_value("coordinates.left_wheel_center"), - "coordinates_right_wheel_center": Config.get_value("coordinates.right_wheel_center"), - "coordinates_left_hand": Config.get_value("coordinates.left_hand"), - "coordinates_right_hand": Config.get_value("coordinates.right_hand"), - "wheel_diameter": Config.get_value("player.pushrim_diameter"), - } diff --git a/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd index 88044b4..3612a6d 100644 --- a/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd +++ b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd @@ -43,6 +43,9 @@ extends Node2D @export_subgroup("Trails") @export var trails_visibled = true +## Results from wheelsims_analysis (python) - Updated by parent node +var analysis_results := {} + var position_wheel_l var position_wheel_r var radius_wheel @@ -82,9 +85,6 @@ func _process(_delta): update_wheelchair() update_push_pattern_label() - if not Config.get_value("overlays.biofeedback_push_pattern.enabled"): - queue_free() - # Update wheelchair model based on configuration and tracking data func update_wheelchair(): @@ -154,23 +154,8 @@ func window_user(): # Update the push pattern label when the Python biofeedback script detects a propulsive cycle func update_push_pattern_label(): - if Globals.main.has_node("PythonBridge"): - var data = Globals.main.get_node("PythonBridge").receive("push_pattern_label") - - if data is Dictionary and data.has("data") and data["data"].size() > 0: - if data["command"] == "biofeedback_update": - var side = data["data"].keys()[0] - if data["data"][side].has("label_push_pattern") and side == "right": - node_push_pattern_label.text = data["data"][side]["label_push_pattern"] - - if push_pattern_tween: - push_pattern_tween.kill() - node_push_pattern_label.scale = Vector2.ZERO - - push_pattern_tween = create_tween() - push_pattern_tween.tween_property( - node_push_pattern_label, "scale", Vector2.ONE, 0.1 - ) + if ("right" in analysis_results) and ("label_push_pattern" in analysis_results["right"]): + node_push_pattern_label.text = analysis_results["right"]["label_push_pattern"] else: node_push_pattern_label.text = "" diff --git a/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn index bdaee2b..0a7233b 100644 --- a/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn +++ b/src/overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn @@ -169,71 +169,71 @@ transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, script = ExtResource("5_nqdaa") side = "right" -[node name="BézierCircle_004" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="0" unique_id=363854926] +[node name="BézierCircle_004" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="0" unique_id=492824724] layers = 4 -[node name="BézierCircle_005" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="1" unique_id=1397379913] +[node name="BézierCircle_005" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="1" unique_id=1967190373] layers = 4 -[node name="BézierCircle_006" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="2" unique_id=1928306487] +[node name="BézierCircle_006" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="2" unique_id=1293971367] layers = 4 -[node name="Cylinder_013" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="3" unique_id=2129805941] +[node name="Cylinder_013" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="3" unique_id=1915422161] layers = 4 -[node name="Cylinder_014" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="4" unique_id=19447650] +[node name="Cylinder_014" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="4" unique_id=871273199] layers = 4 -[node name="Cylinder_015" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="5" unique_id=1473366646] +[node name="Cylinder_015" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="5" unique_id=1866239796] layers = 4 -[node name="Cylinder_016" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="6" unique_id=1826976270] +[node name="Cylinder_016" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="6" unique_id=582229067] layers = 4 -[node name="Cylinder_017" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="7" unique_id=356637044] +[node name="Cylinder_017" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="7" unique_id=132602823] layers = 4 -[node name="Cylinder_018" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="8" unique_id=32034191] +[node name="Cylinder_018" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="8" unique_id=553216785] layers = 4 -[node name="Cylinder_019" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="9" unique_id=2063277236] +[node name="Cylinder_019" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="9" unique_id=1782011555] layers = 4 -[node name="Cylinder_020" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="10" unique_id=1378418252] +[node name="Cylinder_020" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="10" unique_id=397632586] layers = 4 -[node name="Cylinder_021" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="11" unique_id=773933742] +[node name="Cylinder_021" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="11" unique_id=1264964103] layers = 4 -[node name="Cylinder_022" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="12" unique_id=613544328] +[node name="Cylinder_022" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="12" unique_id=1785887012] layers = 4 -[node name="Cylinder_023" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="13" unique_id=33910092] +[node name="Cylinder_023" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="13" unique_id=903056405] layers = 4 -[node name="Cylinder_024" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="14" unique_id=804831044] +[node name="Cylinder_024" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="14" unique_id=1417923883] layers = 4 -[node name="Cylinder_025" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="15" unique_id=308237162] +[node name="Cylinder_025" parent="CurrentScene3D/WheelRight/RearWheelRight/rear_wheel" parent_id_path=PackedInt32Array(1979307876, 1701913547) index="15" unique_id=1128864618] layers = 4 [node name="ContactAngleEndRight" parent="CurrentScene3D/WheelRight" unique_id=434550697 instance=ExtResource("3_ss2qs")] script = ExtResource("8_tdhcr") phase = "end" -[node name="Circle" parent="CurrentScene3D/WheelRight/ContactAngleEndRight/angle_contact" index="0" unique_id=2039290200] +[node name="Circle" parent="CurrentScene3D/WheelRight/ContactAngleEndRight/angle_contact" index="0" unique_id=1646293624] layers = 4 [node name="ContactAngleStartRight" parent="CurrentScene3D/WheelRight" unique_id=1398161811 instance=ExtResource("3_ss2qs")] script = ExtResource("8_tdhcr") phase = "start" -[node name="Circle" parent="CurrentScene3D/WheelRight/ContactAngleStartRight/angle_contact" index="0" unique_id=2039290200] +[node name="Circle" parent="CurrentScene3D/WheelRight/ContactAngleStartRight/angle_contact" index="0" unique_id=1646293624] layers = 4 [node name="HandrimRight" parent="CurrentScene3D/WheelRight" unique_id=8043099 instance=ExtResource("4_8bgme")] -[node name="BézierCircle_003" parent="CurrentScene3D/WheelRight/HandrimRight/handrim" parent_id_path=PackedInt32Array(8043099, 196758062) index="0" unique_id=1225760875] +[node name="BézierCircle_003" parent="CurrentScene3D/WheelRight/HandrimRight/handrim" parent_id_path=PackedInt32Array(8043099, 196758062) index="0" unique_id=1785037892] layers = 5 [node name="WheelLeft" type="Node3D" parent="CurrentScene3D" unique_id=915408687] @@ -243,71 +243,71 @@ transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 0, script = ExtResource("5_nqdaa") side = "left" -[node name="BézierCircle_004" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="0" unique_id=363854926] +[node name="BézierCircle_004" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="0" unique_id=492824724] layers = 2 -[node name="BézierCircle_005" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="1" unique_id=1397379913] +[node name="BézierCircle_005" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="1" unique_id=1967190373] layers = 2 -[node name="BézierCircle_006" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="2" unique_id=1928306487] +[node name="BézierCircle_006" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="2" unique_id=1293971367] layers = 2 -[node name="Cylinder_013" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="3" unique_id=2129805941] +[node name="Cylinder_013" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="3" unique_id=1915422161] layers = 2 -[node name="Cylinder_014" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="4" unique_id=19447650] +[node name="Cylinder_014" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="4" unique_id=871273199] layers = 2 -[node name="Cylinder_015" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="5" unique_id=1473366646] +[node name="Cylinder_015" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="5" unique_id=1866239796] layers = 2 -[node name="Cylinder_016" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="6" unique_id=1826976270] +[node name="Cylinder_016" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="6" unique_id=582229067] layers = 2 -[node name="Cylinder_017" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="7" unique_id=356637044] +[node name="Cylinder_017" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="7" unique_id=132602823] layers = 2 -[node name="Cylinder_018" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="8" unique_id=32034191] +[node name="Cylinder_018" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="8" unique_id=553216785] layers = 2 -[node name="Cylinder_019" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="9" unique_id=2063277236] +[node name="Cylinder_019" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="9" unique_id=1782011555] layers = 2 -[node name="Cylinder_020" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="10" unique_id=1378418252] +[node name="Cylinder_020" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="10" unique_id=397632586] layers = 2 -[node name="Cylinder_021" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="11" unique_id=773933742] +[node name="Cylinder_021" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="11" unique_id=1264964103] layers = 2 -[node name="Cylinder_022" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="12" unique_id=613544328] +[node name="Cylinder_022" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="12" unique_id=1785887012] layers = 2 -[node name="Cylinder_023" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="13" unique_id=33910092] +[node name="Cylinder_023" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="13" unique_id=903056405] layers = 2 -[node name="Cylinder_024" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="14" unique_id=804831044] +[node name="Cylinder_024" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="14" unique_id=1417923883] layers = 2 -[node name="Cylinder_025" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="15" unique_id=308237162] +[node name="Cylinder_025" parent="CurrentScene3D/WheelLeft/RearWheelLeft/rear_wheel" parent_id_path=PackedInt32Array(9668413, 1701913547) index="15" unique_id=1128864618] layers = 2 [node name="ContactAngleEndLeft" parent="CurrentScene3D/WheelLeft" unique_id=178996732 instance=ExtResource("3_ss2qs")] script = ExtResource("8_tdhcr") phase = "end" -[node name="Circle" parent="CurrentScene3D/WheelLeft/ContactAngleEndLeft/angle_contact" index="0" unique_id=2039290200] +[node name="Circle" parent="CurrentScene3D/WheelLeft/ContactAngleEndLeft/angle_contact" index="0" unique_id=1646293624] layers = 2 [node name="ContactAngleStartLeft" parent="CurrentScene3D/WheelLeft" unique_id=1651147978 instance=ExtResource("3_ss2qs")] script = ExtResource("8_tdhcr") phase = "start" -[node name="Circle" parent="CurrentScene3D/WheelLeft/ContactAngleStartLeft/angle_contact" index="0" unique_id=2039290200] +[node name="Circle" parent="CurrentScene3D/WheelLeft/ContactAngleStartLeft/angle_contact" index="0" unique_id=1646293624] layers = 2 [node name="HandrimLeft" parent="CurrentScene3D/WheelLeft" unique_id=1417836334 instance=ExtResource("4_8bgme")] -[node name="BézierCircle_003" parent="CurrentScene3D/WheelLeft/HandrimLeft/handrim" parent_id_path=PackedInt32Array(1417836334, 196758062) index="0" unique_id=1225760875] +[node name="BézierCircle_003" parent="CurrentScene3D/WheelLeft/HandrimLeft/handrim" parent_id_path=PackedInt32Array(1417836334, 196758062) index="0" unique_id=1785037892] layers = 2 [node name="TrailHandLeft" type="MultiMeshInstance3D" parent="CurrentScene3D" unique_id=748685228 node_paths=PackedStringArray("node_forearm_cluster_left", "node_forearm_cluster_right")] diff --git a/src/overlays/biofeedback_kinematics/last_push_pattern.gd b/src/overlays/biofeedback_kinematics/last_push_pattern.gd index a129eb6..809f785 100644 --- a/src/overlays/biofeedback_kinematics/last_push_pattern.gd +++ b/src/overlays/biofeedback_kinematics/last_push_pattern.gd @@ -20,6 +20,10 @@ var last_push_pattern: String @export var node_virtual_wheel_right: Node # Variables + +## Results from wheelsims_analysis (python) - Updated by parent node +var analysis_results := {} + var positions := [] var trail_size := 0.11 @@ -41,59 +45,10 @@ func _ready() -> void: func _process(_delta: float) -> void: - # Once start the analysis by sending a request to the python bridge - if Globals.main: - if Globals.main.has_node("PythonBridge"): - if Globals.main.get_node("PythonBridge")._udp_receiver_connected and not connected: - connected = true - _update_arg() - Globals.main.get_node("PythonBridge").send("biofeedback_update", arg, "start") - # Reset the connected flag if the python bridge is disconnected - else: - if connected: - connected = false - - # Update loop process if the process is connected - if connected: - visible = true - if Globals.main.has_node("PythonBridge"): - var data = Globals.main.get_node("PythonBridge").receive(last_push_pattern + "_" + side) - - if data is Dictionary and data.has("data") and data["data"].size() > 0: - if data["command"] == "biofeedback_update": - if data["data"].keys()[0] == side: - var value = data["data"][side][last_push_pattern] - positions = parse_trail_points(value) - _update_multimesh() - else: - visible = false - - # Should we quit - if not Config.get_value("overlays.biofeedback_push_pattern.enabled"): - # Stop the biofeedback from python bridge if this overlays is shut down - if ( - Globals.main.has_node("PythonBridge") - and connected - and not Config.get_value("overlays.biofeedback_push_frequency.enabled") - ): - # Tell the python bridge to stop the repeating update process - Globals.main.get_node("PythonBridge").send("biofeedback_update", {}, "stop") - # Send a final request to reset the biofeedback script data - _update_arg() - Globals.main.get_node("PythonBridge").send("biofeedback_stop", arg, "once") - # Remove the overlay node from the scene tree - queue_free() - - -# Update the arguments to send the requests to the python bridge -func _update_arg(): - arg = { - "coordinates_left_wheel_center": Config.get_value("coordinates.left_wheel_center"), - "coordinates_right_wheel_center": Config.get_value("coordinates.right_wheel_center"), - "coordinates_left_hand": Config.get_value("coordinates.left_hand"), - "coordinates_right_hand": Config.get_value("coordinates.right_hand"), - "wheel_diameter": Config.get_value("player.pushrim_diameter"), - } + if analysis_results != {}: + var value = analysis_results[side][last_push_pattern] + positions = parse_trail_points(value) + _update_multimesh() # Set layer, references, and coordinate variables based on the selected side (left or right) From dea815deb0f9fca2a7a85f15a47a4761b0b1abcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laboratoire=20de=20recherche=20en=20mobilit=C3=A9=20et=20s?= =?UTF-8?q?yst=C3=A8mes=20adapt=C3=A9s?= Date: Thu, 10 Sep 2026 15:39:35 -0400 Subject: [PATCH 8/9] [68-create-a-new-biofeedback-module-for-the-propulsion-force] Done. --- src/config.gd | 7 +++++++ .../biofeedback_kinematics/biofeedback_kinematics.gd | 3 +++ src/overlays/biofeedback_kinematics/last_push_pattern.gd | 2 +- .../biofeedback_pushrim_kinetics.gd | 8 +++++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/config.gd b/src/config.gd index d42c347..55d7390 100644 --- a/src/config.gd +++ b/src/config.gd @@ -144,6 +144,13 @@ var _defaults: Dictionary[String, Dictionary] = { "min": 25.0, "max": 125.0 }, + "overlays.biofeedback_pushrim_kinetics.wheel_ip": + { + "order": 3.09, + "label": "Wheel IP ('xx.xx.xx.xx' or 'dummy')", + "type": "string", + "default": "dummy" + }, "devices": {"order": 4, "label": "DEVICE SETTINGS"}, "devices.screens": {"order": 4.1, "label": "Screens"}, "devices.screens.single_screen": {"order": 4.2, "label": "Single screen"}, diff --git a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd index d5f6234..793033d 100644 --- a/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd +++ b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd @@ -45,3 +45,6 @@ func _process(_delta) -> void: $BiofeedbackPushFrequency.visible = Config.get_value( "overlays.biofeedback_push_frequency.enabled" ) + + if not Config.get_value("overlays.biofeedback_kinematics.enabled"): + queue_free() diff --git a/src/overlays/biofeedback_kinematics/last_push_pattern.gd b/src/overlays/biofeedback_kinematics/last_push_pattern.gd index 809f785..1c923c6 100644 --- a/src/overlays/biofeedback_kinematics/last_push_pattern.gd +++ b/src/overlays/biofeedback_kinematics/last_push_pattern.gd @@ -45,7 +45,7 @@ func _ready() -> void: func _process(_delta: float) -> void: - if analysis_results != {}: + if side in analysis_results and last_push_pattern in analysis_results[side]: var value = analysis_results[side][last_push_pattern] positions = parse_trail_points(value) _update_multimesh() diff --git a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd index a81dc6d..5eb5592 100644 --- a/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd @@ -22,13 +22,19 @@ func _ready() -> void: await SignalBus.python_bridge_connected python_bridge = Globals.main.get_node("PythonBridge") - await python_bridge.run("biofeedback_pushrim_kinetics_connect", {"ip": "dummy"}) + await python_bridge.run( + "biofeedback_pushrim_kinetics_connect", + {"ip": Config.get_value("overlays.biofeedback_pushrim_kinetics.wheel_ip")} + ) update_loop() func update_loop() -> void: while true: var result = await python_bridge.run("biofeedback_pushrim_kinetics_process", {}) + if result == null: + continue + var f_peak = str(int(result["Fpeak"])) if f_peak == "0": f_peak = "" From 886372200a898aff9c35b22c619e0de737633da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laboratoire=20de=20recherche=20en=20mobilit=C3=A9=20et=20s?= =?UTF-8?q?yst=C3=A8mes=20adapt=C3=A9s?= Date: Thu, 10 Sep 2026 16:07:58 -0400 Subject: [PATCH 9/9] [68-create-a-new-biofeedback-module-for-the-propulsion-force] Reduced number of pedestrians because reduced framerate affect vibration by dbox (bug to be issued) --- src/playable_scenes/park.tscn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playable_scenes/park.tscn b/src/playable_scenes/park.tscn index a2488b3..63eff4e 100644 --- a/src/playable_scenes/park.tscn +++ b/src/playable_scenes/park.tscn @@ -13,6 +13,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.117460966, 0) max_contacts_reported = 4 [node name="PedestrianGenerator" parent="." unique_id=1740765578 instance=ExtResource("6_8xwh6")] -n_pedestrians = 200 +n_pedestrians = 50 [connection signal="ready" from="." to="." method="_on_ready"]