diff --git a/model/CMakeLists.txt b/model/CMakeLists.txt index bdac965..72df3c1 100644 --- a/model/CMakeLists.txt +++ b/model/CMakeLists.txt @@ -3,6 +3,8 @@ add_library(model MotorModel.h MotorModelDatabase.cpp MotorModelDatabase.h + Part.cpp + Part.h Rocket.cpp Rocket.h ThrustCurve.cpp diff --git a/model/MotorModel.cpp b/model/MotorModel.cpp index 63c393e..a3aecbd 100644 --- a/model/MotorModel.cpp +++ b/model/MotorModel.cpp @@ -60,6 +60,7 @@ double MotorModel::getMass(double simTime) const double propMassEnd = i->second; double slope = (propMassEnd - propMassStart) / (tEnd - tStart); double currentMass = emptyMass + propMassStart + (thrustTime - tStart) * slope; + utils::Logger::getInstance()->info("simTime: " + std::to_string(simTime) + ": motor mass: " + std::to_string(currentMass)); return currentMass; } diff --git a/model/Part.cpp b/model/Part.cpp new file mode 100644 index 0000000..fd3e890 --- /dev/null +++ b/model/Part.cpp @@ -0,0 +1,6 @@ +#include "Part.h" + +namespace model +{ + +} // namespace model \ No newline at end of file diff --git a/model/Part.h b/model/Part.h new file mode 100644 index 0000000..e766fca --- /dev/null +++ b/model/Part.h @@ -0,0 +1,61 @@ +#ifndef MODEL_PART_H +#define MODEL_PART_H + +/// \cond +// C headers +// C++ headers +#include +#include +#include +#include + +// 3rd party headers +/// \endcond + +// qtrocket headers +#include "utils/math/MathTypes.h" + +namespace model +{ + +class Part +{ +public: + Part(); + virtual ~Part(); + + void setMass(double m) { mass = m; } + + // Set the inertia tensor + void setI(const Matrix3& I) { inertiaTensor = I; } + + void setCm(const Vector3& x) { cm = x; } + // Special version of setCM that assumes the cm lies along the body x-axis + void setCm(double x) { cm = {x, 0.0, 0.0}; } + + void setLength(double l) { length = l; } + + void setInnerRadius(double r) { innerRadiusTop = r; innerRadiusBottom = r; } + void setOuterRadius(double r) { outerRadiusTop = r; outerRadiusBottom = r; } +private: + + Matrix3 inertiaTensor; // moment of inertia tensor with respect to the part's center of mass and + // + double mass; // The moment of inertia tensor also has this, so don't double compute + + Vector3 cm; // center of mass wrt middle of component + + double length; + + double innerRadiusTop; + double outerRadiusTop; + + double innerRadiusBottom; + double outerRadiusBottom; + + +}; + +} + +#endif // MODEL_PART_H \ No newline at end of file diff --git a/sim/Propagator.h b/sim/Propagator.h index 2926101..ec7fbe4 100644 --- a/sim/Propagator.h +++ b/sim/Propagator.h @@ -59,12 +59,12 @@ private: double getForceY(); double getForceZ(); - double getTorqueP(); - double getTorqueQ(); - double getTorqueR(); + double getTorqueP(); // yaw + double getTorqueQ(); // pitch + double getTorqueR(); // roll - double getIpitch() { return 1.0; } double getIyaw() { return 1.0; } + double getIpitch() { return 1.0; } double getIroll() { return 1.0; } std::unique_ptr> linearIntegrator; diff --git a/utils/math/MathTypes.h b/utils/math/MathTypes.h index 9cb354c..9eba8a1 100644 --- a/utils/math/MathTypes.h +++ b/utils/math/MathTypes.h @@ -2,6 +2,7 @@ #define UTILS_MATH_MATHTYPES_H #include +#include /// This is not in any namespace. These typedefs are intended to be used throughout QtRocket, /// so keeping them in the global namespace seems to make sense. @@ -20,4 +21,54 @@ using Matrix4 = MyMatrix<4>; using Vector3 = MyVector<3>; using Vector6 = MyVector<6>; +/* +namespace utils +{ + std::vector myVectorToStdVector(const Vector3& x) + { + return std::vector{x.coeff(0), x.coeff(1), x.coeff(2)}; + } + + std::vector myVectorToStdVector(const Vector6& x) + { + return std::vector{x.coeff(0), + x.coeff(1), + x.coeff(2), + x.coeff(3), + x.coeff(4), + x.coeff(5)}; + } +} + +class Vector3 : public MyVector<3> +{ +public: + template + Vector3(Args&&... args) : MyVector<3>(std::forward(args)...) + {} + operator std::vector() + { + return std::vector{this->coeff(0), this->coeff(1), this->coeff(2)}; + } +}; + +class Vector6 : public MyVector<6> +{ +public: + template + Vector6(Args&&... args) : MyVector<6>(std::forward(args)...) + {} + operator std::vector() + { + return std::vector{this->coeff(0), + this->coeff(1), + this->coeff(2), + this->coeff(3), + this->coeff(4), + this->coeff(5)}; + } +}; +*/ + + #endif // UTILS_MATH_MATHTYPES_H \ No newline at end of file