Initial 6DoF implementation. The Euler rigid body dynamical equations are present, but there are no torques yet
This commit is contained in:
parent
c319a18bbe
commit
9ca604049e
@ -80,7 +80,7 @@ void MainWindow::on_testButton2_clicked()
|
|||||||
double initialVelocityX = initialVelocity * std::cos(initialAngle / 57.2958);
|
double initialVelocityX = initialVelocity * std::cos(initialAngle / 57.2958);
|
||||||
double initialVelocityZ = initialVelocity * std::sin(initialAngle / 57.2958);
|
double initialVelocityZ = initialVelocity * std::sin(initialAngle / 57.2958);
|
||||||
Rocket rocket;
|
Rocket rocket;
|
||||||
std::vector<double> initialState = {0.0, 0.0, 0.0, initialVelocityX, 0.0, initialVelocityZ};
|
std::vector<double> initialState = {0.0, 0.0, 0.0, initialVelocityX, 0.0, initialVelocityZ, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||||
rocket.setInitialState(initialState);
|
rocket.setInitialState(initialState);
|
||||||
rocket.setMass(mass);
|
rocket.setMass(mass);
|
||||||
rocket.setDragCoefficient(dragCoeff);
|
rocket.setDragCoefficient(dragCoeff);
|
||||||
|
@ -105,42 +105,17 @@
|
|||||||
<x>260</x>
|
<x>260</x>
|
||||||
<y>80</y>
|
<y>80</y>
|
||||||
<width>161</width>
|
<width>161</width>
|
||||||
<height>120</height>
|
<height>151</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Velocity</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="initialVelocity">
|
|
||||||
<property name="text">
|
|
||||||
<string>50.0</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Angle</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="initialAngle">
|
<widget class="QLineEdit" name="initialAngle">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>90.0</string>
|
<string>90.0</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="readOnly">
|
||||||
</item>
|
<bool>true</bool>
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>mass</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -158,6 +133,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Angle</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="initialVelocity">
|
||||||
|
<property name="text">
|
||||||
|
<string>50.0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="dragCoeff">
|
<widget class="QLineEdit" name="dragCoeff">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -165,6 +154,34 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>mass</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Velocity</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLineEdit" name="timeStep">
|
||||||
|
<property name="text">
|
||||||
|
<string>0.01</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Time Step</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -27,14 +27,21 @@ Propagator::Propagator(Rocket* r)
|
|||||||
// template types, and it derives from DESolver, so we can just reset the unique_ptr
|
// template types, and it derives from DESolver, so we can just reset the unique_ptr
|
||||||
// and pass it a freshly allocated RK4Solver pointer
|
// and pass it a freshly allocated RK4Solver pointer
|
||||||
|
|
||||||
// The state vector has components of the form: (x, y, z, xdot, ydot, zdot)
|
// The state vector has components of the form:
|
||||||
|
// (x, y, z, xdot, ydot, zdot, pitch, yaw, roll, pitchRate, yawRate, rollRate)
|
||||||
integrator.reset(new RK4Solver(
|
integrator.reset(new RK4Solver(
|
||||||
/* dx/dt */ [](double, const std::vector<double>& s) -> double {return s[3]; },
|
/* dx/dt */ [](double, const std::vector<double>& s) -> double {return s[3]; },
|
||||||
/* dy/dt */ [](double, const std::vector<double>& s) -> double {return s[4]; },
|
/* dy/dt */ [](double, const std::vector<double>& s) -> double {return s[4]; },
|
||||||
/* dz/dt */ [](double, const std::vector<double>& s) -> double {return s[5]; },
|
/* dz/dt */ [](double, const std::vector<double>& s) -> double {return s[5]; },
|
||||||
/* dvx/dt */ [this](double, const std::vector<double>& ) -> double { return getForceX() / getMass(); },
|
/* dvx/dt */ [this](double, const std::vector<double>& ) -> double { return getForceX() / getMass(); },
|
||||||
/* dvy/dt */ [this](double, const std::vector<double>& ) -> double { return getForceY() / getMass(); },
|
/* dvy/dt */ [this](double, const std::vector<double>& ) -> double { return getForceY() / getMass(); },
|
||||||
/* dvz/dt */ [this](double, const std::vector<double>& ) -> double { return getForceZ() / getMass(); }));
|
/* dvz/dt */ [this](double, const std::vector<double>& ) -> double { return getForceZ() / getMass(); },
|
||||||
|
/* dpitch/dt */ [this](double, const std::vector<double>& s) -> double { return s[9]; },
|
||||||
|
/* dyaw/dt */ [this](double, const std::vector<double>& s) -> double { return s[10]; },
|
||||||
|
/* droll/dt */ [this](double, const std::vector<double>& s) -> double { return s[11]; },
|
||||||
|
/* dpitchRate/dt */ [this](double, const std::vector<double>& s) -> double { (getTorqueP() - s[7] * s[8] * (getIroll() - getIyaw())) / getIpitch(); },
|
||||||
|
/* dyawRate/dt */ [this](double, const std::vector<double>& s) -> double { (getTorqueQ() - s[6] * s[9] * (getIpitch() - getIroll())) / getIyaw(); },
|
||||||
|
/* drollRate/dt */ [this](double, const std::vector<double>& s) -> double { (getTorqueR() - s[6] * s[7] * (getIyaw() - getIpitch())) / getIroll(); }));
|
||||||
|
|
||||||
|
|
||||||
integrator->setTimeStep(timeStep);
|
integrator->setTimeStep(timeStep);
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
void setSaveStats(bool s) { saveStates = s; }
|
void setSaveStats(bool s) { saveStates = s; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
double getMass();
|
||||||
double getForceX();
|
double getForceX();
|
||||||
double getForceY();
|
double getForceY();
|
||||||
double getForceZ();
|
double getForceZ();
|
||||||
@ -56,7 +57,9 @@ private:
|
|||||||
double getTorqueQ();
|
double getTorqueQ();
|
||||||
double getTorqueR();
|
double getTorqueR();
|
||||||
|
|
||||||
double getMass();
|
double getIpitch() { return 1.0; }
|
||||||
|
double getIyaw() { return 1.0; }
|
||||||
|
double getIroll() { return 1.0; }
|
||||||
|
|
||||||
//private:
|
//private:
|
||||||
|
|
||||||
@ -65,8 +68,8 @@ private:
|
|||||||
Rocket* rocket;
|
Rocket* rocket;
|
||||||
QtRocket* qtrocket;
|
QtRocket* qtrocket;
|
||||||
|
|
||||||
std::vector<double> currentState{0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
std::vector<double> currentState{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||||
std::vector<double> tempRes{0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
std::vector<double> tempRes{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||||
bool saveStates{true};
|
bool saveStates{true};
|
||||||
double currentTime{0.0};
|
double currentTime{0.0};
|
||||||
double timeStep{0.01};
|
double timeStep{0.01};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user