Represents a complete rocket vehicle composed of stages, motors, and recovery systems. More...
#include <Rocket.h>
Public Member Functions | |
Rocket (const std::string &name) | |
Constructs a new Rocket with a given name. | |
~Rocket ()=default | |
Default destructor. | |
double | getTotalMass () const |
Returns the total mass of the rocket (including all stages and payloads). | |
double | getTotalPropellantMass () const |
Returns the total remaining propellant mass of all motors. | |
double | getCenterOfGravity () const |
Returns the current center of gravity (CG) of the rocket. | |
double | getCenterOfPressure () const |
Returns the current center of pressure (CP) of the rocket. | |
double | getStabilityMargin () const |
Calculates the rocket's stability margin. | |
void | addStage (std::unique_ptr< Stage > stage) |
Adds a new stage to the rocket. | |
const std::vector< std::unique_ptr< Stage > > & | getStages () const |
Returns a const reference to the list of stages. | |
void | updateMassProperties () |
Recalculates total mass, CG, CP, and stability margin. | |
void | prepareForFlight (const Environment &env) |
Prepares the rocket for flight simulation. | |
void | applyFlightState (const FlightState &state) |
Applies a given flight state to the rocket. | |
const std::string & | getName () const |
Gets the name of the rocket. | |
void | setName (const std::string &name) |
Sets the name of the rocket. | |
Private Attributes | |
std::string | name_ |
Name of the rocket. | |
std::vector< std::unique_ptr< Stage > > | stages_ |
List of rocket stages. | |
double | totalMass_ |
Total mass of the rocket [kg]. | |
double | totalPropellantMass_ |
Total remaining propellant mass [kg]. | |
double | centerOfGravity_ |
Center of gravity location [m]. | |
double | centerOfPressure_ |
Center of pressure location [m]. | |
Represents a complete rocket vehicle composed of stages, motors, and recovery systems.
The Rocket class encapsulates the full vehicle configuration, including mass properties, center of gravity (CG), center of pressure (CP), and stability margin calculations. It is the central object for design, simulation, and flight state management.
Rocket::Rocket | ( | const std::string & | name | ) |
Constructs a new Rocket with a given name.
name | The name of the rocket. |
|
default |
Default destructor.
void Rocket::addStage | ( | std::unique_ptr< Stage > | stage | ) |
Adds a new stage to the rocket.
stage | A unique_ptr to the Stage object to add. |
void Rocket::applyFlightState | ( | const FlightState & | state | ) |
Applies a given flight state to the rocket.
Intended for advanced simulation stages, including 6-DoF dynamics.
state | The current flight state. |
double Rocket::getCenterOfGravity | ( | ) | const |
Returns the current center of gravity (CG) of the rocket.
double Rocket::getCenterOfPressure | ( | ) | const |
Returns the current center of pressure (CP) of the rocket.
const std::string & Rocket::getName | ( | ) | const |
Gets the name of the rocket.
double Rocket::getStabilityMargin | ( | ) | const |
Calculates the rocket's stability margin.
Defined as the normalized distance between CG and CP. Positive margin indicates stable configuration.
const std::vector< std::unique_ptr< Stage > > & Rocket::getStages | ( | ) | const |
Returns a const reference to the list of stages.
double Rocket::getTotalMass | ( | ) | const |
Returns the total mass of the rocket (including all stages and payloads).
double Rocket::getTotalPropellantMass | ( | ) | const |
Returns the total remaining propellant mass of all motors.
void Rocket::prepareForFlight | ( | const Environment & | env | ) |
Prepares the rocket for flight simulation.
Typically called once at simulation setup to adjust for environmental conditions.
env | The environment (atmospheric conditions) at launch. |
void Rocket::setName | ( | const std::string & | name | ) |
Sets the name of the rocket.
name | The new name. |
void Rocket::updateMassProperties | ( | ) |
Recalculates total mass, CG, CP, and stability margin.
Should be called after any modification to the rocket structure.
|
private |
Center of gravity location [m].
|
private |
Center of pressure location [m].
|
private |
Name of the rocket.
|
private |
List of rocket stages.
|
private |
Total mass of the rocket [kg].
|
private |
Total remaining propellant mass [kg].