QtRocket
 
Loading...
Searching...
No Matches
Motor.h
Go to the documentation of this file.
1#ifndef MOTOR_H
2#define MOTOR_H
3
4#include <string>
5#include <vector>
6#include <utility> // for std::pair
7
14class Motor {
15public:
22 Motor(const std::string& name, double initialPropellantMass, double totalImpulse);
23
27 ~Motor() = default;
28
37 void addThrustDataPoint(double time, double thrust);
38
42 void ignite();
43
48 void update(double deltaTime);
49
54 double getCurrentThrust() const;
55
60 bool isBurnedOut() const;
61
66 double getRemainingPropellantMass() const;
67
72 const std::string& getName() const;
73
74private:
75 std::string name_;
76
79
81
82 std::vector<std::pair<double, double>> thrustCurve_;
83
85 bool ignited_;
87
89
95 double interpolateThrust(double time) const;
96};
97
98#endif // MOTOR_H
~Motor()=default
Default destructor.
double ignitionTime_
Elapsed time since ignition [s].
Definition Motor.h:84
double getCurrentThrust() const
Gets the current thrust output.
Definition Motor.cpp:56
bool burnedOut_
Whether the motor has finished burning.
Definition Motor.h:86
bool ignited_
Whether the motor has been ignited.
Definition Motor.h:85
bool isBurnedOut() const
Checks whether the motor has burned out.
Definition Motor.cpp:60
const std::string & getName() const
Gets the name of the motor.
Definition Motor.cpp:68
void ignite()
Starts motor ignition (sets internal ignition time to zero).
Definition Motor.cpp:23
double remainingPropellantMass_
Current propellant mass [kg].
Definition Motor.h:78
double currentThrust_
Cached current thrust [N].
Definition Motor.h:88
void addThrustDataPoint(double time, double thrust)
Adds a thrust curve data point.
Definition Motor.cpp:19
double interpolateThrust(double time) const
Linearly interpolates thrust from the thrust curve.
Definition Motor.cpp:74
std::vector< std::pair< double, double > > thrustCurve_
Thrust curve (time, thrust) points.
Definition Motor.h:82
double getRemainingPropellantMass() const
Returns the remaining propellant mass.
Definition Motor.cpp:64
std::string name_
Name of the motor.
Definition Motor.h:75
double initialPropellantMass_
Initial propellant mass [kg].
Definition Motor.h:77
Motor(const std::string &name, double initialPropellantMass, double totalImpulse)
Constructs a new Motor with a given name and mass properties.
Definition Motor.cpp:6
void update(double deltaTime)
Updates the motor status based on elapsed time.
Definition Motor.cpp:29
double totalImpulse_
Total impulse [Ns], used for sanity checks.
Definition Motor.h:80