WIP: PFD instrument
This commit is contained in:
parent
4be36eb39e
commit
740a72bcb6
23 changed files with 432 additions and 32 deletions
|
|
@ -49,6 +49,7 @@ func _process(delta: float) -> void:
|
||||||
# Update the instruments
|
# Update the instruments
|
||||||
instruments.call("set_controls", connector.get_controls())
|
instruments.call("set_controls", connector.get_controls())
|
||||||
instruments.call("set_trim", connector.get_trim())
|
instruments.call("set_trim", connector.get_trim())
|
||||||
|
instruments.call("update_pfd", connector.get_aircraft(), connector.get_velocity())
|
||||||
|
|
||||||
# Spin the rotor only when receiving flight data
|
# Spin the rotor only when receiving flight data
|
||||||
if connector.get_model_connected():
|
if connector.get_model_connected():
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ fov = 60.0
|
||||||
|
|
||||||
[node name="Instruments" parent="AttitudeRoot" instance=ExtResource("3_5w717")]
|
[node name="Instruments" parent="AttitudeRoot" instance=ExtResource("3_5w717")]
|
||||||
transform = Transform3D(-0.5, -1.27582e-08, 7.43353e-08, 4.33325e-10, 0.4923, 0.0874084, -7.5421e-08, 0.0874084, -0.4923, 0.00724897, -1.1581, 2.40391)
|
transform = Transform3D(-0.5, -1.27582e-08, 7.43353e-08, 4.33325e-10, 0.4923, 0.0874084, -7.5421e-08, 0.0874084, -0.4923, 0.00724897, -1.1581, 2.40391)
|
||||||
lidia_hostname = "127.0.0.1"
|
|
||||||
|
|
||||||
[node name="MarshConnector" type="MarshConnector" parent="."]
|
[node name="MarshConnector" type="MarshConnector" parent="."]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,12 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
const PFD_PATH: String = "pfd#adi,vsi,alt,ias,rht,rpm,hsi"
|
|
||||||
|
|
||||||
@export var lidia_hostname: String = "localhost"
|
|
||||||
@export var lidia_port: int = 5555
|
|
||||||
|
|
||||||
@onready var controls: Node = $SubViewport2/Controls
|
@onready var controls: Node = $SubViewport2/Controls
|
||||||
|
@onready var pfd: Node = $SubViewport/PFD
|
||||||
func _ready():
|
|
||||||
if !$CEF.initialize({"incognito":true, "locale":"en-US"}):
|
|
||||||
push_error($CEF.get_error())
|
|
||||||
get_tree().quit()
|
|
||||||
return
|
|
||||||
print("CEF version: " + $CEF.get_full_version())
|
|
||||||
|
|
||||||
# Wait one frame for the texture rect to get its size
|
|
||||||
await get_tree().process_frame
|
|
||||||
|
|
||||||
var browser_pfd = $CEF.create_browser(
|
|
||||||
"http://{}:{}/{}".format([lidia_hostname, lidia_port, PFD_PATH], "{}"),
|
|
||||||
$SubViewport/TextureRect,
|
|
||||||
{ "frame_rate": 90, "javascript": true },
|
|
||||||
)
|
|
||||||
browser_pfd.name = "pfd"
|
|
||||||
browser_pfd.enable_ad_block(false) # Required for lidia static assets
|
|
||||||
|
|
||||||
# Propagate the calls to child
|
# Propagate the calls to child
|
||||||
func set_controls(current: Vector4):
|
func set_controls(current: Vector4):
|
||||||
controls.set("controls", current)
|
controls.set("controls", current)
|
||||||
func set_trim(trim: Vector4):
|
func set_trim(trim: Vector4):
|
||||||
controls.set("trim", trim)
|
controls.set("trim", trim)
|
||||||
|
func update_pfd(aircraft: Transform3D, velocity: Vector3):
|
||||||
|
pfd.call("update", aircraft, velocity)
|
||||||
|
|
|
||||||
41
project/instruments/RobotoMono-LICENSE.txt
Normal file
41
project/instruments/RobotoMono-LICENSE.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
Roboto Mono
|
||||||
|
|
||||||
|
Copyright 2015 Google
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
=====================================================================
|
||||||
|
|
||||||
|
Socket.IO
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2014-2022 Guillermo Rauch
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
BIN
project/instruments/RobotoMono-Regular.ttf
Normal file
BIN
project/instruments/RobotoMono-Regular.ttf
Normal file
Binary file not shown.
35
project/instruments/RobotoMono-Regular.ttf.import
Normal file
35
project/instruments/RobotoMono-Regular.ttf.import
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://chqgmpsthpbgt"
|
||||||
|
path="res://.godot/imported/RobotoMono-Regular.ttf-48a8b9dfd581c05f54f90e11c9fc9d5f.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://instruments/RobotoMono-Regular.ttf"
|
||||||
|
dest_files=["res://.godot/imported/RobotoMono-Regular.ttf-48a8b9dfd581c05f54f90e11c9fc9d5f.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
disable_embedded_bitmaps=true
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=4
|
||||||
|
keep_rounding_remainders=true
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=true
|
||||||
|
preload=[]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
||||||
BIN
project/instruments/heading-ticks.png
(Stored with Git LFS)
Normal file
BIN
project/instruments/heading-ticks.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
project/instruments/heading-ticks.png.import
Normal file
34
project/instruments/heading-ticks.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c36kaqyfalb2v"
|
||||||
|
path="res://.godot/imported/heading-ticks.png-8d0b08e5e3af463192c04d5a2068a1e0.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://instruments/heading-ticks.png"
|
||||||
|
dest_files=["res://.godot/imported/heading-ticks.png-8d0b08e5e3af463192c04d5a2068a1e0.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
project/instruments/horizon-mask.png
(Stored with Git LFS)
Normal file
BIN
project/instruments/horizon-mask.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
project/instruments/horizon-mask.png.import
Normal file
34
project/instruments/horizon-mask.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c5nbrnus8pcyd"
|
||||||
|
path="res://.godot/imported/horizon-mask.png-03d2bafdd84b9816ae1fe68fc4baf43d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://instruments/horizon-mask.png"
|
||||||
|
dest_files=["res://.godot/imported/horizon-mask.png-03d2bafdd84b9816ae1fe68fc4baf43d.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
project/instruments/horizon-overlay.png
(Stored with Git LFS)
Normal file
BIN
project/instruments/horizon-overlay.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
project/instruments/horizon-overlay.png.import
Normal file
34
project/instruments/horizon-overlay.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://b703lu8yhaoav"
|
||||||
|
path="res://.godot/imported/horizon-overlay.png-7e128e1a0dd8183251d6119879899864.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://instruments/horizon-overlay.png"
|
||||||
|
dest_files=["res://.godot/imported/horizon-overlay.png-7e128e1a0dd8183251d6119879899864.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
project/instruments/horizon.png
(Stored with Git LFS)
Normal file
BIN
project/instruments/horizon.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
project/instruments/horizon.png.import
Normal file
34
project/instruments/horizon.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bxdfrv8bovdai"
|
||||||
|
path="res://.godot/imported/horizon.png-9384af1095d9251c4f8861113a545ccf.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://instruments/horizon.png"
|
||||||
|
dest_files=["res://.godot/imported/horizon.png-9384af1095d9251c4f8861113a545ccf.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://cis4s43ubuynp"]
|
[gd_scene load_steps=9 format=3 uid="uid://cis4s43ubuynp"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://01bmfj4wthwg" path="res://instruments.gd" id="1_wlkep"]
|
[ext_resource type="Script" uid="uid://01bmfj4wthwg" path="res://instruments.gd" id="1_wlkep"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bgkpwebqksth5" path="res://instruments/controls.tscn" id="2_372d7"]
|
[ext_resource type="PackedScene" uid="uid://bgkpwebqksth5" path="res://instruments/controls.tscn" id="2_372d7"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b26tu6wb2h3ce" path="res://instruments/pfd.tscn" id="2_uhiu3"]
|
||||||
|
|
||||||
[sub_resource type="QuadMesh" id="QuadMesh_nowl7"]
|
[sub_resource type="QuadMesh" id="QuadMesh_nowl7"]
|
||||||
|
|
||||||
|
|
@ -21,14 +22,11 @@ albedo_texture = SubResource("ViewportTexture_h5at3")
|
||||||
|
|
||||||
[node name="Instruments" type="Node3D"]
|
[node name="Instruments" type="Node3D"]
|
||||||
script = ExtResource("1_wlkep")
|
script = ExtResource("1_wlkep")
|
||||||
lidia_hostname = "192.168.1.2"
|
|
||||||
|
|
||||||
[node name="SubViewport" type="SubViewport" parent="."]
|
[node name="SubViewport" type="SubViewport" parent="."]
|
||||||
|
size = Vector2i(1024, 1024)
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="SubViewport"]
|
[node name="PFD" parent="SubViewport" instance=ExtResource("2_uhiu3")]
|
||||||
offset_right = 512.0
|
|
||||||
offset_bottom = 512.0
|
|
||||||
expand_mode = 5
|
|
||||||
|
|
||||||
[node name="Quad" type="MeshInstance3D" parent="."]
|
[node name="Quad" type="MeshInstance3D" parent="."]
|
||||||
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, -0.35, 0, 0)
|
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, -0.35, 0, 0)
|
||||||
|
|
|
||||||
BIN
project/instruments/pfd-background.png
(Stored with Git LFS)
Normal file
BIN
project/instruments/pfd-background.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
project/instruments/pfd-background.png.import
Normal file
34
project/instruments/pfd-background.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://colp4xsovikmv"
|
||||||
|
path="res://.godot/imported/pfd-background.png-99626101f4d3a30d7dd189ac71adf1c0.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://instruments/pfd-background.png"
|
||||||
|
dest_files=["res://.godot/imported/pfd-background.png-99626101f4d3a30d7dd189ac71adf1c0.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
project/instruments/pfd-ref.png
(Stored with Git LFS)
BIN
project/instruments/pfd-ref.png
(Stored with Git LFS)
Binary file not shown.
50
project/instruments/pfd.gd
Normal file
50
project/instruments/pfd.gd
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
@tool
|
||||||
|
class_name PFD
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@export var euler_attitude_deg: Vector3:
|
||||||
|
set(value):
|
||||||
|
euler_attitude_deg = value
|
||||||
|
horizon_pivot.rotation = deg_to_rad(-value.x)
|
||||||
|
const px_per_deg: float = 6.56
|
||||||
|
horizon_background.position.y = px_per_deg * clamp(value.y, -30, 30)
|
||||||
|
heading_ticks.rotation = deg_to_rad(-value.z)
|
||||||
|
heading_label.text = "%03d" % (int(round(value.z) + 360) % 360)
|
||||||
|
|
||||||
|
@export var airspeed: float:
|
||||||
|
set(value):
|
||||||
|
airspeed = value
|
||||||
|
airspeed_label.text = str(int(round(value)))
|
||||||
|
|
||||||
|
@export var groundspeed: float:
|
||||||
|
set(value):
|
||||||
|
groundspeed = value
|
||||||
|
groundspeed_label.text = str(int(round(value)))
|
||||||
|
|
||||||
|
@export var altitude: float:
|
||||||
|
set(value):
|
||||||
|
altitude = value
|
||||||
|
var step = 1
|
||||||
|
if value > 49.5:
|
||||||
|
step = 5
|
||||||
|
if value > 99.5:
|
||||||
|
step = 10
|
||||||
|
altitude_label.text = str(int(step * round(value / step)))
|
||||||
|
|
||||||
|
@export var climbrate: float = 1000:
|
||||||
|
set(value):
|
||||||
|
climbrate = value
|
||||||
|
climbrate_arrow.scale.y = clamp(value / 1000.0, -1, 1)
|
||||||
|
|
||||||
|
@onready var horizon_pivot: Node2D = $HorizonMask/HorizonOrigin/Pivot
|
||||||
|
@onready var horizon_background: Node2D = $HorizonMask/HorizonOrigin/Pivot/Background
|
||||||
|
@onready var heading_ticks: Node2D = $HeadingOrigin/Ticks
|
||||||
|
@onready var climbrate_arrow: Node2D = $ClimbrateOrigin/Polygon2D
|
||||||
|
@onready var airspeed_label: Label = $Airspeed
|
||||||
|
@onready var groundspeed_label: Label = $Groundspeed
|
||||||
|
@onready var altitude_label: Label = $Altitude
|
||||||
|
@onready var heading_label: Label = $Heading
|
||||||
|
|
||||||
|
func update(aircraft: Transform3D, velocity: Vector3):
|
||||||
|
var godot_euler = aircraft.basis.get_euler()
|
||||||
|
euler_attitude_deg = Vector3(godot_euler.z, -godot_euler.x, -godot_euler.y) * rad_to_deg(1)
|
||||||
1
project/instruments/pfd.gd.uid
Normal file
1
project/instruments/pfd.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://368tfiyen071
|
||||||
103
project/instruments/pfd.tscn
Normal file
103
project/instruments/pfd.tscn
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
[gd_scene load_steps=9 format=3 uid="uid://b26tu6wb2h3ce"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://colp4xsovikmv" path="res://instruments/pfd-background.png" id="1_inkqg"]
|
||||||
|
[ext_resource type="Script" uid="uid://368tfiyen071" path="res://instruments/pfd.gd" id="1_t02it"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c5nbrnus8pcyd" path="res://instruments/horizon-mask.png" id="2_t02it"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bxdfrv8bovdai" path="res://instruments/horizon.png" id="3_kwqn1"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b703lu8yhaoav" path="res://instruments/horizon-overlay.png" id="4_1vq1p"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c36kaqyfalb2v" path="res://instruments/heading-ticks.png" id="5_3w2cf"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://chqgmpsthpbgt" path="res://instruments/RobotoMono-Regular.ttf" id="6_wtx4e"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://toojp8r3424r" path="res://instruments/pfd-ref.png" id="7_86xjv"]
|
||||||
|
|
||||||
|
[node name="PFD" type="Node2D"]
|
||||||
|
script = ExtResource("1_t02it")
|
||||||
|
|
||||||
|
[node name="Background" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(512, 512)
|
||||||
|
texture = ExtResource("1_inkqg")
|
||||||
|
|
||||||
|
[node name="HorizonMask" type="Sprite2D" parent="."]
|
||||||
|
clip_children = 1
|
||||||
|
position = Vector2(512, 512)
|
||||||
|
texture = ExtResource("2_t02it")
|
||||||
|
|
||||||
|
[node name="HorizonOrigin" type="Node2D" parent="HorizonMask"]
|
||||||
|
position = Vector2(-82, -244)
|
||||||
|
|
||||||
|
[node name="Pivot" type="Node2D" parent="HorizonMask/HorizonOrigin"]
|
||||||
|
|
||||||
|
[node name="Background" type="Sprite2D" parent="HorizonMask/HorizonOrigin/Pivot"]
|
||||||
|
texture = ExtResource("3_kwqn1")
|
||||||
|
|
||||||
|
[node name="RollArrowContour" type="Polygon2D" parent="HorizonMask/HorizonOrigin/Pivot"]
|
||||||
|
position = Vector2(-430, -267)
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
|
polygon = PackedVector2Array(430, 70, 416, 92, 444, 92)
|
||||||
|
|
||||||
|
[node name="RollArrowFill" type="Polygon2D" parent="HorizonMask/HorizonOrigin/Pivot"]
|
||||||
|
position = Vector2(-430, -267)
|
||||||
|
polygon = PackedVector2Array(430, 74, 420, 90, 440, 90)
|
||||||
|
|
||||||
|
[node name="Overlay" type="Sprite2D" parent="HorizonMask/HorizonOrigin"]
|
||||||
|
texture = ExtResource("4_1vq1p")
|
||||||
|
|
||||||
|
[node name="HeadingOrigin" type="Node2D" parent="."]
|
||||||
|
position = Vector2(430, 794)
|
||||||
|
|
||||||
|
[node name="Ticks" type="Sprite2D" parent="HeadingOrigin"]
|
||||||
|
texture = ExtResource("5_3w2cf")
|
||||||
|
|
||||||
|
[node name="ClimbrateOrigin" type="Node2D" parent="."]
|
||||||
|
position = Vector2(711, 268)
|
||||||
|
|
||||||
|
[node name="Polygon2D" type="Polygon2D" parent="ClimbrateOrigin"]
|
||||||
|
polygon = PackedVector2Array(12, 0, -12, 0, -12, -121, 0, -133, 12, -121)
|
||||||
|
|
||||||
|
[node name="Airspeed" type="Label" parent="."]
|
||||||
|
offset_left = 35.0
|
||||||
|
offset_top = 233.0
|
||||||
|
offset_right = 154.0
|
||||||
|
offset_bottom = 298.0
|
||||||
|
theme_override_fonts/font = ExtResource("6_wtx4e")
|
||||||
|
theme_override_font_sizes/font_size = 48
|
||||||
|
text = "0"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Groundspeed" type="Label" parent="."]
|
||||||
|
offset_left = 59.0
|
||||||
|
offset_top = 477.0
|
||||||
|
offset_right = 178.0
|
||||||
|
offset_bottom = 542.0
|
||||||
|
theme_override_fonts/font = ExtResource("6_wtx4e")
|
||||||
|
theme_override_font_sizes/font_size = 33
|
||||||
|
text = "0"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Altitude" type="Label" parent="."]
|
||||||
|
offset_left = 859.0
|
||||||
|
offset_top = 233.0
|
||||||
|
offset_right = 978.0
|
||||||
|
offset_bottom = 298.0
|
||||||
|
theme_override_fonts/font = ExtResource("6_wtx4e")
|
||||||
|
theme_override_font_sizes/font_size = 48
|
||||||
|
text = "0"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Heading" type="Label" parent="."]
|
||||||
|
offset_left = 370.0
|
||||||
|
offset_top = 498.0
|
||||||
|
offset_right = 489.0
|
||||||
|
offset_bottom = 563.0
|
||||||
|
theme_override_fonts/font = ExtResource("6_wtx4e")
|
||||||
|
theme_override_font_sizes/font_size = 33
|
||||||
|
text = "000"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Reference" type="Sprite2D" parent="."]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(512, 512)
|
||||||
|
texture = ExtResource("7_86xjv")
|
||||||
|
|
@ -34,6 +34,7 @@ using namespace godot;
|
||||||
void MarshConnector::_bind_methods() {
|
void MarshConnector::_bind_methods() {
|
||||||
// Data access
|
// Data access
|
||||||
ClassDB::bind_method(D_METHOD("get_aircraft"), &MarshConnector::get_aircraft);
|
ClassDB::bind_method(D_METHOD("get_aircraft"), &MarshConnector::get_aircraft);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_velocity"), &MarshConnector::get_velocity);
|
||||||
ClassDB::bind_method(D_METHOD("get_cyclic"), &MarshConnector::get_cyclic);
|
ClassDB::bind_method(D_METHOD("get_cyclic"), &MarshConnector::get_cyclic);
|
||||||
ClassDB::bind_method(D_METHOD("get_collective"),
|
ClassDB::bind_method(D_METHOD("get_collective"),
|
||||||
&MarshConnector::get_collective);
|
&MarshConnector::get_collective);
|
||||||
|
|
@ -242,6 +243,8 @@ Transform3D MarshConnector::get_aircraft() {
|
||||||
return offset * marsh;
|
return offset * marsh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 MarshConnector::get_velocity() { return last_velocity; }
|
||||||
|
|
||||||
Vector2 MarshConnector::get_cyclic() {
|
Vector2 MarshConnector::get_cyclic() {
|
||||||
return Vector2{last_controls.x, last_controls.y};
|
return Vector2{last_controls.x, last_controls.y};
|
||||||
}
|
}
|
||||||
|
|
@ -293,6 +296,8 @@ void MarshConnector::handle_sim_state(mavlink_message_t message) {
|
||||||
local_position.x, local_position.y, sim_state.alt));
|
local_position.x, local_position.y, sim_state.alt));
|
||||||
receive_rotation(godot_rotation_from_mavlink(sim_state.roll, sim_state.pitch,
|
receive_rotation(godot_rotation_from_mavlink(sim_state.roll, sim_state.pitch,
|
||||||
sim_state.yaw));
|
sim_state.yaw));
|
||||||
|
|
||||||
|
last_velocity = Vector3{-sim_state.ve, -sim_state.vd, sim_state.vn};
|
||||||
}
|
}
|
||||||
Vector3 MarshConnector::godot_location_from_mavlink(float north_meters,
|
Vector3 MarshConnector::godot_location_from_mavlink(float north_meters,
|
||||||
float east_meters,
|
float east_meters,
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ public:
|
||||||
|
|
||||||
// Get current state of the aircraft
|
// Get current state of the aircraft
|
||||||
Transform3D get_aircraft();
|
Transform3D get_aircraft();
|
||||||
|
Vector3 get_velocity();
|
||||||
// Get normalized (-1 to 1) cyclic position, where X is right, Y is pitch up
|
// Get normalized (-1 to 1) cyclic position, where X is right, Y is pitch up
|
||||||
Vector2 get_cyclic();
|
Vector2 get_cyclic();
|
||||||
// Get normalized (0 to 1) collective position, positive to climb
|
// Get normalized (0 to 1) collective position, positive to climb
|
||||||
|
|
@ -118,6 +119,7 @@ private:
|
||||||
// Or not, in practice the simple solution works nicely
|
// Or not, in practice the simple solution works nicely
|
||||||
Vector3 last_location;
|
Vector3 last_location;
|
||||||
Quaternion last_rotation;
|
Quaternion last_rotation;
|
||||||
|
Vector3 last_velocity;
|
||||||
Vector4 last_controls;
|
Vector4 last_controls;
|
||||||
Vector4 last_trim;
|
Vector4 last_trim;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue