Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gnss namespace #657

Merged
merged 6 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dynamics/orbit/encke_orbit_propagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void EnckeOrbitPropagation::Initialize(double current_time_jd, math::Vector<3> r
// reference orbit
reference_position_i_m_ = reference_position_i_m;
reference_velocity_i_m_s_ = reference_velocity_i_m_s;
OrbitalElements oe_ref(gravity_constant_m3_s2_, current_time_jd, reference_position_i_m, reference_velocity_i_m_s);
reference_kepler_orbit = KeplerOrbit(gravity_constant_m3_s2_, oe_ref);
orbit::OrbitalElements oe_ref(gravity_constant_m3_s2_, current_time_jd, reference_position_i_m, reference_velocity_i_m_s);
reference_kepler_orbit = orbit::KeplerOrbit(gravity_constant_m3_s2_, oe_ref);

// difference orbit
difference_position_i_m_.FillUp(0.0);
Expand Down
2 changes: 1 addition & 1 deletion src/dynamics/orbit/encke_orbit_propagation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class EnckeOrbitPropagation : public Orbit, public math::OrdinaryDifferentialEqu
// reference orbit
math::Vector<3> reference_position_i_m_; //!< Reference orbit position in the inertial frame [m]
math::Vector<3> reference_velocity_i_m_s_; //!< Reference orbit velocity in the inertial frame [m/s]
KeplerOrbit reference_kepler_orbit; //!< Reference Kepler orbital element
orbit::KeplerOrbit reference_kepler_orbit; //!< Reference Kepler orbital element

// difference orbit
math::Vector<3> difference_position_i_m_; //!< Difference orbit position in the inertial frame [m]
Expand Down
16 changes: 8 additions & 8 deletions src/dynamics/orbit/initialize_orbit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Orbit* InitOrbit(const CelestialInformation* celestial_information, std::string
// initialize orbit for relative dynamics of formation flying
RelativeOrbit::RelativeOrbitUpdateMethod update_method =
(RelativeOrbit::RelativeOrbitUpdateMethod)(conf.ReadInt(section_, "relative_orbit_update_method"));
RelativeOrbitModel relative_dynamics_model_type = (RelativeOrbitModel)(conf.ReadInt(section_, "relative_dynamics_model_type"));
StmModel stm_model_type = (StmModel)(conf.ReadInt(section_, "stm_model_type"));
orbit::RelativeOrbitModel relative_dynamics_model_type = (orbit::RelativeOrbitModel)(conf.ReadInt(section_, "relative_dynamics_model_type"));
orbit::StmModel stm_model_type = (orbit::StmModel)(conf.ReadInt(section_, "stm_model_type"));

math::Vector<3> init_relative_position_lvlh;
conf.ReadVector<3>(section_, "initial_relative_position_lvlh_m", init_relative_position_lvlh);
Expand All @@ -62,15 +62,15 @@ Orbit* InitOrbit(const CelestialInformation* celestial_information, std::string
init_relative_velocity_lvlh, update_method, relative_dynamics_model_type, stm_model_type, relative_information);
} else if (propagate_mode == "KEPLER") {
// initialize orbit for Kepler propagation
OrbitalElements oe;
orbit::OrbitalElements oe;
// TODO: init_mode_kepler should be removed in the next major update
if (initialize_mode == OrbitInitializeMode::kInertialPositionAndVelocity) {
// initialize with position and velocity
math::Vector<3> init_pos_m;
conf.ReadVector<3>(section_, "initial_position_i_m", init_pos_m);
math::Vector<3> init_vel_m_s;
conf.ReadVector<3>(section_, "initial_velocity_i_m_s", init_vel_m_s);
oe = OrbitalElements(gravity_constant_m3_s2, current_time_jd, init_pos_m, init_vel_m_s);
oe = orbit::OrbitalElements(gravity_constant_m3_s2, current_time_jd, init_pos_m, init_vel_m_s);
} else {
// initialize with orbital elements
double semi_major_axis_m = conf.ReadDouble(section_, "semi_major_axis_m");
Expand All @@ -79,9 +79,9 @@ Orbit* InitOrbit(const CelestialInformation* celestial_information, std::string
double raan_rad = conf.ReadDouble(section_, "raan_rad");
double arg_perigee_rad = conf.ReadDouble(section_, "argument_of_perigee_rad");
double epoch_jday = conf.ReadDouble(section_, "epoch_jday");
oe = OrbitalElements(epoch_jday, semi_major_axis_m, eccentricity, inclination_rad, raan_rad, arg_perigee_rad);
oe = orbit::OrbitalElements(epoch_jday, semi_major_axis_m, eccentricity, inclination_rad, raan_rad, arg_perigee_rad);
}
KeplerOrbit kepler_orbit(gravity_constant_m3_s2, oe);
orbit::KeplerOrbit kepler_orbit(gravity_constant_m3_s2, oe);
orbit = new KeplerOrbitPropagation(celestial_information, current_time_jd, kepler_orbit);
} else if (propagate_mode == "ENCKE") {
// initialize orbit for Encke's method
Expand Down Expand Up @@ -130,8 +130,8 @@ math::Vector<6> InitializePosVel(std::string initialize_file, double current_tim
double raan_rad = conf.ReadDouble(section_, "raan_rad");
double arg_perigee_rad = conf.ReadDouble(section_, "argument_of_perigee_rad");
double epoch_jday = conf.ReadDouble(section_, "epoch_jday");
OrbitalElements oe(epoch_jday, semi_major_axis_m, eccentricity, inclination_rad, raan_rad, arg_perigee_rad);
KeplerOrbit kepler_orbit(gravity_constant_m3_s2, oe);
orbit::OrbitalElements oe(epoch_jday, semi_major_axis_m, eccentricity, inclination_rad, raan_rad, arg_perigee_rad);
orbit::KeplerOrbit kepler_orbit(gravity_constant_m3_s2, oe);

kepler_orbit.CalcOrbit(current_time_jd);
position_i_m = kepler_orbit.GetPosition_i_m();
Expand Down
4 changes: 2 additions & 2 deletions src/dynamics/orbit/kepler_orbit_propagation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @class KeplerOrbitPropagation
* @brief Class to propagate spacecraft orbit with Kepler equation
*/
class KeplerOrbitPropagation : public Orbit, public KeplerOrbit {
class KeplerOrbitPropagation : public Orbit, public orbit::KeplerOrbit {
public:
// Initialize with orbital elements
/**
Expand All @@ -23,7 +23,7 @@ class KeplerOrbitPropagation : public Orbit, public KeplerOrbit {
* @param [in] current_time_jd: Current Julian day [day]
* @param [in] kepler_orbit: Kepler orbit
*/
KeplerOrbitPropagation(const CelestialInformation* celestial_information, const double current_time_jd, KeplerOrbit kepler_orbit);
KeplerOrbitPropagation(const CelestialInformation* celestial_information, const double current_time_jd, orbit::KeplerOrbit kepler_orbit);
/**
* @fn ~KeplerOrbitPropagation
* @brief Destructor
Expand Down
17 changes: 9 additions & 8 deletions src/dynamics/orbit/relative_orbit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

RelativeOrbit::RelativeOrbit(const CelestialInformation* celestial_information, double gravity_constant_m3_s2, double time_step_s,
int reference_spacecraft_id, math::Vector<3> relative_position_lvlh_m, math::Vector<3> relative_velocity_lvlh_m_s,
RelativeOrbitUpdateMethod update_method, RelativeOrbitModel relative_dynamics_model_type, StmModel stm_model_type,
RelativeInformation* relative_information)
RelativeOrbitUpdateMethod update_method, orbit::RelativeOrbitModel relative_dynamics_model_type,
orbit::StmModel stm_model_type, RelativeInformation* relative_information)
: Orbit(celestial_information),
math::OrdinaryDifferentialEquation<6>(time_step_s),
gravity_constant_m3_s2_(gravity_constant_m3_s2),
Expand Down Expand Up @@ -66,12 +66,12 @@ void RelativeOrbit::InitializeState(math::Vector<3> relative_position_lvlh_m, ma
TransformEcefToGeodetic();
}

void RelativeOrbit::CalculateSystemMatrix(RelativeOrbitModel relative_dynamics_model_type, const Orbit* reference_sat_orbit,
void RelativeOrbit::CalculateSystemMatrix(orbit::RelativeOrbitModel relative_dynamics_model_type, const Orbit* reference_sat_orbit,
double gravity_constant_m3_s2) {
switch (relative_dynamics_model_type) {
case RelativeOrbitModel::kHill: {
case orbit::RelativeOrbitModel::kHill: {
double reference_sat_orbit_radius = reference_sat_orbit->GetPosition_i_m().CalcNorm();
system_matrix_ = CalcHillSystemMatrix(reference_sat_orbit_radius, gravity_constant_m3_s2);
system_matrix_ = orbit::CalcHillSystemMatrix(reference_sat_orbit_radius, gravity_constant_m3_s2);
}
default: {
// NOT REACHED
Expand All @@ -80,11 +80,12 @@ void RelativeOrbit::CalculateSystemMatrix(RelativeOrbitModel relative_dynamics_m
}
}

void RelativeOrbit::CalculateStm(StmModel stm_model_type, const Orbit* reference_sat_orbit, double gravity_constant_m3_s2, double elapsed_sec) {
void RelativeOrbit::CalculateStm(orbit::StmModel stm_model_type, const Orbit* reference_sat_orbit, double gravity_constant_m3_s2,
double elapsed_sec) {
switch (stm_model_type) {
case StmModel::kHcw: {
case orbit::StmModel::kHcw: {
double reference_sat_orbit_radius = reference_sat_orbit->GetPosition_i_m().CalcNorm();
stm_ = CalcHcwStm(reference_sat_orbit_radius, gravity_constant_m3_s2, elapsed_sec);
stm_ = orbit::CalcHcwStm(reference_sat_orbit_radius, gravity_constant_m3_s2, elapsed_sec);
}
default: {
// NOT REACHED
Expand Down
14 changes: 7 additions & 7 deletions src/dynamics/orbit/relative_orbit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RelativeOrbit : public Orbit, public math::OrdinaryDifferentialEquation<6>
*/
RelativeOrbit(const CelestialInformation* celestial_information, double gravity_constant_m3_s2, double time_step_s, int reference_spacecraft_id,
math::Vector<3> relative_position_lvlh_m, math::Vector<3> relative_velocity_lvlh_m_s, RelativeOrbitUpdateMethod update_method,
RelativeOrbitModel relative_dynamics_model_type, StmModel stm_model_type, RelativeInformation* relative_information);
orbit::RelativeOrbitModel relative_dynamics_model_type, orbit::StmModel stm_model_type, RelativeInformation* relative_information);
/**
* @fn ~RelativeOrbit
* @brief Destructor
Expand Down Expand Up @@ -80,10 +80,10 @@ class RelativeOrbit : public Orbit, public math::OrdinaryDifferentialEquation<6>
math::Vector<3> relative_position_lvlh_m_; //!< Relative position in the LVLH frame
math::Vector<3> relative_velocity_lvlh_m_s_; //!< Relative velocity in the LVLH frame

RelativeOrbitUpdateMethod update_method_; //!< Update method
RelativeOrbitModel relative_dynamics_model_type_; //!< Relative dynamics model type
StmModel stm_model_type_; //!< State Transition Matrix model type
RelativeInformation* relative_information_; //!< Relative information
RelativeOrbitUpdateMethod update_method_; //!< Update method
orbit::RelativeOrbitModel relative_dynamics_model_type_; //!< Relative dynamics model type
orbit::StmModel stm_model_type_; //!< State Transition Matrix model type
RelativeInformation* relative_information_; //!< Relative information

/**
* @fn InitializeState
Expand All @@ -102,7 +102,7 @@ class RelativeOrbit : public Orbit, public math::OrdinaryDifferentialEquation<6>
* @param [in] reference_sat_orbit: Orbit information of reference satellite
* @param [in] gravity_constant_m3_s2: Gravity constant of the center body [m3/s2]
*/
void CalculateSystemMatrix(RelativeOrbitModel relative_dynamics_model_type, const Orbit* reference_sat_orbit, double gravity_constant_m3_s2);
void CalculateSystemMatrix(orbit::RelativeOrbitModel relative_dynamics_model_type, const Orbit* reference_sat_orbit, double gravity_constant_m3_s2);
/**
* @fn CalculateStm
* @brief Calculate State Transition Matrix
Expand All @@ -111,7 +111,7 @@ class RelativeOrbit : public Orbit, public math::OrdinaryDifferentialEquation<6>
* @param [in] gravity_constant_m3_s2: Gravity constant of the center body [m3/s2]
* @param [in] elapsed_sec: Elapsed time [sec]
*/
void CalculateStm(StmModel stm_model_type, const Orbit* reference_sat_orbit, double gravity_constant_m3_s2, double elapsed_sec);
void CalculateStm(orbit::StmModel stm_model_type, const Orbit* reference_sat_orbit, double gravity_constant_m3_s2, double elapsed_sec);
/**
* @fn PropagateRk4
* @brief Propagate relative orbit with RK4
Expand Down
4 changes: 3 additions & 1 deletion src/environment/global/gnss_satellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "setting_file_reader/initialize_file_access.hpp"
#include "utilities/macros.hpp"

using namespace gnss;

const size_t kNumberOfInterpolation = 9;

void GnssSatellites::Initialize(const std::vector<Sp3FileReader>& sp3_files, const EpochTime start_time) {
Expand All @@ -38,7 +40,7 @@ void GnssSatellites::Initialize(const std::vector<Sp3FileReader>& sp3_files, con
reference_time_ = EpochTime(initial_sp3_file.GetEpochData(reference_interpolation_id_));

// Initialize orbit
orbit_.assign(number_of_calculated_gnss_satellites_, InterpolationOrbit(kNumberOfInterpolation));
orbit_.assign(number_of_calculated_gnss_satellites_, orbit::InterpolationOrbit(kNumberOfInterpolation));

// Initialize clock
std::vector<double> temp;
Expand Down
10 changes: 5 additions & 5 deletions src/environment/global/gnss_satellites.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class GnssSatellites : public ILoggable {
* @param [in] sp3_files: List of SP3 files
* @param [in] start_time: The simulation start time
*/
void Initialize(const std::vector<Sp3FileReader>& sp3_files, const EpochTime start_time);
void Initialize(const std::vector<gnss::Sp3FileReader>& sp3_files, const EpochTime start_time);

/**
* @fn IsCalcEnabled
Expand Down Expand Up @@ -113,15 +113,15 @@ class GnssSatellites : public ILoggable {
private:
bool is_calc_enabled_ = false; //!< Flag to manage the GNSS satellite position calculation

std::vector<Sp3FileReader> sp3_files_; //!< List of SP3 files
std::vector<gnss::Sp3FileReader> sp3_files_; //!< List of SP3 files
size_t number_of_calculated_gnss_satellites_; //!< Number of calculated GNSS satellites
size_t sp3_file_id_; //!< Current SP3 file ID
EpochTime reference_time_; //!< Reference start time of the SP3 handling
size_t reference_interpolation_id_ = 0; //!< Reference epoch ID of the interpolation
EpochTime current_epoch_time_; //!< The last updated time

std::vector<InterpolationOrbit> orbit_; //!< GNSS satellite orbit with interpolation
std::vector<math::Interpolation> clock_; //!< GNSS satellite clock offset with interpolation
std::vector<orbit::InterpolationOrbit> orbit_; //!< GNSS satellite orbit with interpolation
std::vector<math::Interpolation> clock_; //!< GNSS satellite clock offset with interpolation

// References
const EarthRotation& earth_rotation_; //!< Earth rotation
Expand All @@ -133,7 +133,7 @@ class GnssSatellites : public ILoggable {
* @param [in] current_time: Target time
* @return true means no error, false means the time argument is out of range
*/
bool GetCurrentSp3File(Sp3FileReader& current_sp3_file, const EpochTime current_time);
bool GetCurrentSp3File(gnss::Sp3FileReader& current_sp3_file, const EpochTime current_time);

/**
* @fn UpdateInterpolationInformation
Expand Down
4 changes: 4 additions & 0 deletions src/math_physics/gnss/antex_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <iostream>
#include <math_physics/gnss/gnss_satellite_number.hpp>

namespace gnss {

#define ANTEX_LINE_TYPE_POSITION (60)

AntexGridDefinition::AntexGridDefinition(const double zenith_start_angle_deg, const double zenith_end_angle_deg, const double zenith_step_angle_deg,
Expand Down Expand Up @@ -196,3 +198,5 @@ DateTime AntexFileReader::ReadDateTime(std::string line) {
sscanf(line.c_str(), "%zu %2zu %2zu %2zu %2zu %10lf", &year, &month, &day, &hour, &minute, &second);
return DateTime(year, month, day, hour, minute, second);
}

} // namespace gnss
4 changes: 4 additions & 0 deletions src/math_physics/gnss/antex_file_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <string>
#include <vector>

namespace gnss {

/**
* @class AntexGridDefinition
* @brief grid data definition in ANTEX file
Expand Down Expand Up @@ -343,4 +345,6 @@ class AntexFileReader {
DateTime ReadDateTime(std::string line);
};

} // namespace gnss

#endif // S2E_LIBRARY_ANTEX_FILE_READER_HPP_
4 changes: 4 additions & 0 deletions src/math_physics/gnss/bias_sinex_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <fstream>
#include <iostream>

namespace gnss {

bool BiasSinexFileReader::ReadFile(const std::string file_name) {
// File open
std::ifstream bias_sinex_file(file_name);
Expand Down Expand Up @@ -242,3 +244,5 @@ void BiasSolutionData::SetTargetSignal(const std::string signal1, const std::str
target_signal_ = BiasTargetSignal::kError;
}
}

} // namespace gnss
4 changes: 4 additions & 0 deletions src/math_physics/gnss/bias_sinex_file_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <string>
#include <vector>

namespace gnss {

/**
* @enum BiasIdentifier
* @brief Bias Identifier
Expand Down Expand Up @@ -184,4 +186,6 @@ class BiasSinexFileReader {
void ReadBiasSolution(std::ifstream& bias_sinex_file);
};

} // namespace gnss

#endif // S2E_LIBRARY_BIAS_SINEX_FILE_READER_HPP_
4 changes: 4 additions & 0 deletions src/math_physics/gnss/gnss_satellite_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "gnss_satellite_number.hpp"

namespace gnss {

size_t ConvertGnssSatelliteNumberToIndex(const std::string satellite_number) {
switch (satellite_number.front()) {
case 'G':
Expand Down Expand Up @@ -58,3 +60,5 @@ std::string ConvertIndexToGnssSatelliteNumber(const size_t index) {

return output;
}

} // namespace gnss
4 changes: 4 additions & 0 deletions src/math_physics/gnss/gnss_satellite_number.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include <string>

namespace gnss {

// GNSS satellite number definition
// TODO: Move to initialized file?
const size_t kNumberOfGpsSatellite = 32; //!< Number of GPS satellites
Expand Down Expand Up @@ -44,4 +46,6 @@ size_t ConvertGnssSatelliteNumberToIndex(const std::string satellite_number);
*/
std::string ConvertIndexToGnssSatelliteNumber(const size_t index);

} // namespace gnss

#endif // S2E_LIBRARY_GNSS_GNSS_SATELLITE_NUMBER_HPP_
4 changes: 4 additions & 0 deletions src/math_physics/gnss/igs_product_name_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include <string>

namespace gnss {

/**
* @fn GetOrbitClockFileName
* @brief Return IGS orbit and clock final product file name
Expand Down Expand Up @@ -83,4 +85,6 @@ size_t IncrementYearDoy(const size_t year_doy) {
return output;
}

} // namespace gnss

#endif // S2E_LIBRARY_GNSS_IGS_PRODUCT_NAME_HANDLING_HPP_
4 changes: 4 additions & 0 deletions src/math_physics/gnss/sp3_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <fstream>
#include <iostream>

namespace gnss {

Sp3FileReader::Sp3FileReader(const std::string file_name) { ReadFile(file_name); }

DateTime Sp3FileReader::GetEpochData(const size_t epoch_id) const {
Expand Down Expand Up @@ -419,3 +421,5 @@ Sp3VelocityClockRateCorrelation Sp3FileReader::DecodeVelocityClockRateCorrelatio

return correlation;
}

} // namespace gnss
4 changes: 4 additions & 0 deletions src/math_physics/gnss/sp3_file_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <string>
#include <vector>

namespace gnss {

#define SP3_BAD_CLOCK_VALUE (999999.999999)
#define SP3_BAD_POSITION_VALUE (0.000000)

Expand Down Expand Up @@ -234,4 +236,6 @@ class Sp3FileReader {
Sp3VelocityClockRateCorrelation DecodeVelocityClockRateCorrelation(std::string line);
};

} // namespace gnss

#endif // S2E_LIBRARY_GNSS_SP3_FILE_READER_HPP_
2 changes: 2 additions & 0 deletions src/math_physics/gnss/test_antex_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "antex_file_reader.hpp"

using namespace gnss;

/**
* @brief Test Constructor
*/
Expand Down
2 changes: 2 additions & 0 deletions src/math_physics/gnss/test_bias_sinex_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "bias_sinex_file_reader.hpp"

using namespace gnss;

TEST(BiasSinex, Constructor) {
// File read error check
BiasSinexFileReader bias_sinex_file_fault("false_file_path.BSX");
Expand Down
2 changes: 2 additions & 0 deletions src/math_physics/gnss/test_gnss_satellite_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "gnss_satellite_number.hpp"

using namespace gnss;

/**
* @brief Test satellite number to index
*/
Expand Down
Loading
Loading