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

Represents a rocket motor with thrust characteristics over time. More...

#include <Motor.h>

Public Member Functions

 Motor (const std::string &name, double initialPropellantMass, double totalImpulse)
 Constructs a new Motor with a given name and mass properties.
 
 ~Motor ()=default
 Default destructor.
 
void addThrustDataPoint (double time, double thrust)
 Adds a thrust curve data point.
 
void ignite ()
 Starts motor ignition (sets internal ignition time to zero).
 
void update (double deltaTime)
 Updates the motor status based on elapsed time.
 
double getCurrentThrust () const
 Gets the current thrust output.
 
bool isBurnedOut () const
 Checks whether the motor has burned out.
 
double getRemainingPropellantMass () const
 Returns the remaining propellant mass.
 
const std::string & getName () const
 Gets the name of the motor.
 

Private Member Functions

double interpolateThrust (double time) const
 Linearly interpolates thrust from the thrust curve.
 

Private Attributes

std::string name_
 Name of the motor.
 
double initialPropellantMass_
 Initial propellant mass [kg].
 
double remainingPropellantMass_
 Current propellant mass [kg].
 
double totalImpulse_
 Total impulse [Ns], used for sanity checks.
 
std::vector< std::pair< double, double > > thrustCurve_
 Thrust curve (time, thrust) points.
 
double ignitionTime_
 Elapsed time since ignition [s].
 
bool ignited_
 Whether the motor has been ignited.
 
bool burnedOut_
 Whether the motor has finished burning.
 
double currentThrust_
 Cached current thrust [N].
 

Detailed Description

Represents a rocket motor with thrust characteristics over time.

The Motor class manages the thrust curve, ignition timing, burn duration, and remaining propellant mass of a single propulsion unit.

Constructor & Destructor Documentation

◆ Motor()

Motor::Motor ( const std::string & name,
double initialPropellantMass,
double totalImpulse )

Constructs a new Motor with a given name and mass properties.

Parameters
nameName of the motor.
initialPropellantMassInitial mass of propellant (kg).
totalImpulseTotal impulse (Ns) for basic verification.

◆ ~Motor()

Motor::~Motor ( )
default

Default destructor.

Member Function Documentation

◆ addThrustDataPoint()

void Motor::addThrustDataPoint ( double time,
double thrust )

Adds a thrust curve data point.

Should be called during setup. Time must be monotonically increasing.

Parameters
timeTime since ignition (seconds).
thrustThrust at this time (Newtons).
Here is the caller graph for this function:

◆ getCurrentThrust()

double Motor::getCurrentThrust ( ) const

Gets the current thrust output.

Returns
Current thrust in Newtons.
Here is the caller graph for this function:

◆ getName()

const std::string & Motor::getName ( ) const

Gets the name of the motor.

Returns
Motor name as a constant reference.

◆ getRemainingPropellantMass()

double Motor::getRemainingPropellantMass ( ) const

Returns the remaining propellant mass.

Returns
Remaining propellant mass in kilograms.
Here is the caller graph for this function:

◆ ignite()

void Motor::ignite ( )

Starts motor ignition (sets internal ignition time to zero).

Here is the caller graph for this function:

◆ interpolateThrust()

double Motor::interpolateThrust ( double time) const
private

Linearly interpolates thrust from the thrust curve.

Parameters
timeTime since ignition (seconds).
Returns
Interpolated thrust (Newtons).
Here is the caller graph for this function:

◆ isBurnedOut()

bool Motor::isBurnedOut ( ) const

Checks whether the motor has burned out.

Returns
True if burnout has occurred.
Here is the caller graph for this function:

◆ update()

void Motor::update ( double deltaTime)

Updates the motor status based on elapsed time.

Parameters
deltaTimeTime step in seconds.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ burnedOut_

bool Motor::burnedOut_
private

Whether the motor has finished burning.

◆ currentThrust_

double Motor::currentThrust_
private

Cached current thrust [N].

◆ ignited_

bool Motor::ignited_
private

Whether the motor has been ignited.

◆ ignitionTime_

double Motor::ignitionTime_
private

Elapsed time since ignition [s].

◆ initialPropellantMass_

double Motor::initialPropellantMass_
private

Initial propellant mass [kg].

◆ name_

std::string Motor::name_
private

Name of the motor.

◆ remainingPropellantMass_

double Motor::remainingPropellantMass_
private

Current propellant mass [kg].

◆ thrustCurve_

std::vector<std::pair<double, double> > Motor::thrustCurve_
private

Thrust curve (time, thrust) points.

◆ totalImpulse_

double Motor::totalImpulse_
private

Total impulse [Ns], used for sanity checks.


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