Change how different sensor types ar handled

This commit is contained in:
2026-07-06 13:57:09 -06:00
parent 6eb2993391
commit 8fc5088c01
21 changed files with 320 additions and 124 deletions
@@ -11,7 +11,6 @@ var origin: Vector2 = Vector2(0., 0.)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
super._ready()
Signals.linear_acceleration_updated.connect(_on_linear_acceleration_updated)
label = get_node('Label')
accel_vector = get_node("AccelVector")
accel_vector.points = [origin, origin]
@@ -20,13 +19,13 @@ func _ready() -> void:
y_vector = get_node("YVector")
y_vector.points = [origin, origin]
func _on_linear_acceleration_updated(sensor_ip: String, linear_acceleration: Array):
var accel_vec = Vector2(-linear_acceleration[1], linear_acceleration[0])
var vec_norm: Vector2 = accel_vec.normalized()
var vec_length: float = accel_vec.length()
var accel_g = vec_length / Constants.g
var x_vec = Vector2(vec_norm.x*vec_length, 0)
accel_vector.points = [origin, accel_vec * 10]
x_vector.points = [origin, x_vec * 10]
y_vector.points = [x_vec * 10, accel_vec * 10]
label.text = str(round(accel_g*100)/100) + ' g'
func _update_data():
if y_vector == null:
return
var lateral_gs = host_vehicle.lateral_accel
var accel_g = lateral_gs.length() / Constants.g
var x_vec = Vector2(lateral_gs.x, 0)
accel_vector.points = [origin, lateral_gs * 4]
x_vector.points = [origin, x_vec * 4]
y_vector.points = [x_vec * 4, lateral_gs * 4]
label.text = str(round(accel_g*10)/10) + ' g'
+8 -8
View File
@@ -8,22 +8,22 @@ script = ExtResource("1_hmdxp")
metadata/_custom_type_script = "uid://b3rfje1auw6to"
[node name="Panel" type="Panel" parent="." unique_id=1393400967]
offset_right = 306.0
offset_bottom = 70.0
offset_right = 460.0
offset_bottom = 120.0
[node name="Label" type="Label" parent="." unique_id=1070194714]
offset_right = 306.0
offset_bottom = 70.0
theme_override_font_sizes/font_size = 32
text = "Altitude: 99999 ft"
offset_right = 460.0
offset_bottom = 120.0
theme_override_font_sizes/font_size = 80
text = "Alt: 99999 ft"
horizontal_alignment = 1
vertical_alignment = 1
[node name="MovableControl" type="Control" parent="." unique_id=1186292353 node_paths=PackedStringArray("move_target")]
layout_mode = 3
anchors_preset = 0
offset_right = 306.0
offset_bottom = 70.0
offset_right = 460.0
offset_bottom = 120.0
mouse_filter = 1
script = ExtResource("2_34sps")
move_target = NodePath("..")
@@ -14,4 +14,4 @@ func _ready() -> void:
func _update_data():
if label_node == null:
return
label_node.text = 'Altitude: ' + str(int(round(host_vehicle.altitude_m * Constants.M2FT))) + ' ft'
label_node.text = 'Alt: ' + str(int(round(host_vehicle.altitude_m * Constants.M2FT))) + ' ft'
+9 -3
View File
@@ -14,14 +14,20 @@ scale = Vector2(0.1, 0.1)
texture = ExtResource("2_qf1yp")
[node name="Label" type="Label" parent="." unique_id=338110309]
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -50.0
offset_top = -350.0
offset_top = -300.0
offset_right = 50.0
offset_bottom = -150.0
grow_horizontal = 2
grow_vertical = 0
pivot_offset = Vector2(50, 300)
theme_override_font_sizes/font_size = 80
text = "N"
horizontal_alignment = 1
vertical_alignment = 1
justification_flags = 161
[node name="MovableControl" type="Control" parent="." unique_id=124696843 node_paths=PackedStringArray("move_target")]
+26 -2
View File
@@ -5,6 +5,7 @@ class_name CompassWidgetNode
@export_range(0., 359., 0.1) var north_deg = 0.
var north_rad: float
var indicator: Sprite2D
var label: Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -13,8 +14,31 @@ func _ready() -> void:
north_deg = 0.
north_rad = deg_to_rad(north_deg)
indicator = get_node("CompassIndicator")
label = get_node("Label")
func _update_data():
if indicator == null:
if label == null:
return
indicator.rotation = host_vehicle.heading_rad
#label.rotation = -host_vehicle.heading_rad
label.text = get_direction_label(host_vehicle.heading_rad)
func get_direction_label(heading_rad):
var heading_deg = rad_to_deg(heading_rad)
if 0 <= heading_deg and heading_deg <= 22.5:
return 'N'
elif 22.5 < heading_deg and heading_deg <= 67.5:
return "NE"
elif 67.5 < heading_deg and heading_deg <= 112.5:
return "E"
elif 112.5 < heading_deg and heading_deg <= 157.5:
return "SE"
elif 157.5 < heading_deg and heading_deg <= 202.5:
return "S"
elif 202.5 < heading_deg and heading_deg <= 247.5:
return "SW"
elif 247.5 < heading_deg and heading_deg <= 292.5:
return "W"
elif 292.5 < heading_deg and heading_deg <= 337.5:
return "NW"
else:
return "N"
+2 -2
View File
@@ -14,14 +14,14 @@ offset_bottom = 40.0
[node name="SpeedLabel" type="Label" parent="VBoxContainer" unique_id=2101712075]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
theme_override_font_sizes/font_size = 48
theme_override_font_sizes/font_size = 80
text = "10"
horizontal_alignment = 1
[node name="UnitLabel" type="Label" parent="VBoxContainer" unique_id=123505815]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
theme_override_font_sizes/font_size = 16
theme_override_font_sizes/font_size = 26
text = "MPH"
horizontal_alignment = 1