Cleanup
This commit is contained in:
parent
d9cc4e4aec
commit
5da279a8e6
1
.gitignore
vendored
1
.gitignore
vendored
@ -40,4 +40,5 @@ docs/doxygen/*
|
||||
# IDE
|
||||
qtrocket.pro.user
|
||||
.qmake.stash
|
||||
CMakeLists.txt.user
|
||||
|
||||
|
@ -53,6 +53,12 @@ FetchContent_Declare(eigen
|
||||
GIT_TAG 3.4.0)
|
||||
FetchContent_MakeAvailable(eigen)
|
||||
|
||||
# boost dependency
|
||||
FetchContent_Declare(Boost
|
||||
GIT_REPOSITORY https://github.com/boostorg/boost
|
||||
GIT_TAG boost-1.82.0)
|
||||
FetchContent_MakeAvailable(Boost)
|
||||
|
||||
# Add qtrocket subdirectories. These are components that will be linked in
|
||||
|
||||
|
||||
@ -63,7 +69,7 @@ set(CMAKE_AUTORCC ON)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_PREFIX_PATH $ENV{QTDIR})
|
||||
include_directories("C:\\boost\\boost_1_82_0\\")
|
||||
# include_directories("C:\\boost\\boost_1_82_0\\")
|
||||
# find_package(Qt6Core REQUIRED)
|
||||
# find_package(Qt6Widgets REQUIRED)
|
||||
endif()
|
||||
|
17
QtRocket.cpp
17
QtRocket.cpp
@ -1,4 +1,3 @@
|
||||
|
||||
/// \cond
|
||||
// C headers
|
||||
// C++ headers
|
||||
@ -45,7 +44,7 @@ void guiWorker(int argc, char* argv[], int& ret)
|
||||
|
||||
// Go!
|
||||
MainWindow w(QtRocket::getInstance());
|
||||
logger->info("Showing MainWindow");
|
||||
logger->debug("Showing MainWindow");
|
||||
w.show();
|
||||
ret = a.exec();
|
||||
|
||||
@ -65,7 +64,7 @@ void QtRocket::init()
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if(!initialized)
|
||||
{
|
||||
utils::Logger::getInstance()->info("Instantiating new QtRocket");
|
||||
utils::Logger::getInstance()->debug("Instantiating new QtRocket");
|
||||
instance = new QtRocket();
|
||||
initialized = true;
|
||||
}
|
||||
@ -88,6 +87,13 @@ QtRocket::QtRocket()
|
||||
|
||||
motorDatabase = std::make_shared<utils::MotorModelDatabase>();
|
||||
|
||||
logger->debug("Initial states vector size: " + states.capacity() );
|
||||
// Reserve at least 1024 spaces for StateData
|
||||
if(states.capacity() < 1024)
|
||||
{
|
||||
states.reserve(1024);
|
||||
}
|
||||
logger->debug("New states vector size: " + states.capacity() );
|
||||
}
|
||||
|
||||
int QtRocket::run(int argc, char* argv[])
|
||||
@ -122,3 +128,8 @@ void QtRocket::addMotorModels(std::vector<model::MotorModel>& m)
|
||||
motorDatabase->addMotorModels(m);
|
||||
// TODO: Now clear any duplicates?
|
||||
}
|
||||
|
||||
void QtRocket::appendState(const StateData& state)
|
||||
{
|
||||
states.emplace_back(state);
|
||||
}
|
||||
|
14
QtRocket.h
14
QtRocket.h
@ -15,12 +15,11 @@
|
||||
// qtrocket headers
|
||||
#include "model/MotorModel.h"
|
||||
#include "model/Rocket.h"
|
||||
#include "sim/AtmosphericModel.h"
|
||||
#include "sim/GravityModel.h"
|
||||
#include "sim/Environment.h"
|
||||
#include "sim/Propagator.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/MotorModelDatabase.h"
|
||||
#include "utils/math/MathTypes.h"
|
||||
|
||||
/**
|
||||
* @brief The QtRocket class is the master controller for the QtRocket application.
|
||||
@ -67,6 +66,8 @@ public:
|
||||
*/
|
||||
void setInitialState(const StateData& initState) { rocket.second->setInitialState(initState); }
|
||||
|
||||
void appendState(const StateData& state);
|
||||
|
||||
private:
|
||||
QtRocket();
|
||||
|
||||
@ -84,6 +85,15 @@ private:
|
||||
std::shared_ptr<sim::Environment> environment;
|
||||
std::shared_ptr<utils::MotorModelDatabase> motorDatabase;
|
||||
|
||||
// Launch site
|
||||
// ECEF coordinates
|
||||
Vector3 launchSitePosition{0.0, 0.0, 0.0};
|
||||
|
||||
// Table of state data
|
||||
std::vector<StateData> states;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // QTROCKET_H
|
||||
|
7
main.cpp
7
main.cpp
@ -1,11 +1,9 @@
|
||||
|
||||
/// \cond
|
||||
// C headers
|
||||
// C++ headers
|
||||
// 3rd party headers
|
||||
/// \endcond
|
||||
|
||||
|
||||
#include "QtRocket.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
@ -14,12 +12,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Instantiate logger
|
||||
utils::Logger* logger = utils::Logger::getInstance();
|
||||
logger->setLogLevel(utils::Logger::DEBUG_);
|
||||
logger->setLogLevel(utils::Logger::PERF_);
|
||||
logger->info("Logger instantiated at PERF level");
|
||||
// instantiate QtRocket
|
||||
logger->debug("Starting QtRocket");
|
||||
QtRocket* qtrocket = QtRocket::getInstance();
|
||||
|
||||
// Run QtRocket. This'll start the GUI thread and block until the user
|
||||
// exits the program
|
||||
logger->debug("QtRocket->run()");
|
||||
int retVal = qtrocket->run(argc, argv);
|
||||
logger->debug("Returning");
|
||||
return retVal;
|
||||
|
@ -5,7 +5,6 @@
|
||||
// C headers
|
||||
// C++ headers
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
// 3rd party headers
|
||||
@ -13,7 +12,6 @@
|
||||
|
||||
// qtrocket headers
|
||||
#include "utils/math/MathTypes.h"
|
||||
#include "model/Part.h"
|
||||
|
||||
namespace model
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
// qtrocket headers
|
||||
#include "Rocket.h"
|
||||
#include "QtRocket.h"
|
||||
|
||||
namespace model
|
||||
{
|
||||
|
@ -13,9 +13,7 @@
|
||||
/// \endcond
|
||||
|
||||
// qtrocket headers
|
||||
#include "model/ThrustCurve.h"
|
||||
#include "sim/Propagator.h"
|
||||
#include "utils/math/MathTypes.h"
|
||||
|
||||
#include "model/Stage.h"
|
||||
#include "model/Propagatable.h"
|
||||
@ -52,7 +50,7 @@ public:
|
||||
* @param t current simulation time
|
||||
* @return thrust in Newtons
|
||||
*/
|
||||
double getThrust(double t);
|
||||
double getThrust(double t) override;
|
||||
|
||||
/**
|
||||
* @brief getMass returns current rocket
|
||||
|
@ -1,8 +1,6 @@
|
||||
/// \cond
|
||||
// C headers
|
||||
// C++ headers
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
// 3rd party headers
|
||||
/// \endcond
|
||||
|
@ -8,8 +8,6 @@
|
||||
/// \endcond
|
||||
|
||||
#include "model/ThrustCurve.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
|
||||
ThrustCurve::ThrustCurve(std::vector<std::pair<double, double>>& tc)
|
||||
: thrustCurve(tc),
|
||||
|
@ -4,7 +4,6 @@
|
||||
/// \cond
|
||||
// C headers
|
||||
// C++ headers
|
||||
#include <string>
|
||||
|
||||
// 3rd party headers
|
||||
/// \endcond
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
// qtrocket headers
|
||||
#include "AtmosphericModel.h"
|
||||
#include "utils/math/Constants.h"
|
||||
|
||||
namespace sim {
|
||||
|
||||
|
@ -4,13 +4,12 @@
|
||||
/// \cond
|
||||
// C headers
|
||||
// C++ headers
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
// 3rd party headers
|
||||
/// \endcond
|
||||
|
||||
// qtrocket headers
|
||||
#include "utils/math/MathTypes.h"
|
||||
|
||||
namespace sim
|
||||
{
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include "sim/ConstantAtmosphere.h"
|
||||
#include "sim/USStandardAtmosphere.h"
|
||||
#include "sim/GeoidModel.h"
|
||||
|
||||
namespace sim
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
/// \cond
|
||||
// C headers
|
||||
// C++ headers
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
@ -4,10 +4,8 @@
|
||||
/// \cond
|
||||
// C headers
|
||||
// C++ headers
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
// 3rd party headers
|
||||
|
||||
|
@ -18,9 +18,9 @@ namespace sim
|
||||
{
|
||||
|
||||
// Populate static data
|
||||
utils::BinMap initTemps()
|
||||
utils::Bin initTemps()
|
||||
{
|
||||
utils::BinMap map;
|
||||
utils::Bin map;
|
||||
map.insert(std::make_pair(0.0, 288.15));
|
||||
map.insert(std::make_pair(11000.0, 216.65));
|
||||
map.insert(std::make_pair(20000.0, 216.65));
|
||||
@ -33,9 +33,9 @@ utils::BinMap initTemps()
|
||||
|
||||
}
|
||||
|
||||
utils::BinMap initLapseRates()
|
||||
utils::Bin initLapseRates()
|
||||
{
|
||||
utils::BinMap map;
|
||||
utils::Bin map;
|
||||
map.insert(std::make_pair(0.0, 0.0065));
|
||||
map.insert(std::make_pair(11000.0, 0.0));
|
||||
map.insert(std::make_pair(20000.0, -0.001));
|
||||
@ -47,9 +47,9 @@ utils::BinMap initLapseRates()
|
||||
return map;
|
||||
}
|
||||
|
||||
utils::BinMap initDensities()
|
||||
utils::Bin initDensities()
|
||||
{
|
||||
utils::BinMap map;
|
||||
utils::Bin map;
|
||||
map.insert(std::make_pair(0.0, 1.225));
|
||||
map.insert(std::make_pair(11000.0, 0.36391));
|
||||
map.insert(std::make_pair(20000.0, 0.08803));
|
||||
@ -61,9 +61,9 @@ utils::BinMap initDensities()
|
||||
return map;
|
||||
}
|
||||
|
||||
utils::BinMap initPressures()
|
||||
utils::Bin initPressures()
|
||||
{
|
||||
utils::BinMap map;
|
||||
utils::Bin map;
|
||||
map.insert(std::make_pair(0.0, 101325));
|
||||
map.insert(std::make_pair(11000.0, 22632.1));
|
||||
map.insert(std::make_pair(20000.0, 5474.89));
|
||||
@ -75,10 +75,10 @@ utils::BinMap initPressures()
|
||||
return map;
|
||||
}
|
||||
|
||||
utils::BinMap USStandardAtmosphere::temperatureLapseRate(initLapseRates());
|
||||
utils::BinMap USStandardAtmosphere::standardTemperature(initTemps());
|
||||
utils::BinMap USStandardAtmosphere::standardDensity(initDensities());
|
||||
utils::BinMap USStandardAtmosphere::standardPressure(initPressures());
|
||||
utils::Bin USStandardAtmosphere::temperatureLapseRate(initLapseRates());
|
||||
utils::Bin USStandardAtmosphere::standardTemperature(initTemps());
|
||||
utils::Bin USStandardAtmosphere::standardDensity(initDensities());
|
||||
utils::Bin USStandardAtmosphere::standardPressure(initPressures());
|
||||
|
||||
USStandardAtmosphere::USStandardAtmosphere()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
// qtrocket headers
|
||||
#include "sim/AtmosphericModel.h"
|
||||
#include "utils/BinMap.h"
|
||||
#include "utils/Bin.h"
|
||||
|
||||
namespace sim
|
||||
{
|
||||
@ -33,10 +33,10 @@ public:
|
||||
double getDynamicViscosity(double altitude) override;
|
||||
|
||||
private:
|
||||
static utils::BinMap temperatureLapseRate;
|
||||
static utils::BinMap standardTemperature;
|
||||
static utils::BinMap standardDensity;
|
||||
static utils::BinMap standardPressure;
|
||||
static utils::Bin temperatureLapseRate;
|
||||
static utils::Bin standardTemperature;
|
||||
static utils::Bin standardDensity;
|
||||
static utils::Bin standardPressure;
|
||||
|
||||
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
/// \endcond
|
||||
|
||||
// qtrocket headers
|
||||
#include "BinMap.h"
|
||||
#include "Bin.h"
|
||||
|
||||
// TODO: Check on the availability of this in Clang.
|
||||
// Replace libfmt with format when LLVM libc++ supports it
|
||||
@ -20,33 +20,33 @@
|
||||
namespace utils
|
||||
{
|
||||
|
||||
BinMap::BinMap()
|
||||
Bin::Bin()
|
||||
: bins()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BinMap::BinMap(BinMap&& o)
|
||||
Bin::Bin(Bin&& o)
|
||||
: bins(std::move(o.bins))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BinMap::~BinMap()
|
||||
Bin::~Bin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// TODO: Very low priority, but if anyone wants to make this more efficient it could be
|
||||
// interesting
|
||||
void BinMap::insert(const std::pair<double, double>& toInsert)
|
||||
void Bin::insert(const std::pair<double, double>& toInsert)
|
||||
{
|
||||
bins.push_back(toInsert);
|
||||
std::sort(bins.begin(), bins.end(),
|
||||
[](const auto& a, const auto& b){ return a.first < b.first; });
|
||||
}
|
||||
|
||||
double BinMap::operator[](double key)
|
||||
double Bin::operator[](double key)
|
||||
{
|
||||
auto iter = bins.begin();
|
||||
// If the key is less than the lowest bin value, then it is out of range
|
||||
@ -74,7 +74,7 @@ double BinMap::operator[](double key)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
double BinMap::getBinBase(double key)
|
||||
double Bin::getBinBase(double key)
|
||||
{
|
||||
auto iter = bins.begin();
|
||||
// If the key is less than the lowest bin value, then it is out of range
|
@ -1,5 +1,5 @@
|
||||
#ifndef UTILS_BINMAP_H
|
||||
#define UTILS_BINMAP_H
|
||||
#ifndef UTILS_BIN_H
|
||||
#define UTILS_BIN_H
|
||||
|
||||
/// \cond
|
||||
// C headers
|
||||
@ -22,12 +22,12 @@ namespace utils {
|
||||
* @todo Make this class behave more like a proper STL container. Templetize it for one
|
||||
*
|
||||
*/
|
||||
class BinMap
|
||||
class Bin
|
||||
{
|
||||
public:
|
||||
BinMap();
|
||||
BinMap(BinMap&& o);
|
||||
~BinMap();
|
||||
Bin();
|
||||
Bin(Bin&& o);
|
||||
~Bin();
|
||||
|
||||
void insert(const std::pair<double, double>& toInsert);
|
||||
double operator[](double key);
|
||||
@ -40,4 +40,4 @@ private:
|
||||
|
||||
} // namespace utils
|
||||
|
||||
#endif // UTILS_BINMAP_H
|
||||
#endif // UTILS_BIN_H
|
@ -1,6 +1,6 @@
|
||||
add_library(utils
|
||||
BinMap.cpp
|
||||
BinMap.h
|
||||
Bin.cpp
|
||||
Bin.h
|
||||
CurlConnection.cpp
|
||||
CurlConnection.h
|
||||
Logger.cpp
|
||||
@ -18,6 +18,10 @@ add_library(utils
|
||||
math/MathTypes.h
|
||||
math/UtilityMathFunctions.h)
|
||||
|
||||
|
||||
target_include_directories(utils PRIVATE
|
||||
${Boost_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(utils PUBLIC
|
||||
libcurl
|
||||
jsoncpp_static
|
||||
|
@ -40,6 +40,13 @@ void Logger::log(std::string_view msg, const LogLevel& lvl)
|
||||
// all levels at or lower than the current level.
|
||||
switch(currentLevel)
|
||||
{
|
||||
case PERF_:
|
||||
if(lvl == PERF_)
|
||||
{
|
||||
outFile << "[PERF] " << msg << std::endl;
|
||||
std::cout << "[PERF] " << msg << "\n";
|
||||
}
|
||||
[[fallthrough]];
|
||||
case DEBUG_:
|
||||
if(lvl == DEBUG_)
|
||||
{
|
||||
|
@ -25,7 +25,8 @@ public:
|
||||
ERROR_,
|
||||
WARN_,
|
||||
INFO_,
|
||||
DEBUG_
|
||||
DEBUG_,
|
||||
PERF_
|
||||
};
|
||||
|
||||
static Logger* getInstance();
|
||||
@ -38,16 +39,11 @@ public:
|
||||
|
||||
void setLogLevel(const LogLevel& lvl);
|
||||
|
||||
/*
|
||||
std::function<void(std::string_view)> error;
|
||||
std::function<void(std::string_view)> warn;
|
||||
std::function<void(std::string_view)> info;
|
||||
std::function<void(std::string_view)> debug;
|
||||
*/
|
||||
inline void error(std::string_view msg) { log(msg, ERROR_); }
|
||||
inline void warn(std::string_view msg) { log(msg, WARN_); }
|
||||
inline void info(std::string_view msg) { log(msg, INFO_); }
|
||||
inline void debug(std::string_view msg) { log(msg, DEBUG_); }
|
||||
inline void perf(std::string_view msg) { log(msg, PERF_); }
|
||||
|
||||
void log(std::ostream& o, const std::string& msg);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user