public void advance(FlightPathData flightPathData) { double rawHeadingChange = randomWalkFlightParameters.HeadingChangeScale * centeredRandom(); double newRawHeading = flightPathData.plane_heading_true + rawHeadingChange; double newRationalizedRawHeading = GeoCalcUtils.rationalizedCompassDirection(newRawHeading); double newHeading = heading.next(newRationalizedRawHeading); double headingChange = flightPathData.plane_heading_true - newHeading; flightPathData.plane_heading_true = newHeading; flightPathData.plane_heading_magnetic = newHeading; flightPathData.heading_indicator = newHeading; double rawVelocityChange = randomWalkFlightParameters.VelocityChangeScale * centeredRandom(); double newRawVelocity = flightPathData.ground_velocity + rawVelocityChange; double newRationalizedRawVelocity = rationalizedVelocity(newRawVelocity); double newGroundVelocity = velocity.next(newRationalizedRawVelocity); flightPathData.ground_velocity = newGroundVelocity; flightPathData.airspeed_true = newGroundVelocity; double rawAltitudeChange = randomWalkFlightParameters.AltitudeChangeScale * centeredRandom(); double newRawAltitude = flightPathData.altitude + rawAltitudeChange; double newRationalizedRawAltitude = rationalizedAltitude(newRawAltitude); double newAltitude = altitude.next(newRationalizedRawAltitude); double altitudeChange = flightPathData.altitude - newAltitude; flightPathData.altitude = (int)newAltitude; double distancePerTick = newGroundVelocity / TICKS_PER_HOUR; double distanceChange = distancePerTick * ticksPerAdvance; (double lat, double lon)newLatLon = GeoCalcUtils.calcLatLonOffset( GeoCalcUtils.normalizedIso6709GeoDirection(flightPathData.latitude), GeoCalcUtils.normalizedIso6709GeoDirection(flightPathData.longitude), newHeading, distanceChange ); //Console.WriteLine($"p({GeoCalcUtils.pcoord(newLatLon)}"); flightPathData.latitude = newLatLon.lat; flightPathData.longitude = newLatLon.lon; double altitudeChangePerSecond = altitudeChange / secondsPerSample; flightPathData.vertical_speed = (altitudeChangePerSecond / 60); // https://www.skybrary.aero/index.php/Rate_of_Turn#:~:text=The%20bank%20angle%20required%20to,10%20and%20then%20adding%207. double headingChangePerSecond = headingChange / secondsPerSample; double newRawPlaneBankAngle = ((flightPathData.airspeed_true / 10) + 7) * headingChangePerSecond / 3; flightPathData.plane_bank = rationalizeBankAngle(newRawPlaneBankAngle); //Console.WriteLine($"b{flightPathData.plane_bank} h{headingChangePerSecond}"); // https://www.cfinotebook.net/notebook/aerodynamics-and-performance/performance-calculations double rawPlanePitchAngle = altitudeChangePerSecond / (100 * flightPathData.airspeed_true); flightPathData.plane_pitch = rationalizePitchAngle(rawPlanePitchAngle); //Console.WriteLine($"p{flightPathData.plane_pitch} a{altitudeChangePerSecond}"); flightPathData.timestamp += ticksPerAdvance; }
public FlightDataGenerator( string name, FlightPathData initialFlightPathData, Action <FlightPathData> flightAdvancer ) { this.name = name; currentSample = FlightPathDataUtils.CopyOf(initialFlightPathData); flightPathDataStream = FlightPathDataStream(); this.flightAdvancer = flightAdvancer; }
private static FlightDataStructure FpdToFds(FlightPathData fpd) { return(new FlightDataStructure { timestamp = fpd.timestamp, latitude = fpd.latitude, longitude = fpd.longitude, altitude = fpd.altitude, altitude_above_ground = fpd.altitudeaboveground, engine1rpm = fpd.Eng1Rpm, engine2rpm = fpd.Eng2Rpm, engine3rpm = fpd.Eng3Rpm, engine4rpm = fpd.Eng4Rpm, lightsmask = fpd.LightsMask, ground_velocity = fpd.ground_velocity, plane_pitch = fpd.plane_pitch, plane_bank = fpd.plane_bank, plane_heading_true = fpd.plane_heading_true, plane_heading_magnetic = fpd.plane_heading_magnetic, plane_airspeed_indicated = fpd.plane_airspeed_indicated, airspeed_true = fpd.airspeed_true, vertical_speed = fpd.vertical_speed, heading_indicator = fpd.heading_indicator, flaps_handle_position = fpd.flaps_handle_position, spoilers_handle_position = fpd.spoilers_handle_position, gear_handle_position = fpd.gear_handle_position, ambient_wind_velocity = fpd.ambient_wind_velocity, ambient_wind_direction = fpd.ambient_wind_direction, ambient_temperature = fpd.ambient_temperature, stall_warning = fpd.stall_warning, overspeed_warning = fpd.overspeed_warning, is_gear_retractable = fpd.is_gear_retractable, spoiler_available = fpd.spoiler_available, sim_on_ground = fpd.sim_on_ground, // // No flight plan, so no values for the following... // //gps_wp_prev_latitude = null, //gps_wp_prev_longitude = null, //gps_wp_prev_altitude = null, //gps_wp_prev_id = null, //gps_wp_next_latitude = null, //gps_wp_next_longitude = null, //gps_wp_next_altitude = null, //gps_wp_next_id = null, //gps_flight_plan_wp_index = null, //gps_flight_plan_wp_count = null, }); }
public static FlightPathData CopyOf(FlightPathData source) { return(new FlightPathData { timestamp = source.timestamp, longitude = source.longitude, latitude = source.latitude, altitude = source.altitude, plane_pitch = source.plane_pitch, plane_bank = source.plane_bank, plane_heading_true = source.plane_heading_true, ground_velocity = source.ground_velocity, vertical_speed = source.vertical_speed, airspeed_true = source.airspeed_true, heading_indicator = source.heading_indicator, plane_airspeed_indicated = source.plane_airspeed_indicated, plane_heading_magnetic = source.plane_heading_magnetic, altitudeaboveground = source.altitudeaboveground, Eng1Rpm = source.Eng1Rpm, Eng2Rpm = source.Eng2Rpm, Eng3Rpm = source.Eng3Rpm, Eng4Rpm = source.Eng4Rpm, LightsMask = source.LightsMask, flaps_handle_position = source.flaps_handle_position, spoilers_handle_position = source.spoilers_handle_position, gear_handle_position = source.gear_handle_position, ambient_wind_velocity = source.ambient_wind_velocity, ambient_wind_direction = source.ambient_wind_direction, ambient_temperature = source.ambient_temperature, stall_warning = source.stall_warning, overspeed_warning = source.overspeed_warning, is_gear_retractable = source.is_gear_retractable, spoiler_available = source.spoiler_available, sim_on_ground = source.sim_on_ground }); }