diff --git a/src/config.gd b/src/config.gd index 425799e..55d7390 100644 --- a/src/config.gd +++ b/src/config.gd @@ -11,6 +11,9 @@ ## 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 # ------------------------------------------------------------------- @@ -37,7 +40,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 +51,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": { @@ -101,9 +106,11 @@ 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": - {"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, @@ -125,7 +132,25 @@ 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 + }, + "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"}, @@ -174,7 +199,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"}, @@ -353,6 +378,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/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 diff --git a/src/devices/python_bridge/python_bridge.gd b/src/devices/python_bridge/python_bridge.gd index 4fd13de..8363e0b 100644 --- a/src/devices/python_bridge/python_bridge.gd +++ b/src/devices/python_bridge/python_bridge.gd @@ -14,16 +14,16 @@ 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 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.") @@ -33,98 +33,91 @@ func _ready(): print("Cannot launch Python because Python app script is unset.") return - OS.create_process(python_app_path, [python_script_path], true) + 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...") + 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: + 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) _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 - if Config.get_value("devices.data_logging.enabled") == 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() - - 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(): 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) + var data_dict: Dictionary = json.get_data() - for id in queue_requests_by_id: - queue_requests_by_id[id].append(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 + 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): - var request = {"command": command, "args": args, "run_mode": run_mode} +## 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 = 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 = "" - text += "Python " - 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/main.tscn b/src/main.tscn index 48af036..19cb857 100644 --- a/src/main.tscn +++ b/src/main.tscn @@ -7,10 +7,10 @@ [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"] [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 +18,9 @@ [node name="main" type="Node" unique_id=502567777] script = ExtResource("1_0xm2m") available_overlays = Dictionary[String, PackedScene]({ -"overlays.biofeedback_push_frequency.enabled": ExtResource("5_ycdy4"), -"overlays.biofeedback_push_pattern.enabled": ExtResource("4_dg77c"), +"": null, +"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..793033d --- /dev/null +++ b/src/overlays/biofeedback_kinematics/biofeedback_kinematics.gd @@ -0,0 +1,50 @@ +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", {}) + update_loop() + + +func update_loop() -> void: + 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" + ) + + if not Config.get_value("overlays.biofeedback_kinematics.enabled"): + queue_free() 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..d6e9f2f --- /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="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 new file mode 100644 index 0000000..2d79253 --- /dev/null +++ b/src/overlays/biofeedback_kinematics/biofeedback_push_frequency.gd @@ -0,0 +1,65 @@ +extends Control + +# ---------------------------------------------------------------------- # +# GUI overlay for displaying mean push frequency from biofeedback data +# - receives mean push frequency values from the device Python bridge +# - Displays the current mean push frequency whithin a slider +# ---------------------------------------------------------------------- # + +# Slider parameters +@export_category("Slider parameters") +@export var min_value = 0.0 +@export var max_value = 2.5 + +@export var min_target_value = 0.4 +@export var max_target_value = 1.2 + +# UI elements +@export_category("Nodes") +@export var node_min_value: Node +@export var node_max_value: Node +@export var node_min_target_value: Node +@export var node_max_target_value: Node +@export var node_value: Node +@export var node_slider_zone: Node +@export var node_slider: Node +@export var node_target_zone: Node +@export var node_green_zone: Node + +# Push frequency value from python script biofeedback +var current_value = 0.0 + +# Connection flags and request arguments +var connected = false +var biofeedback_args + +## Results from wheelsims_analysis (python) - Updated by parent node +var analysis_results := {} + + +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) + node_value.text = str(snappedf(current_value, 0.1)) + + node_slider.position.y = ( + node_slider_zone.size.y + - (current_value - min_value) * node_slider_zone.size.y / (max_value - min_value) + ) + node_slider.size.x = node_slider_zone.size.x + + node_target_zone.position.y = ( + node_slider_zone.size.y + - (min_target_value - min_value) * node_slider_zone.size.y / (max_value - min_value) + ) + node_green_zone.size.y = ( + node_slider_zone.size.y * (max_target_value - min_target_value) / (max_value - min_value) + ) + + node_min_target_value.text = str(min_target_value) + node_max_target_value.text = str(max_target_value) + + node_max_target_value.position.y = node_green_zone.size.y 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 87% rename from src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.gd rename to src/overlays/biofeedback_kinematics/biofeedback_push_pattern.gd index 88044b4..3612a6d 100644 --- a/src/overlays/biofeedback_push_pattern/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_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 89% rename from src/overlays/biofeedback_push_pattern/biofeedback_push_pattern.tscn rename to src/overlays/biofeedback_kinematics/biofeedback_push_pattern.tscn index b05773a..0a7233b 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"] @@ -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_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 58% rename from src/overlays/biofeedback_push_pattern/last_push_pattern.gd rename to src/overlays/biofeedback_kinematics/last_push_pattern.gd index a129eb6..1c923c6 100644 --- a/src/overlays/biofeedback_push_pattern/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 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() # Set layer, references, and coordinate variables based on the selected side (left or right) 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_push_frequency/biofeedback_push_frequency.gd b/src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.gd deleted file mode 100644 index bc1eb39..0000000 --- a/src/overlays/biofeedback_push_frequency/biofeedback_push_frequency.gd +++ /dev/null @@ -1,114 +0,0 @@ -extends Control - -# ---------------------------------------------------------------------- # -# GUI overlay for displaying mean push frequency from biofeedback data -# - receives mean push frequency values from the device Python bridge -# - Displays the current mean push frequency whithin a slider -# ---------------------------------------------------------------------- # - -# Slider parameters -@export_category("Slider parameters") -@export var min_value = 0.0 -@export var max_value = 2.5 - -@export var min_target_value = 0.4 -@export var max_target_value = 1.2 - -# UI elements -@export_category("Nodes") -@export var node_min_value: Node -@export var node_max_value: Node -@export var node_min_target_value: Node -@export var node_max_target_value: Node -@export var node_value: Node -@export var node_slider_zone: Node -@export var node_slider: Node -@export var node_target_zone: Node -@export var node_green_zone: Node - -# Push frequency value from python script biofeedback -var current_value = 0.0 - -# Connection flags and request arguments -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() - - -# 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"] - - node_min_value.text = str(min_value) - node_max_value.text = str(max_value) - node_value.text = str(snappedf(current_value, 0.1)) - - node_slider.position.y = ( - node_slider_zone.size.y - - (current_value - min_value) * node_slider_zone.size.y / (max_value - min_value) - ) - node_slider.size.x = node_slider_zone.size.x - - node_target_zone.position.y = ( - node_slider_zone.size.y - - (min_target_value - min_value) * node_slider_zone.size.y / (max_value - min_value) - ) - node_green_zone.size.y = ( - node_slider_zone.size.y * (max_target_value - min_target_value) / (max_value - min_value) - ) - - node_min_target_value.text = str(min_target_value) - 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_pushrim_kinetics/biofeedback_pushrim_kinetics.gd b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd new file mode 100644 index 0000000..5eb5592 --- /dev/null +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.gd @@ -0,0 +1,57 @@ +extends Node2D + +const N_POINTS := 300 + +var f_tot_curve: Array[float] = [] +var python_bridge: Node + +@onready var n_answers := 0 + + +## 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 values + 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": 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 = "" + %FpeakLabel.text = f_peak + for i in N_POINTS: + f_tot_curve[i] = result["FtotCurve"][i] + + 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" + ): + _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.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..eaecfac --- /dev/null +++ b/src/overlays/biofeedback_pushrim_kinetics/biofeedback_pushrim_kinetics.tscn @@ -0,0 +1,69 @@ +[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="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 + +[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="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="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/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"] 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")