From b27ed7c76f448aced720a3073ef2500244e9c169 Mon Sep 17 00:00:00 2001 From: Kondo Ekyu <58505068+KondoA9@users.noreply.github.com> Date: Tue, 9 Aug 2022 15:54:40 +0900 Subject: [PATCH 1/6] chore: show error when specification file not found --- src/simulator/SimulatorFactory.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/simulator/SimulatorFactory.cpp b/src/simulator/SimulatorFactory.cpp index ebf39520..7a395267 100644 --- a/src/simulator/SimulatorFactory.cpp +++ b/src/simulator/SimulatorFactory.cpp @@ -19,14 +19,18 @@ namespace SimulatorFactory { namespace _internal { std::string setSpecFile() { - std::cout << "" << std::endl; - std::vector specificationFiles; for (const std::filesystem::directory_entry& x : std::filesystem::directory_iterator(specDirectoryPath)) { specificationFiles.push_back(x.path().filename().string()); } + if (specificationFiles.size() == 0) { + throw std::runtime_error{"Specification file not found in input/spec/."}; + } + + std::cout << "" << std::endl; + for (size_t i = 0; i < specificationFiles.size(); i++) { std::cout << i + 1 << ": " << specificationFiles[i] << std::endl; } From d33a3b3b3b4f21baf0614bd7298c23ae2312db72 Mon Sep 17 00:00:00 2001 From: Kondo Ekyu <58505068+KondoA9@users.noreply.github.com> Date: Tue, 9 Aug 2022 16:06:52 +0900 Subject: [PATCH 2/6] chore(WindModel): add error handling for undefined layers --- src/dynamics/WindModel.cpp | 18 ++++++------------ src/main.cpp | 11 ++++++++--- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/dynamics/WindModel.cpp b/src/dynamics/WindModel.cpp index efbaf790..2d62c72e 100644 --- a/src/dynamics/WindModel.cpp +++ b/src/dynamics/WindModel.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "app/AppSetting.hpp" #include "app/CommandLine.hpp" @@ -171,11 +172,8 @@ double WindModel::getTemperature() { } } - CommandLine::PrintInfo(PrintInfoType::Error, - "Current height is " + std::to_string(m_height) + "m", - "Wind model is not defined above 32000m"); - - exit(1); + throw std::runtime_error{"Current height is " + std::to_string(m_height) + " m. " + + "Wind model is not defined above 32000 m."}; } // Formula from: https://pigeon-poppo.com/standard-atmosphere/#i-4 @@ -191,19 +189,15 @@ double WindModel::getPressure() { } else if (i == 2) { k = pow(216.65 / (m_temperature - Constant::AbsoluteZero), 34.163); } else { - CommandLine::PrintInfo(PrintInfoType::Error, "In WindModel::getPressure()", "Index out of range"); - exit(1); + throw std::runtime_error{"WindModel::getPressure(): Detected unhandled layer."}; } return Atmospehre::Layers[i].basePressure * k; } } - CommandLine::PrintInfo(PrintInfoType::Error, - "Current height is " + std::to_string(m_height) + "m", - "Wind model is not defined above 32000m"); - - exit(1); + throw std::runtime_error{"Current height is " + std::to_string(m_height) + " m. " + + "Wind model is not defined above 32000 m."}; } // Formula from: https://pigeon-poppo.com/standard-atmosphere/#i-5 diff --git a/src/main.cpp b/src/main.cpp index 67f23994..d1fb283a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ // ------------------------------------------------ #include +#include #include #include "app/AppSetting.hpp" @@ -27,13 +28,17 @@ int main(int argc, char* argv[]) { // インスタンスの生成に失敗したかどうか(simulator == nullptrと同値) if (!simulator) { - CommandLine::PrintInfo(PrintInfoType::Error, "Failed to initialize simulator"); + CommandLine::PrintInfo(PrintInfoType::Error, "Failed to initialize simulator."); return 1; } // シミュレーション実行 - if (!simulator->run(option.saveResult && !option.dryRun)) { - CommandLine::PrintInfo(PrintInfoType::Error, "Failed to simulate"); + try { + if (!simulator->run(option.saveResult && !option.dryRun)) { + throw std::runtime_error{"Failed to simulate."}; + } + } catch (const std::exception& e) { + CommandLine::PrintInfo(PrintInfoType::Error, e.what()); return 1; } From b096e54892dd42db42cbcd581f5a64d03416542a Mon Sep 17 00:00:00 2001 From: Kondo Ekyu <58505068+KondoA9@users.noreply.github.com> Date: Tue, 9 Aug 2022 16:11:19 +0900 Subject: [PATCH 3/6] chore(editor): set cmake.debugConfig.console to integratedTerminal --- .vscode/settings.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 96967e90..d08d46ed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,8 +5,11 @@ "files.associations": { ".clang-format": "yaml" }, + "cmake.debugConfig": { + "console": "integratedTerminal" + }, "[cpp]": { "editor.defaultFormatter": "ms-vscode.cpptools", "files.encoding": "utf8bom" - } + }, } From bffb5fcef79a4742f85fa22c92e24edef6cf0283 Mon Sep 17 00:00:00 2001 From: Kondo Ekyu <58505068+KondoA9@users.noreply.github.com> Date: Tue, 9 Aug 2022 16:34:26 +0900 Subject: [PATCH 4/6] fix(Solver): calc max altitude for each body When solve multi rocket, second and after bodies open parachute from the beginning. It causes calculation errors. --- src/rocket/Rocket.hpp | 12 +++++++----- src/solver/Solver.cpp | 11 ++++++----- src/solver/Solver.hpp | 4 ---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/rocket/Rocket.hpp b/src/rocket/Rocket.hpp index c72d04fd..23e035c5 100644 --- a/src/rocket/Rocket.hpp +++ b/src/rocket/Rocket.hpp @@ -30,11 +30,13 @@ struct Body { Vector3D moment_b; // status - double elapsedTime = 0.0; // [s] - size_t parachuteIndex = 0; - bool parachuteOpened = false; - bool waitForOpenPara = false; - bool detectPeak = false; + double elapsedTime = 0.0; // [s] + size_t parachuteIndex = 0; + bool parachuteOpened = false; + bool waitForOpenPara = false; + bool detectPeak = false; + double maxAltitude = 0; // [m] + double maxAltitudeTime = 0; // [s] // calculated Vector3D airSpeed_b; // [m/s] diff --git a/src/solver/Solver.cpp b/src/solver/Solver.cpp index 7422ffe2..d8bd51a7 100644 --- a/src/solver/Solver.cpp +++ b/src/solver/Solver.cpp @@ -127,7 +127,8 @@ void Solver::update() { } void Solver::updateParachute() { - const bool detectpeakConditon = m_maxAltitude > THIS_BODY.pos.z + AppSetting::Simulation::detectPeakThreshold; + const bool detectpeakConditon = + THIS_BODY.maxAltitude > THIS_BODY.pos.z + AppSetting::Simulation::detectPeakThreshold; if (detectpeakConditon && !THIS_BODY.detectPeak) { THIS_BODY.detectPeak = true; @@ -150,7 +151,7 @@ void Solver::updateParachute() { } const bool time_from_detect_peakCondition = - THIS_BODY.elapsedTime - m_detectPeakTime > THIS_BODY_SPEC.parachutes[0].openingTime; + THIS_BODY.elapsedTime - THIS_BODY.maxAltitudeTime > THIS_BODY_SPEC.parachutes[0].openingTime; if (time_from_detect_peak) { if (!THIS_BODY.waitForOpenPara && detectpeakConditon) { @@ -368,9 +369,9 @@ void Solver::organizeResult() { *m_windModel.get(), THIS_BODY_SPEC.engine.isCombusting(THIS_BODY.elapsedTime)); - if (m_maxAltitude < THIS_BODY.pos.z) { - m_maxAltitude = THIS_BODY.pos.z; - m_detectPeakTime = THIS_BODY.elapsedTime; + if (THIS_BODY.maxAltitude < THIS_BODY.pos.z) { + THIS_BODY.maxAltitude = THIS_BODY.pos.z; + THIS_BODY.maxAltitudeTime = THIS_BODY.elapsedTime; } } diff --git a/src/solver/Solver.hpp b/src/solver/Solver.hpp index a6c20bc8..1197ad12 100644 --- a/src/solver/Solver.hpp +++ b/src/solver/Solver.hpp @@ -41,10 +41,6 @@ class Solver { size_t m_currentBodyIndex = 0; // index of the body being solved size_t m_detachCount = 0; - // calc - double m_maxAltitude = 0; - double m_detectPeakTime = 0; - // Simulation size_t m_steps = 0; From 1e386f312b5ad37adbfc217d7cb47399f8ec537c Mon Sep 17 00:00:00 2001 From: Kondo Ekyu <58505068+KondoA9@users.noreply.github.com> Date: Tue, 9 Aug 2022 16:36:08 +0900 Subject: [PATCH 5/6] ci: test multiple rocket parachute --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a416905a..fbd38d42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,10 +97,10 @@ jobs: run: echo "1" "1" "1" "1" | ${{ matrix.config.launch_command }} working-directory: ./application - #- name: "[Test] Multi/Detail/Parachute/0[m]/0[deg]" - # run: echo "1" "2" "2" "0" "0" "1" | ${{ matrix.config.launch_command }} --dry-run - # working-directory: ./application + - name: "[Test] Multi/Detail/Parachute/0[m]/0[deg]" + run: echo "1" "2" "2" "0" "0" "1" | ${{ matrix.config.launch_command }} --dry-run + working-directory: ./application - #- name: "[Test] Multi/Scatter/Parachute" - # run: echo "1" "1" "2" "1" | ${{ matrix.config.launch_command }} --dry-run - # working-directory: ./application + - name: "[Test] Multi/Scatter/Parachute" + run: echo "1" "1" "2" "1" | ${{ matrix.config.launch_command }} --dry-run + working-directory: ./application From 39e9457656892182be7f85e70b12542423a0c7f6 Mon Sep 17 00:00:00 2001 From: Kondo Ekyu <58505068+KondoA9@users.noreply.github.com> Date: Tue, 9 Aug 2022 16:43:55 +0900 Subject: [PATCH 6/6] release: bump version to 1.9.1 --- README.md | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ef385fc6..3aac07f3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Latest Update: 2022/08/09 -Version: 1.9.0 +Version: 1.9.1 [**Download**](https://github.com/FROM-THE-EARTH/Prologue/releases/latest) diff --git a/src/main.cpp b/src/main.cpp index d1fb283a..ef2f5d1e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,7 +11,7 @@ #include "app/Option.hpp" #include "simulator/SimulatorFactory.hpp" -const auto VERSION = "1.9.0"; +const auto VERSION = "1.9.1"; void ShowSettingInfo();