diff --git a/src/shared/algorithms/ReferenceValues.h b/src/shared/algorithms/ReferenceValues.h index d984dc9faaa8c80ddb99f7528434c5b2f97feb32..fcd4de5df92ae22adb817d1938c8464fdbf89147 100644 --- a/src/shared/algorithms/ReferenceValues.h +++ b/src/shared/algorithms/ReferenceValues.h @@ -24,6 +24,7 @@ #include <utils/Constants.h> +#include <Eigen/Eigen> #include <ostream> namespace Boardcore @@ -39,6 +40,10 @@ struct ReferenceValues float pressure; float temperature; + // Start position + float startLatitude; + float startLongitude; + // Pressure and temperature at mean sea level for altitude calculation float mslPressure = Constants::MSL_PRESSURE; float mslTemperature = Constants::MSL_TEMPERATURE; @@ -46,28 +51,35 @@ struct ReferenceValues ReferenceValues(){}; ReferenceValues(float altitude, float pressure, float temperature, + float startLatitude = Constants::B21_LATITUDE, + float startLongitude = Constants::B21_LONGITUDE, float mslPressure = Constants::MSL_PRESSURE, float mslTemperature = Constants::MSL_TEMPERATURE) : altitude(altitude), pressure(pressure), temperature(temperature), + startLatitude(startLatitude), startLongitude(startLongitude), mslPressure(mslPressure), mslTemperature(mslTemperature) { } static std::string header() { - return "altitude,pressure,temperature,mslPressure,mslTemperature\n"; + return "altitude,pressure,temperature,startLatitude,startLongitude," + "mslPressure,mslTemperature\n"; } void print(std::ostream& os) const { os << altitude << "," << pressure << "," << temperature << "," - << mslPressure << "," << mslTemperature << "\n"; + << startLatitude << "," << startLongitude << "," << mslPressure + << "," << mslTemperature << "\n"; } bool operator==(const ReferenceValues& other) const { return altitude == other.altitude && pressure == other.pressure && temperature == other.temperature && + startLatitude == other.startLatitude && + startLongitude == other.startLongitude && mslPressure == other.mslPressure && mslTemperature == other.mslTemperature; } diff --git a/src/shared/utils/Constants.h b/src/shared/utils/Constants.h index 6f8aaa90e9f80f266c4f26e1910776b1df3bc4ea..ba2aafcde38ed05ac9a2fda8bae8f46148ded2da 100644 --- a/src/shared/utils/Constants.h +++ b/src/shared/utils/Constants.h @@ -28,11 +28,11 @@ namespace Boardcore namespace Constants { -static constexpr const float PI = 3.14159265f; // [rad] -static constexpr const float DEGREES_TO_RADIANS = PI / 180.0f; -static constexpr const float RADIANS_TO_DEGREES = 180.0f / PI; +static constexpr float PI = 3.14159265f; // [rad] +static constexpr float DEGREES_TO_RADIANS = PI / 180.0f; +static constexpr float RADIANS_TO_DEGREES = 180.0f / PI; -static constexpr const float g = 9.80665f; // [m^s^2] +static constexpr float g = 9.80665f; // [m^s^2] static constexpr float a = 0.0065f; // Troposphere temperature gradient [deg/m] static constexpr float R = 287.05f; // Air gas constant [J/Kg/K] @@ -44,8 +44,11 @@ static constexpr float ALPHA = -3.871e-3; // Sound speed gradient [1/s] static constexpr float RHO_0 = 1.225; // Air density at sea level [kg/m^3] static constexpr float Hn = 10400.0; // Scale height [m] -static constexpr const float MSL_PRESSURE = 101325.0f; // [Pa] -static constexpr const float MSL_TEMPERATURE = 288.15f; // [Kelvin] +static constexpr float MSL_PRESSURE = 101325.0f; // [Pa] +static constexpr float MSL_TEMPERATURE = 288.15f; // [Kelvin] + +static constexpr float B21_LATITUDE = 45.501141; +static constexpr float B21_LONGITUDE = 9.156281; } // namespace Constants