bool GlideComputerAirData::FlightTimes(const NMEAInfo &basic, const NMEAInfo &last_basic, DerivedInfo &calculated, const ComputerSettings &settings) { if (basic.gps.replay != last_basic.gps.replay) // reset flight before/after replay logger ResetFlight(calculated, basic.gps.replay); if (basic.time_available && basic.HasTimeRetreatedSince(last_basic)) { // 20060519:sgi added (basic.Time != 0) due to always return here // if no GPS time available if (basic.location_available) // Reset statistics.. (probably due to being in IGC replay mode) ResetFlight(calculated, false); return false; } FlightState(basic, calculated, calculated.flight, settings.polar.glide_polar_task); return true; }
void Ship::Load(Serializer::Reader &rd, Space *space) { DynamicBody::Load(rd, space); // needs fixups m_angThrusters = rd.Vector3d(); m_thrusters = rd.Vector3d(); m_wheelTransition = rd.Int32(); m_wheelState = rd.Float(); m_launchLockTimeout = rd.Float(); m_testLanded = rd.Bool(); m_flightState = FlightState(rd.Int32()); m_alertState = AlertState(rd.Int32()); m_lastFiringAlert = rd.Double(); m_hyperspace.dest = SystemPath::Unserialize(rd); m_hyperspace.countdown = rd.Float(); for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) { m_gunState[i] = rd.Int32(); m_gunRecharge[i] = rd.Float(); m_gunTemperature[i] = rd.Float(); } m_ecmRecharge = rd.Float(); m_shipFlavour.Load(rd); m_type = &ShipType::types[m_shipFlavour.id]; m_dockedWithPort = rd.Int32(); m_dockedWithIndex = rd.Int32(); m_equipment.InitSlotSizes(m_shipFlavour.id); m_equipment.Load(rd); Init(); m_stats.hull_mass_left = rd.Float(); // must be after Init()... m_stats.shield_mass_left = rd.Float(); if(rd.Int32()) m_curAICmd = AICommand::Load(rd); else m_curAICmd = 0; m_aiMessage = AIError(rd.Int32()); SetFuel(rd.Double()); m_stats.fuel_tank_mass_left = GetShipType().fuelTankMass * GetFuel(); m_reserveFuel = rd.Double(); UpdateStats(); // this is necessary, UpdateStats() in Ship::Init has wrong values of m_thrusterFuel after Load m_controller = 0; const ShipController::Type ctype = static_cast<ShipController::Type>(rd.Int32()); if (ctype == ShipController::PLAYER) SetController(new PlayerShipController()); else SetController(new ShipController()); m_controller->Load(rd); m_equipment.onChange.connect(sigc::mem_fun(this, &Ship::OnEquipmentChange)); }
void Ship::Load(Serializer::Reader &rd) { DynamicBody::Load(rd); // needs fixups m_angThrusters = rd.Vector3d(); m_thrusters = rd.Vector3d(); m_wheelTransition = rd.Int32(); m_wheelState = rd.Float(); m_launchLockTimeout = rd.Float(); m_testLanded = rd.Bool(); m_flightState = FlightState(rd.Int32()); m_alertState = AlertState(rd.Int32()); m_lastFiringAlert = rd.Float(); m_hyperspace.dest = SystemPath::Unserialize(rd); m_hyperspace.countdown = rd.Float(); for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) { m_gunState[i] = rd.Int32(); m_gunRecharge[i] = rd.Float(); m_gunTemperature[i] = rd.Float(); } m_ecmRecharge = rd.Float(); m_shipFlavour.Load(rd); m_dockedWithPort = rd.Int32(); m_dockedWithIndex = rd.Int32(); m_equipment.InitSlotSizes(m_shipFlavour.type); m_equipment.Load(rd); Init(); m_stats.hull_mass_left = rd.Float(); // must be after Init()... m_stats.shield_mass_left = rd.Float(); if(rd.Int32()) m_curAICmd = AICommand::Load(rd); else m_curAICmd = 0; m_equipment.onChange.connect(sigc::mem_fun(this, &Ship::OnEquipmentChange)); }
void RocketSystem::update() { //static int time = 0; //if (time % 1000 == 0) { // chprintf((BaseSequentialStream*)&SD4, "%d\r\n", RTT2MS(chibios_rt::System::getTime())); //} //time = (time+1) % 1000; // Poll sensors AccelerometerReading accelReading = accel.readAccel(); GyroscopeReading gyrReading = gyr.readGyro(); optional<AccelerometerReading> accelHReading; optional<BarometerReading> barReading; optional<GeigerReading> ggrReading; optional<GPSReading> gpsReading; optional<MagnetometerReading> magReading; if (accelH) accelHReading = (*accelH)->readAccel(); if (bar) barReading = (*bar)->readBar(); if (ggr) ggrReading = (*ggr)->readGeiger(); if (gps) gpsReading = (*gps)->readGPS(); if (mag) magReading = (*mag)->readMag(); SensorMeasurements meas { .accel = std::experimental::make_optional(accelReading), .accelH = accelHReading, .bar = barReading, .ggr = ggrReading, .gps = gpsReading, .gyro = std::experimental::make_optional(gyrReading), .mag = magReading }; // Update the world estimate WorldEstimate estimate = estimator.update(meas); // Run the controllers ActuatorSetpoint actuatorSp = {0,0,0,0}; // Run state machine switch (state) { case RocketState::DISARMED: state = DisarmedState(meas, estimate, actuatorSp); break; case RocketState::PRE_ARM: state = PreArmState(meas, estimate, actuatorSp); break; case RocketState::ARMED: state = ArmedState(meas, estimate, actuatorSp); break; case RocketState::FLIGHT: state = FlightState(meas, estimate, actuatorSp); break; case RocketState::APOGEE: state = ApogeeState(meas, estimate, actuatorSp); break; case RocketState::DESCENT: state = DescentState(meas, estimate, actuatorSp); break; case RocketState::RECOVERY: state = RecoveryState(meas, estimate, actuatorSp); break; default: break; } // Update motor outputs motorMapper.run(isArmed(), actuatorSp); // Poll for controller input ControllerInput input = inputSource.read(); // Update streams updateStreams(meas, estimate, actuatorSp); }