Loading...
Searching...
No Matches
FlightSimulator.h
Go to the documentation of this file.
#ifndef FLIGHTSIMULATOR_H
#define FLIGHTSIMULATOR_H
#include <memory>
#include <vector>
class Rocket;
class Environment;
class ForcesModel;
class FlightState;
class Integrator;
class FlightSimulator {
public:
FlightSimulator(std::shared_ptr<Rocket> rocket,
std::shared_ptr<Environment> environment);
~FlightSimulator() = default;
void run(double maxSimulationTime, double timeStep);
const std::vector<FlightState>& getFlightLog() const;
private:
std::shared_ptr<Rocket> rocket_;
std::shared_ptr<Environment> environment_;
std::shared_ptr<ForcesModel> forcesModel_;
std::unique_ptr<Integrator> integrator_;
std::vector<FlightState> flightLog_;
bool hasLaunched_ = false;
void initialize();
void step(double deltaTime);
void handleEvents(FlightState& state);
bool checkTermination(const FlightState& state);
void updateMotors(double deltaTime);
};
#endif // FLIGHTSIMULATOR_H
Environment
Models atmospheric and gravitational conditions for the flight simulation.
Definition Environment.h:10
FlightSimulator::~FlightSimulator
~FlightSimulator()=default
Default destructor.
FlightSimulator::checkTermination
bool checkTermination(const FlightState &state)
Checks if simulation termination conditions are met (e.g., landed).
Definition FlightSimulator.cpp:94
FlightSimulator::integrator_
std::unique_ptr< Integrator > integrator_
Integrates equations of motion.
Definition FlightSimulator.h:52
FlightSimulator::FlightSimulator
FlightSimulator(std::shared_ptr< Rocket > rocket, std::shared_ptr< Environment > environment)
Constructs a new FlightSimulator.
Definition FlightSimulator.cpp:15
FlightSimulator::run
void run(double maxSimulationTime, double timeStep)
Runs the full flight simulation.
Definition FlightSimulator.cpp:26
FlightSimulator::handleEvents
void handleEvents(FlightState &state)
Detects and processes key events (burnout, separation, recovery).
Definition FlightSimulator.cpp:90
FlightSimulator::updateMotors
void updateMotors(double deltaTime)
Definition FlightSimulator.cpp:82
FlightSimulator::getFlightLog
const std::vector< FlightState > & getFlightLog() const
Returns the recorded flight states over time.
Definition FlightSimulator.cpp:54
FlightSimulator::hasLaunched_
bool hasLaunched_
Have we left the lauch pad/rail?
Definition FlightSimulator.h:56
FlightSimulator::step
void step(double deltaTime)
Advances the simulation by one time step.
Definition FlightSimulator.cpp:64
FlightSimulator::forcesModel_
std::shared_ptr< ForcesModel > forcesModel_
Computes forces and moments on the rocket.
Definition FlightSimulator.h:51
FlightSimulator::rocket_
std::shared_ptr< Rocket > rocket_
Rocket being simulated.
Definition FlightSimulator.h:48
FlightSimulator::environment_
std::shared_ptr< Environment > environment_
Atmospheric and gravity conditions.
Definition FlightSimulator.h:49
FlightSimulator::flightLog_
std::vector< FlightState > flightLog_
Time history of flight state snapshots.
Definition FlightSimulator.h:54
FlightSimulator::initialize
void initialize()
Initializes simulation (prepare rocket, set initial conditions).
Definition FlightSimulator.cpp:60
FlightState
Represents the physical state of the rocket at a given simulation time.
Definition FlightState.h:12
ForcesModel
Computes aerodynamic, thrust, and gravitational forces acting on the rocket.
Definition ForcesModel.h:17
Integrator
Advances the rocket's flight state using numerical integration.
Definition Integrator.h:18
Rocket
Represents a complete rocket vehicle composed of stages, motors, and recovery systems.
Definition Rocket.h:20