Loading...
Searching...
No Matches
Stage.h
Go to the documentation of this file.
#ifndef STAGE_H
#define STAGE_H
#include <string>
#include <vector>
#include <memory>
class Motor;
class Airframe;
class FinSet;
class RecoverySystem;
class Environment;
class FlightState;
class Stage {
public:
Stage(const std::string& name);
~Stage() = default;
void addMotor(std::unique_ptr<Motor> motor);
void setAirframe(std::unique_ptr<Airframe> airframe);
void setFinSet(std::unique_ptr<FinSet> finSet);
void setRecoverySystem(std::unique_ptr<RecoverySystem> recovery);
double getTotalMass() const;
double getTotalPropellantMass() const;
void updateMassProperties();
void prepareForFlight(const Environment& env);
void applyFlightState(const FlightState& state);
bool checkSeparationEvent() const;
bool checkRecoveryEvent() const;
double getAirframeLength() const;
double calculateNormalForceCoefficient() const;
const std::string& getName() const;
std::array<double, 3> getTotalThrust() const;
// Only for testing access!
const std::vector<std::unique_ptr<Motor>>& getMotorsForTesting() const { return motors_; }
private:
std::string name_;
// Core Components
std::vector<std::unique_ptr<Motor>> motors_;
std::unique_ptr<Airframe> airframe_;
std::unique_ptr<FinSet> finSet_;
std::unique_ptr<RecoverySystem> recoverySystem_;
// Cached Mass Properties
double totalMass_;
double totalPropellantMass_;
// Event Flags
bool separationTriggered_;
bool recoveryDeployed_;
};
#endif // STAGE_H
Airframe
Represents the structural body and aerodynamic shell of a rocket stage.
Definition Airframe.h:12
Environment
Models atmospheric and gravitational conditions for the flight simulation.
Definition Environment.h:10
FinSet
Represents a set of aerodynamic fins attached to a rocket stage.
Definition FinSet.h:12
FlightState
Represents the physical state of the rocket at a given simulation time.
Definition FlightState.h:12
Motor
Represents a rocket motor with thrust characteristics over time.
Definition Motor.h:14
RecoverySystem
Represents a recovery system for a rocket stage.
Definition RecoverySystem.h:12
Stage::getTotalPropellantMass
double getTotalPropellantMass() const
Returns the current total propellant mass of all motors in the stage.
Definition Stage.cpp:45
Stage::updateMassProperties
void updateMassProperties()
Updates mass properties (e.g., after motor burn or separation).
Definition Stage.cpp:49
Stage::airframe_
std::unique_ptr< Airframe > airframe_
Structural body and aerodynamic surfaces.
Definition Stage.h:132
Stage::recoverySystem_
std::unique_ptr< RecoverySystem > recoverySystem_
Recovery deployment system.
Definition Stage.h:134
Stage::finSet_
std::unique_ptr< FinSet > finSet_
Fins for aerodynamic stability.
Definition Stage.h:133
Stage::checkSeparationEvent
bool checkSeparationEvent() const
Checks if the stage should separate (e.g., after burnout or trigger).
Definition Stage.cpp:82
Stage::setRecoverySystem
void setRecoverySystem(std::unique_ptr< RecoverySystem > recovery)
Sets the recovery system for the stage.
Definition Stage.cpp:37
Stage::calculateNormalForceCoefficient
double calculateNormalForceCoefficient() const
Calculates the normal force coefficient contribution from the stage's fins.
Definition Stage.cpp:111
Stage::recoveryDeployed_
bool recoveryDeployed_
Flag indicating recovery system deployment.
Definition Stage.h:142
Stage::setAirframe
void setAirframe(std::unique_ptr< Airframe > airframe)
Sets the airframe for the stage.
Definition Stage.cpp:29
Stage::~Stage
~Stage()=default
Default destructor.
Stage::motors_
std::vector< std::unique_ptr< Motor > > motors_
List of motors in this stage.
Definition Stage.h:131
Stage::getMotorsForTesting
const std::vector< std::unique_ptr< Motor > > & getMotorsForTesting() const
Definition Stage.h:124
Stage::checkRecoveryEvent
bool checkRecoveryEvent() const
Checks if the recovery system should deploy (e.g., apogee, velocity triggers).
Definition Stage.cpp:91
Stage::separationTriggered_
bool separationTriggered_
Flag indicating stage separation event.
Definition Stage.h:141
Stage::totalPropellantMass_
double totalPropellantMass_
Remaining propellant [kg].
Definition Stage.h:138
Stage::setFinSet
void setFinSet(std::unique_ptr< FinSet > finSet)
Sets the fin set for the stage.
Definition Stage.cpp:33
Stage::getTotalThrust
std::array< double, 3 > getTotalThrust() const
Calculates the total thrust vector produced by all motors in this stage.
Definition Stage.cpp:118
Stage::applyFlightState
void applyFlightState(const FlightState &state)
Updates the stage based on current flight conditions.
Definition Stage.cpp:77
Stage::prepareForFlight
void prepareForFlight(const Environment &env)
Prepares the stage for flight simulation (e.g., motor ignition sequencing).
Definition Stage.cpp:70
Stage::getName
const std::string & getName() const
Gets the name of the stage.
Definition Stage.cpp:100
Stage::addMotor
void addMotor(std::unique_ptr< Motor > motor)
Adds a motor to the stage.
Definition Stage.cpp:25
Stage::Stage
Stage(const std::string &name)
Constructs a new Stage with a given name.
Definition Stage.cpp:15
Stage::totalMass_
double totalMass_
Total mass [kg].
Definition Stage.h:137
Stage::name_
std::string name_
Name of the stage.
Definition Stage.h:128
Stage::getTotalMass
double getTotalMass() const
Returns the total mass of the stage (structure + motors + payload).
Definition Stage.cpp:41
Stage::getAirframeLength
double getAirframeLength() const
Gets the length of the airframe.
Definition Stage.cpp:104