Skip to content

Commit adf605b

Browse files
committed
🐛 remove buggy ground altitude correcting
1 parent 1a1e4ec commit adf605b

2 files changed

Lines changed: 0 additions & 42 deletions

File tree

src/yourcontrols/src/corrector.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,11 @@ use yourcontrols_types::{AVarMap, VarReaderTypes};
44
use crate::sync::transfer::AircraftVars;
55
use crate::util::InDataTypes;
66

7-
const ALTITUDE_CHANGE_THRESHOLD: f64 = 1000.0;
8-
97
#[derive(Default)]
108
struct Current {
119
wind_z: f64,
12-
ground_alt: f64,
13-
alt_above_ground: f64,
1410
}
1511

16-
fn average(new_value: f64, average: f64) -> f64 {
17-
return average + (new_value - average) / 5 as f64;
18-
}
1912
// In order to synchronize groundspeed in different winds, the Z component is removed remotely and added locally
2013
// Because A:PLANE ALT ABOVE GROUND is not directly setable by execute_calculate_code, the logic is done in this struct instead where the ground altitude is removed remotely below 1000 feet, and added back locally.
2114
pub struct Corrector {
@@ -28,8 +21,6 @@ impl Corrector {
2821
let mut avars = AircraftVars::new(define_id);
2922

3023
avars.add_var("AIRCRAFT WIND Z", "Feet per second", InDataTypes::F64);
31-
avars.add_var("GROUND ALTITUDE", "Feet", InDataTypes::F64);
32-
avars.add_var("PLANE ALT ABOVE GROUND", "Feet", InDataTypes::F64);
3324

3425
Self {
3526
avars,
@@ -41,30 +32,12 @@ impl Corrector {
4132
if let Some(VarReaderTypes::F64(velocity)) = data.get_mut("VELOCITY BODY Z") {
4233
*velocity -= self.current.wind_z
4334
}
44-
45-
if let Some(VarReaderTypes::F64(altitude)) = data.get_mut("PLANE ALTITUDE") {
46-
if self.current.alt_above_ground <= ALTITUDE_CHANGE_THRESHOLD {
47-
*altitude -= self.current.ground_alt;
48-
// Mark for adding back
49-
data.insert("CORRECTED".to_string(), VarReaderTypes::Bool(true));
50-
}
51-
}
5235
}
5336

5437
pub fn add_components(&self, data: &mut AVarMap) {
5538
if let Some(VarReaderTypes::F64(velocity)) = data.get_mut("VELOCITY BODY Z") {
5639
*velocity += self.current.wind_z
5740
}
58-
59-
let is_altitude_corrected = data
60-
.remove("CORRECTED")
61-
.is_some();
62-
63-
if let Some(VarReaderTypes::F64(altitude)) = data.get_mut("PLANE ALTITUDE") {
64-
if is_altitude_corrected {
65-
*altitude += self.current.ground_alt
66-
}
67-
}
6841
}
6942

7043
pub fn on_connected(&self, conn: &SimConnector) {
@@ -91,19 +64,6 @@ impl Corrector {
9164
if let Some(VarReaderTypes::F64(velocity)) = data.get("AIRCRAFT WIND Z") {
9265
self.current.wind_z = *velocity;
9366
}
94-
95-
if let Some(VarReaderTypes::F64(altitude)) = data.get("GROUND ALTITUDE") {
96-
if self.current.ground_alt == 0.0 {
97-
// Not set yet, set value right away without averaging
98-
self.current.ground_alt = *altitude
99-
} else {
100-
self.current.ground_alt = average(*altitude, self.current.ground_alt);
101-
}
102-
}
103-
104-
if let Some(VarReaderTypes::F64(altitude)) = data.get("PLANE ALT ABOVE GROUND") {
105-
self.current.alt_above_ground = *altitude;
106-
}
10767
}
10868
}
10969
}

src/yourcontrols/src/definitions.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,8 +1106,6 @@ impl Definitions {
11061106

11071107
// Shrink all maps
11081108
self.shrink_maps();
1109-
// Add corrector thing
1110-
self.unreliable_vars.insert("CORRECTED".to_string());
11111109

11121110
Ok(())
11131111
}

0 commit comments

Comments
 (0)