QtRocket
 
Loading...
Searching...
No Matches
FlightSimulator Class Reference

Manages the simulation of a rocket flight from launch to landing. More...

#include <FlightSimulator.h>

Public Member Functions

 FlightSimulator (std::shared_ptr< Rocket > rocket, std::shared_ptr< Environment > environment)
 Constructs a new FlightSimulator.
 
 ~FlightSimulator ()=default
 Default destructor.
 
void run (double maxSimulationTime, double timeStep)
 Runs the full flight simulation.
 
const std::vector< FlightState > & getFlightLog () const
 Returns the recorded flight states over time.
 

Private Member Functions

void initialize ()
 Initializes simulation (prepare rocket, set initial conditions).
 
void step (double deltaTime)
 Advances the simulation by one time step.
 
void handleEvents (FlightState &state)
 Detects and processes key events (burnout, separation, recovery).
 
bool checkTermination (const FlightState &state)
 Checks if simulation termination conditions are met (e.g., landed).
 
void updateMotors (double deltaTime)
 

Private Attributes

std::shared_ptr< Rocketrocket_
 Rocket being simulated.
 
std::shared_ptr< Environmentenvironment_
 Atmospheric and gravity conditions.
 
std::shared_ptr< ForcesModelforcesModel_
 Computes forces and moments on the rocket.
 
std::unique_ptr< Integratorintegrator_
 Integrates equations of motion.
 
std::vector< FlightStateflightLog_
 Time history of flight state snapshots.
 
bool hasLaunched_ = false
 Have we left the lauch pad/rail?
 

Detailed Description

Manages the simulation of a rocket flight from launch to landing.

The FlightSimulator coordinates the rocket, environment, force models, and numerical integration to simulate rocket flight dynamics over time.

Constructor & Destructor Documentation

◆ FlightSimulator()

FlightSimulator::FlightSimulator ( std::shared_ptr< Rocket > rocket,
std::shared_ptr< Environment > environment )

Constructs a new FlightSimulator.

Parameters
rocketPointer to the rocket to simulate.
environmentPointer to the launch environment.

◆ ~FlightSimulator()

FlightSimulator::~FlightSimulator ( )
default

Default destructor.

Member Function Documentation

◆ checkTermination()

bool FlightSimulator::checkTermination ( const FlightState & state)
private

Checks if simulation termination conditions are met (e.g., landed).

Parameters
stateCurrent flight state.
Returns
True if simulation should stop.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFlightLog()

const std::vector< FlightState > & FlightSimulator::getFlightLog ( ) const

Returns the recorded flight states over time.

Returns
Vector of FlightState snapshots.
Here is the caller graph for this function:

◆ handleEvents()

void FlightSimulator::handleEvents ( FlightState & state)
private

Detects and processes key events (burnout, separation, recovery).

Parameters
stateCurrent flight state.
Here is the caller graph for this function:

◆ initialize()

void FlightSimulator::initialize ( )
private

Initializes simulation (prepare rocket, set initial conditions).

Here is the caller graph for this function:

◆ run()

void FlightSimulator::run ( double maxSimulationTime,
double timeStep )

Runs the full flight simulation.

Parameters
maxSimulationTimeMaximum allowable simulation time (seconds).
timeStepInitial time step for integration (seconds).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ step()

void FlightSimulator::step ( double deltaTime)
private

Advances the simulation by one time step.

Parameters
deltaTimeThe time step size (seconds).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateMotors()

void FlightSimulator::updateMotors ( double deltaTime)
private
Here is the caller graph for this function:

Member Data Documentation

◆ environment_

std::shared_ptr<Environment> FlightSimulator::environment_
private

Atmospheric and gravity conditions.

◆ flightLog_

std::vector<FlightState> FlightSimulator::flightLog_
private

Time history of flight state snapshots.

◆ forcesModel_

std::shared_ptr<ForcesModel> FlightSimulator::forcesModel_
private

Computes forces and moments on the rocket.

◆ hasLaunched_

bool FlightSimulator::hasLaunched_ = false
private

Have we left the lauch pad/rail?

◆ integrator_

std::unique_ptr<Integrator> FlightSimulator::integrator_
private

Integrates equations of motion.

◆ rocket_

std::shared_ptr<Rocket> FlightSimulator::rocket_
private

Rocket being simulated.


The documentation for this class was generated from the following files: