Merge branch 'master' of ssh://github.com/cthunter01/qtrocket
This commit is contained in:
commit
4fc92cfb64
@ -80,7 +80,7 @@ void MainWindow::on_testButton2_clicked()
|
||||
double initialVelocityX = initialVelocity * std::cos(initialAngle / 57.2958);
|
||||
double initialVelocityZ = initialVelocity * std::sin(initialAngle / 57.2958);
|
||||
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.setMass(mass);
|
||||
rocket.setDragCoefficient(dragCoeff);
|
||||
|
@ -105,42 +105,17 @@
|
||||
<x>260</x>
|
||||
<y>80</y>
|
||||
<width>161</width>
|
||||
<height>120</height>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<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">
|
||||
<widget class="QLineEdit" name="initialAngle">
|
||||
<property name="text">
|
||||
<string>90.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>mass</string>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -158,6 +133,20 @@
|
||||
</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="0" column="1">
|
||||
<widget class="QLineEdit" name="initialVelocity">
|
||||
<property name="text">
|
||||
<string>50.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="dragCoeff">
|
||||
<property name="text">
|
||||
@ -165,6 +154,34 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
|
@ -27,14 +27,21 @@ Propagator::Propagator(Rocket* r)
|
||||
// template types, and it derives from DESolver, so we can just reset the unique_ptr
|
||||
// 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(
|
||||
/* dx/dt */ [](double, const std::vector<double>& s) -> double {return s[3]; },
|
||||
/* dy/dt */ [](double, const std::vector<double>& s) -> double {return s[4]; },
|
||||
/* dz/dt */ [](double, const std::vector<double>& s) -> double {return s[5]; },
|
||||
/* dvx/dt */ [this](double, const std::vector<double>& ) -> double { return getForceX() / 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);
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
void setSaveStats(bool s) { saveStates = s; }
|
||||
|
||||
private:
|
||||
double getMass();
|
||||
double getForceX();
|
||||
double getForceY();
|
||||
double getForceZ();
|
||||
@ -56,7 +57,9 @@ private:
|
||||
double getTorqueQ();
|
||||
double getTorqueR();
|
||||
|
||||
double getMass();
|
||||
double getIpitch() { return 1.0; }
|
||||
double getIyaw() { return 1.0; }
|
||||
double getIroll() { return 1.0; }
|
||||
|
||||
//private:
|
||||
|
||||
@ -65,8 +68,8 @@ private:
|
||||
Rocket* rocket;
|
||||
QtRocket* qtrocket;
|
||||
|
||||
std::vector<double> currentState{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> 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, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||
bool saveStates{true};
|
||||
double currentTime{0.0};
|
||||
double timeStep{0.01};
|
||||
|
Loading…
x
Reference in New Issue
Block a user