diff --git a/CMakeLists.txt b/CMakeLists.txt index abe1594..954cc39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ cmake_minimum_required(VERSION 3.13) # build config option(USE_HILS "Use HILS" OFF) option(USE_C2A "Use C2A" ON) +option(USE_C2A_COMMAND_SENDER "Use command sender to C2A" ON) # preprocessor if(WIN32) @@ -80,7 +81,11 @@ add_subdirectory(${S2E_CORE_DIR}/src/disturbances s2e_core/disturbances) add_subdirectory(${S2E_CORE_DIR}/src/dynamics s2e_core/dynamics) add_subdirectory(${S2E_CORE_DIR}/src/environment/global s2e_core/environment/global) add_subdirectory(${S2E_CORE_DIR}/src/environment/local s2e_core/environment/local) -add_subdirectory(${S2E_CORE_DIR}/src/library s2e_core/library) +add_subdirectory(${S2E_CORE_DIR}/src/math_physics s2e-core/math_physics) +add_subdirectory(${S2E_CORE_DIR}/src/setting_file_reader s2e-core/setting_file_reader) +add_subdirectory(${S2E_CORE_DIR}/src/logger s2e-core/logger) +add_subdirectory(${S2E_CORE_DIR}/src/utilities s2e-core/utilities) +add_subdirectory(${S2E_CORE_DIR}/ExtLibraries/inih s2e-core/inih) add_subdirectory(${S2E_CORE_DIR}/src/simulation s2e_core/simulation) # Add all cpp files as SOURCE_FILES @@ -138,13 +143,14 @@ set(S2E_LIBRARIES IGRF WRAPPER_NRLMSISE00 INIH SGP4 UTIL OPTICS RELATIVE_ORBIT_MODELS ORBIT_MODELS GEODESY MATH ) # Initialize link -target_link_libraries(COMPONENT DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT LIBRARY) -target_link_libraries(DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT SIMULATION LIBRARY) -target_link_libraries(DISTURBANCE DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT LIBRARY) -target_link_libraries(SIMULATION DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT DISTURBANCE LIBRARY) -target_link_libraries(GLOBAL_ENVIRONMENT ${CSPICE_LIB} LIBRARY) -target_link_libraries(LOCAL_ENVIRONMENT GLOBAL_ENVIRONMENT ${CSPICE_LIB} LIBRARY) -target_link_libraries(LIBRARY ${NRLMSISE00_LIB}) +target_link_libraries(COMPONENT DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT MATH_PHYSICS SETTING_FILE_READER LOGGER UTILITIES) +target_link_libraries(DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT SIMULATION MATH_PHYSICS) +target_link_libraries(DISTURBANCE DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT MATH_PHYSICS) +target_link_libraries(SIMULATION DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT DISTURBANCE MATH_PHYSICS) +target_link_libraries(GLOBAL_ENVIRONMENT ${CSPICE_LIB} MATH_PHYSICS) +target_link_libraries(LOCAL_ENVIRONMENT GLOBAL_ENVIRONMENT ${CSPICE_LIB} MATH_PHYSICS) +target_link_libraries(MATH_PHYSICS ${NRLMSISE00_LIB}) +target_link_libraries(SETTING_FILE_READER INIH) target_link_libraries(${PROJECT_NAME} DYNAMICS) target_link_libraries(${PROJECT_NAME} DISTURBANCE) @@ -167,8 +173,6 @@ if(USE_HILS) set_target_properties(SIMULATION PROPERTIES COMMON_LANGUAGE_RUNTIME "") set_target_properties(GLOBAL_ENVIRONMENT PROPERTIES COMMON_LANGUAGE_RUNTIME "") set_target_properties(LOCAL_ENVIRONMENT PROPERTIES COMMON_LANGUAGE_RUNTIME "") - set_target_properties(HILS_IO PROPERTIES COMMON_LANGUAGE_RUNTIME "") - set_target_properties(RELATIVE_INFO PROPERTIES COMMON_LANGUAGE_RUNTIME "") endif() ## Cmake debug diff --git a/data/initialize_files/components/oem7600.ini b/data/initialize_files/components/oem7600.ini index c04e6a7..686ad8f 100644 --- a/data/initialize_files/components/oem7600.ini +++ b/data/initialize_files/components/oem7600.ini @@ -6,37 +6,31 @@ antenna_position_b_m(0) = 0.0125 antenna_position_b_m(1) = 0.0000 antenna_position_b_m(2) = 0.1815 -// Quaternion from body frame to component frame +// Quaternion from body frame to component frame of the antenna +// Note: The antenna boresight direction is +Z direction at the component frame quaternion_b2c(0) = 0.0 quaternion_b2c(1) = 0.0 quaternion_b2c(2) = 0.0 quaternion_b2c(3) = 1.0 // Antenna model -// 0... simple model : GNSS sats are visible when antenna directs anti-earth direction -// 1... cone model : GNSS sats visible when a sat is in a cone -antenna_model = 0 +// SIMPLE: We assume that GNSS satellites are visible when antenna directs anti-earth direction +// CONE: We calculate the number of GNSS satellites in the antenna, +// and the position is observable when more than 4 satellites are in the antenna. +// Note : We need to enable the GNSS satellite calculation when we use this mode. +// All satellites managed in the GnssSatellite class are used in this model. +antenna_model = SIMPLE // Antenna half width [deg] antenna_half_width_deg = 60 -// Number of channels -maximum_channel = 12 - -// GNSS ID -// G...GPS -// R...GLONASS -// E...Galileo -// C...Beidou -// J...QZSS -// if your receiver is compatible with all kind of gnss satellites : GRECJ -// if your receiver is compatible with GPS and QZSS : GJ -gnss_id = GJ - -//Random noise [m] -white_noise_standard_deviation_eci_m(0) = 1.5 -white_noise_standard_deviation_eci_m(1) = 1.5 -white_noise_standard_deviation_eci_m(2) = 1.5 +// Random noise for simple position observation +white_noise_standard_deviation_position_ecef_m(0) = 2000.0 +white_noise_standard_deviation_position_ecef_m(1) = 1000.0 +white_noise_standard_deviation_position_ecef_m(2) = 1500.0 +white_noise_standard_deviation_velocity_ecef_m_s(0) = 1.0 +white_noise_standard_deviation_velocity_ecef_m_s(1) = 1.5 +white_noise_standard_deviation_velocity_ecef_m_s(2) = 2.0 [POWER_PORT] minimum_voltage_V = 3.3 diff --git a/data/initialize_files/local_environment.ini b/data/initialize_files/local_environment.ini index 2a4997c..d8b93c6 100644 --- a/data/initialize_files/local_environment.ini +++ b/data/initialize_files/local_environment.ini @@ -1,7 +1,7 @@ [MAGNETIC_FIELD_ENVIRONMENT] calculation = ENABLE logging = ENABLE -coefficient_file = CORE_DIR_FROM_EXE/src/library/external/igrf/igrf13.coef +coefficient_file = CORE_DIR_FROM_EXE/src/math_physics/geomagnetic/igrf13.coef magnetic_field_random_walk_standard_deviation_nT = 10.0 magnetic_field_random_walk_limit_nT = 400.0 magnetic_field_white_noise_standard_deviation_nT = 50.0 diff --git a/s2e-core b/s2e-core index 6385e16..db02f9f 160000 --- a/s2e-core +++ b/s2e-core @@ -1 +1 @@ -Subproject commit 6385e1625df7be158e04ec9fb0d271eaeec55bd4 +Subproject commit db02f9f3f3eafb0da80e37ae2c00c18f8e0e38d2 diff --git a/src/component/aocs/aobc.cpp b/src/component/aocs/aobc.cpp index 1e7aa8e..908c6cf 100644 --- a/src/component/aocs/aobc.cpp +++ b/src/component/aocs/aobc.cpp @@ -5,7 +5,7 @@ #include "aobc.hpp" -#include +#include #include "../../simulation/spacecraft/aocs_module_components.hpp" diff --git a/src/component/aocs/mpu9250_gyro_sensor.cpp b/src/component/aocs/mpu9250_gyro_sensor.cpp index 66da774..e84583c 100644 --- a/src/component/aocs/mpu9250_gyro_sensor.cpp +++ b/src/component/aocs/mpu9250_gyro_sensor.cpp @@ -5,8 +5,8 @@ #include "mpu9250_gyro_sensor.hpp" -#include -#include +#include +#include Mpu9250GyroSensor::Mpu9250GyroSensor(GyroSensor gyro, const int sils_port_id, const unsigned int hils_port_id, const unsigned char i2c_address, OnBoardComputer *obc, HilsPortManager *hils_port_manager) diff --git a/src/component/aocs/mpu9250_magnetometer.cpp b/src/component/aocs/mpu9250_magnetometer.cpp index 508897a..a09d7b7 100644 --- a/src/component/aocs/mpu9250_magnetometer.cpp +++ b/src/component/aocs/mpu9250_magnetometer.cpp @@ -5,7 +5,7 @@ #include "mpu9250_magnetometer.hpp" -#include +#include Mpu9250Magnetometer::Mpu9250Magnetometer(Magnetometer magnetometer, const int sils_port_id, const unsigned int hils_port_id, const unsigned char i2c_address, OnBoardComputer *obc, HilsPortManager *hils_port_manager, diff --git a/src/component/aocs/mtq_seiren.cpp b/src/component/aocs/mtq_seiren.cpp index ac219f5..df37947 100644 --- a/src/component/aocs/mtq_seiren.cpp +++ b/src/component/aocs/mtq_seiren.cpp @@ -6,7 +6,7 @@ #include "mtq_seiren.hpp" -#include +#include MtqSeiren::MtqSeiren(Magnetorquer magnetorquer, std::vector gpio_ports, OnBoardComputer *obc) : Magnetorquer(magnetorquer), GpioConnectionWithObc(gpio_ports, obc) {} diff --git a/src/component/aocs/nano_ssoc_d60.cpp b/src/component/aocs/nano_ssoc_d60.cpp index 19b42c6..0780d05 100644 --- a/src/component/aocs/nano_ssoc_d60.cpp +++ b/src/component/aocs/nano_ssoc_d60.cpp @@ -9,8 +9,8 @@ #include // for memcpy #include -#include -#include +#include +#include NanoSsocD60::NanoSsocD60(SunSensor sun_sensor, const int sils_port_id, const unsigned int hils_port_id, const unsigned char i2c_address, OnBoardComputer *obc, HilsPortManager *hils_port_manager) diff --git a/src/component/aocs/oem7600.cpp b/src/component/aocs/oem7600.cpp index f2890b1..dacc6d2 100644 --- a/src/component/aocs/oem7600.cpp +++ b/src/component/aocs/oem7600.cpp @@ -6,8 +6,8 @@ #include "oem7600.hpp" #include // toupper -#include #include +#include #define MAX_CMD_LEN 1024 // TBD #define MAX_TLM_LEN 1024 // TBD @@ -66,15 +66,15 @@ void Oem7600::UpdateLocal() { // should be modified to add noise in the future Vector<3> pos_true_ecef_m = dynamics_->GetOrbit().GetPosition_ecef_m(); velocity_ecef_m_s_ = dynamics_->GetOrbit().GetVelocity_ecef_m_s(); - position_llh_ = dynamics_->GetOrbit().GetLatLonAlt(); + geodetic_position_ = dynamics_->GetOrbit().GetGeodeticPosition(); AddNoise(pos_true_eci_m, pos_true_ecef_m); last_position_fix_time_local_ = simulation_time_->GetElapsedTime_s(); // store position fixed time [sec] utc_ = simulation_time_->GetCurrentUtc(); - ConvertJulianDayToGPSTime(simulation_time_->GetCurrentTime_jd()); + ConvertJulianDayToGpsTime(simulation_time_->GetCurrentTime_jd()); } else { utc_ = simulation_time_->GetCurrentUtc(); - ConvertJulianDayToGPSTime(simulation_time_->GetCurrentTime_jd()); + ConvertJulianDayToGpsTime(simulation_time_->GetCurrentTime_jd()); } } @@ -748,10 +748,10 @@ std::string Oem7600::GenerateGpggaTelemetry(void) { str_tmp += StringZeroPaddingLocal(str_utc_tmp, 6); // lat in [ddmm.mm] + indicator "N" or "S" - str_tmp += ConvLatLonToNmea(position_llh_[0], "lat"); + str_tmp += ConvLatLonToNmea(geodetic_position_.GetLatitude_rad(), "lat"); // lon in [dddmm.mm] + indicator "E" or "W" - str_tmp += ConvLatLonToNmea(position_llh_[1], "lon"); + str_tmp += ConvLatLonToNmea(geodetic_position_.GetLongitude_rad(), "lon"); // quality if (is_gnss_visible_) { @@ -767,7 +767,7 @@ std::string Oem7600::GenerateGpggaTelemetry(void) { str_tmp += "1.0,"; // alt in [m] - str_tmp += WriteScalar(position_llh_[2]); + str_tmp += WriteScalar(geodetic_position_.GetAltitude_m()); // units of alt(fix to M in default) str_tmp += "M,"; diff --git a/src/component/aocs/rm3100.cpp b/src/component/aocs/rm3100.cpp index 1400221..6672ca3 100644 --- a/src/component/aocs/rm3100.cpp +++ b/src/component/aocs/rm3100.cpp @@ -5,7 +5,7 @@ #include "rm3100.hpp" -#include +#include Rm3100::Rm3100(Magnetometer magnetometer, const int sils_port_id, const unsigned int hils_port_id, const unsigned char i2c_address, OnBoardComputer *obc, HilsPortManager *hils_port_manager) diff --git a/src/component/aocs/rw0003.cpp b/src/component/aocs/rw0003.cpp index e353167..3a9e865 100644 --- a/src/component/aocs/rw0003.cpp +++ b/src/component/aocs/rw0003.cpp @@ -7,8 +7,8 @@ #include -#include -#include +#include +#include Rw0003::Rw0003(ReactionWheel rw, const int sils_port_id, const unsigned int hils_port_id, const unsigned char i2c_address, OnBoardComputer *obc, HilsPortManager *hils_port_manager) diff --git a/src/component/aocs/sagitta.cpp b/src/component/aocs/sagitta.cpp index 2b4b046..645d8ac 100644 --- a/src/component/aocs/sagitta.cpp +++ b/src/component/aocs/sagitta.cpp @@ -6,7 +6,7 @@ #include "sagitta.hpp" -#include +#include Sagitta::Sagitta(StarSensor stt, const int sils_port_id, OnBoardComputer *obc) : StarSensor(stt), UartCommunicationWithObc(sils_port_id, obc) {} diff --git a/src/component/aocs/stim210.cpp b/src/component/aocs/stim210.cpp index 29ce6bd..5c630f7 100644 --- a/src/component/aocs/stim210.cpp +++ b/src/component/aocs/stim210.cpp @@ -5,7 +5,7 @@ #include "stim210.hpp" -#include +#include Stim210::Stim210(GyroSensor gyro, double compo_step_sec, const int sils_port_id, OnBoardComputer *obc) : GyroSensor(gyro), UartCommunicationWithObc(sils_port_id, obc), counter_(0), compo_step_sec_(compo_step_sec) {} diff --git a/src/component/power/power_controller.cpp b/src/component/power/power_controller.cpp index 3de329e..cffc929 100644 --- a/src/component/power/power_controller.cpp +++ b/src/component/power/power_controller.cpp @@ -5,7 +5,7 @@ #include "power_controller.hpp" -#include +#include #include "../../simulation/spacecraft/aocs_module_port_config.hpp" @@ -45,7 +45,7 @@ void PowerController::MainRoutine(const int time_count) { #ifdef USE_HILS // TODO GPIO操作もHILSでできるようになったら削除する for (int i = 0; i < (int)PowerPortIdx::MAX; i++) { PowerPort *power_port = GetPowerPort(i); - power_port->SetVoltage(output_voltage_list_[i]); + power_port->SetVoltage_V(output_voltage_list_[i]); } return; #else diff --git a/src/interface/hils/hils_if_driver.cpp b/src/interface/hils/hils_if_driver.cpp index 0c83f36..f210f9b 100644 --- a/src/interface/hils/hils_if_driver.cpp +++ b/src/interface/hils/hils_if_driver.cpp @@ -5,7 +5,7 @@ #include "hils_if_driver.hpp" -#include +#include HilsIfDriver::HilsIfDriver(const int prescaler, ClockGenerator *clock_generator, const unsigned int hils_port_id, const unsigned int baud_rate, HilsPortManager *hils_port_manager, std::vector gpio_ports, OnBoardComputer *obc) diff --git a/src/s2e_aobc.cpp b/src/s2e_aobc.cpp index d7db5e6..4f2b420 100644 --- a/src/s2e_aobc.cpp +++ b/src/s2e_aobc.cpp @@ -15,9 +15,9 @@ #include // Simulator includes -#include -#include +#include #include +#include // Add custom include files #include "./simulation/case/sample_case.hpp" diff --git a/src/simulation/spacecraft/aocs_module_components.cpp b/src/simulation/spacecraft/aocs_module_components.cpp index 4616e27..3393682 100644 --- a/src/simulation/spacecraft/aocs_module_components.cpp +++ b/src/simulation/spacecraft/aocs_module_components.cpp @@ -6,7 +6,7 @@ #include "aocs_module_components.hpp" #include -#include +#include #include #include "../../component/aocs/aobc.hpp" diff --git a/src/simulation/spacecraft/aocs_module_components.hpp b/src/simulation/spacecraft/aocs_module_components.hpp index 2de33ed..a28e30f 100644 --- a/src/simulation/spacecraft/aocs_module_components.hpp +++ b/src/simulation/spacecraft/aocs_module_components.hpp @@ -7,7 +7,7 @@ #define S2E_AOBC_SIMULATION_SPACECRAFT_AOCS_MODULE_COMPONENTS_HPP_ #include -#include +#include #include // CDH