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