Skip to content
Open
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
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ jobs:
ls cspice/include
ls cspice/generic_kernels
ls nrlmsise00
ls nrlmsise00/table
ls nrlmsise00/lib*
ls nrlmsise00/lib*/libnrlmsise00.lib
ls nrlmsise00/src
Expand Down Expand Up @@ -173,7 +172,6 @@ jobs:
ls cspice/include
ls cspice/generic_kernels
ls nrlmsise00
ls nrlmsise00/table
ls nrlmsise00/lib*
ls nrlmsise00/lib*/libnrlmsise00.a
ls nrlmsise00/src
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CMakeBuilds/
.vscode/

# Log files
data/logs/
**/logs/

# ExtLibraries
ExtLibraries/
Expand All @@ -31,3 +31,9 @@ build/
# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Setting files
settings/environment/cspice
settings/environment/space_weather
settings/environment/gravity_field
settings/environment/star_catalogue
28 changes: 16 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ cmake_minimum_required(VERSION 3.13)
project(S2E_USER_EXAMPLE
LANGUAGES CXX
DESCRIPTION "s2e-user-example: An example of S2E user side repository"
VERSION 0.0.0
VERSION 1.0.0
)

# build config
option(USE_HILS "Use HILS" OFF)
option(USE_C2A "Use C2A" OFF)
option(BUILD_64BIT "Build 64bit" OFF)
option(GOOGLE_TEST "Execute GoogleTest" OFF)

# Mac user setting
option(APPLE_SILICON "Build with Apple Silicon" OFF)
Expand Down Expand Up @@ -43,8 +42,8 @@ if(NOT DEFINED C2A_NAME)
endif()

## Directory path for ini files
if(NOT DEFINED INI_FILE_DIR_FROM_EXE)
set(INI_FILE_DIR_FROM_EXE ../../data/initialize_files)
if(NOT DEFINED SETTINGS_DIR_FROM_EXE)
set(SETTINGS_DIR_FROM_EXE ../../settings)
endif()

if(NOT DEFINED EXT_LIB_DIR_FROM_EXE)
Expand Down Expand Up @@ -90,8 +89,12 @@ 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/logger s2e_core/logger)
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/simulation s2e_core/simulation)
add_subdirectory(${S2E_CORE_DIR}/src/utilities s2e_core/utilities)
add_subdirectory(${S2E_CORE_DIR}/ExtLibraries/inih)

# Add all cpp files as SOURCE_FILES
file(GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)
Expand Down Expand Up @@ -178,13 +181,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)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion s2e-core
Submodule s2e-core updated 454 files
Empty file.
Empty file.
65,338 changes: 65,338 additions & 0 deletions settings/environment/gravity_field/egm96_to360.ascii

Large diffs are not rendered by default.

721,801 changes: 721,801 additions & 0 deletions settings/environment/gravity_field/gggrx_1200a_sha.tab

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions settings/environment/magnetic_field/igrf11.coef

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions settings/environment/magnetic_field/igrf12.coef

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions settings/environment/magnetic_field/igrf13.coef

Large diffs are not rendered by default.

Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
calculation = DISABLE
logging = ENABLE
degree = 4
coefficients_file_path = EXT_LIB_DIR_FROM_EXE/GeoPotential/egm96_to360.ascii
coefficients_file_path = SETTINGS_DIR_FROM_EXE/environment/gravity_field/egm96_to360.ascii

[LUNAR_GRAVITY_FIELD]
// Enable only when the center object is defined as the Moon
calculation = DISABLE
logging = ENABLE
degree = 10
coefficients_file_path = SETTINGS_DIR_FROM_EXE/environment/gravity_field/gggrx_1200a_sha.tab

[MAGNETIC_DISTURBANCE]
// Enable only when the center object is defined as the Earth
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = SETTINGS_DIR_FROM_EXE/environment/magnetic_field/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
Expand All @@ -12,14 +12,20 @@ calculation = ENABLE
logging = ENABLE


[EARTH_ALBEDO]
calculation = DISABLE
// Earth albedo factor: Percentage of sunlight reflected off the Earth surface. Value between 0.0 and 1.0
earth_albedo_factor = 0.3


[ATMOSPHERE]
calculation = ENABLE
logging = ENABLE

// Atmosphere model
// STANDARD: Model using scale height, NRLMSISE00: NRLMSISE00 model
model = STANDARD
nrlmsise00_table_file = EXT_LIB_DIR_FROM_EXE/nrlmsise00/table/SpaceWeather.txt
nrlmsise00_table_file = SETTINGS_DIR_FROM_EXE/environment/space_weather/SpaceWeather-v1.2.txt
// Whether using user-defined f10.7 and ap value
// Ref of f10.7: https://www.swpc.noaa.gov/phenomena/f107-cm-radio-emissions
// Ref of ap: http://wdc.kugi.kyoto-u.ac.jp/kp/kpexp-j.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ logging = ENABLE
// RELATIVE : Relative dynamics (for formation flying simulation)
// KEPLER : Kepler orbit propagation without disturbances and thruster maneuver
// ENCKE : Encke orbit propagation with disturbances and thruster maneuver
// TIME_SERIES_FILE : Orbit propagation with time series file
propagate_mode = RK4

// Orbit initialize mode for RK4, KEPLER, and ENCKE
Expand Down Expand Up @@ -122,16 +123,26 @@ reference_satellite_id = 1
error_tolerance = 0.0001
///////////////////////////////////////////////////////////////////////////////

// Settings for orbit propagation with time series file ///////////
time_series_file_path = SETTINGS_DIR_FROM_EXE/user_satellite/orbit_files/time_series_orbit.csv
number_of_interpolation = 5
// Interpolation method
0: POLYNOMIAL
1: TRIGONOMETRIC
interpolation_method = 0
orbital_period_correction_s = 86659.2 // Only used for trigonometric method. This sample value is used for the gnss satellits (24 * 60 * 60 * 1.003).
///////////////////////////////////////////////////////////////////////////////


[THERMAL]
calculation = DISABLE
debug = 0
thermal_file_directory = INI_FILE_DIR_FROM_EXE/thermal_csv_files/
thermal_file_directory = SETTINGS_DIR_FROM_EXE/user_satellite/thermal_csv_files/

[SETTING_FILES]
local_environment_file = INI_FILE_DIR_FROM_EXE/user_satellite_local_environment.ini
disturbance_file = INI_FILE_DIR_FROM_EXE/user_satellite_disturbance.ini
structure_file = INI_FILE_DIR_FROM_EXE/user_satellite_structure.ini
local_environment_file = SETTINGS_DIR_FROM_EXE/user_satellite/local_environment.ini
disturbance_file = SETTINGS_DIR_FROM_EXE/user_satellite/disturbance.ini
structure_file = SETTINGS_DIR_FROM_EXE/user_satellite/structure.ini


[COMPONENT_FILES]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ rotation_mode(10) = DISABLE

[CSPICE_KERNELS]
// CSPICE Kernel files definition
tls = EXT_LIB_DIR_FROM_EXE/cspice/generic_kernels/lsk/naif0010.tls
tpc1 = EXT_LIB_DIR_FROM_EXE/cspice/generic_kernels/pck/de-403-masses.tpc
tpc2 = EXT_LIB_DIR_FROM_EXE/cspice/generic_kernels/pck/gm_de431.tpc
tpc3 = EXT_LIB_DIR_FROM_EXE/cspice/generic_kernels/pck/pck00010.tpc
bsp = EXT_LIB_DIR_FROM_EXE/cspice/generic_kernels/spk/planets/de430.bsp
tls = SETTINGS_DIR_FROM_EXE/environment/cspice/generic_kernels/lsk/naif0010.tls
tpc1 = SETTINGS_DIR_FROM_EXE/environment/cspice/generic_kernels/pck/de-403-masses.tpc
tpc2 = SETTINGS_DIR_FROM_EXE/environment/cspice/generic_kernels/pck/gm_de431.tpc
tpc3 = SETTINGS_DIR_FROM_EXE/environment/cspice/generic_kernels/pck/pck00010.tpc
bsp = SETTINGS_DIR_FROM_EXE/environment/cspice/generic_kernels/spk/planets/de430.bsp


[HIPPARCOS_CATALOGUE]
catalogue_file_path = EXT_LIB_DIR_FROM_EXE/HipparcosCatalogue/hip_main.csv
catalogue_file_path = SETTINGS_DIR_FROM_EXE/environment/star_catalogue/hip_main.csv
max_magnitude = 3.0 // Max magnitude to read from Hip catalog
calculation = DISABLE
logging = DISABLE
Expand All @@ -140,5 +140,5 @@ save_initialize_files = ENABLE

number_of_simulated_spacecraft = 1
number_of_simulated_ground_station = 0
spacecraft_file(0) = INI_FILE_DIR_FROM_EXE/user_satellite.ini
log_file_save_directory = ../../data/logs/
spacecraft_file(0) = SETTINGS_DIR_FROM_EXE/user_satellite/satellite.ini
log_file_save_directory = ../../logs/
18 changes: 9 additions & 9 deletions src/s2e_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <string>

// Simulator includes
#include "library/logger/logger.hpp"
#include "logger/logger.hpp"

// Add custom include files
#include "./simulation/case/user_case.hpp"
Expand Down Expand Up @@ -43,26 +43,26 @@ int main(int argc, char *argv[])
system_clock::time_point start, end;
start = system_clock::now();

std::string data_path = "../../data/";
std::string ini_path = INI_FILE_DIR_FROM_EXE;
std::string settings_path = "../settings/";
std::string ini_path = SETTINGS_DIR_FROM_EXE;
std::string ini_file = ini_path + "/user_simulation_base.ini";

// Parsing arguments: SatAttSim <data_path> [ini_file]
// Parsing arguments: S2E <settings_path> [ini_file]
if (argc == 0) {
std::cout << "Usage: SatAttSim <data_path> [ini file path]" << std::endl;
std::cout << "Usage: S2E <settings_path> [ini file path]" << std::endl;
return EXIT_FAILURE;
}
if (argc > 1) {
data_path = std::string(argv[1]);
if (data_path.back() != '/') data_path += "/";
settings_path = std::string(argv[1]);
if (settings_path.back() != '/') settings_path += "/";
}
if (argc > 2) {
ini_file = std::string(argv[2]);
}

std::cout << "Starting simulation..." << std::endl;
std::cout << "\tData path: ";
print_path(data_path);
std::cout << "\tSettings path: ";
print_path(settings_path);
std::cout << "\tIni file: ";
print_path(ini_file);

Expand Down
2 changes: 1 addition & 1 deletion src/simulation/case/user_case.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "user_case.hpp"

UserCase::UserCase(const std::string initialise_base_file) : SimulationCase(initialise_base_file) {}
UserCase::UserCase(const std::string initialise_base_file) : s2e::simulation::SimulationCase(initialise_base_file) {}

UserCase::~UserCase() { delete spacecraft_; }

Expand Down
2 changes: 1 addition & 1 deletion src/simulation/case/user_case.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @class UserCase
* @brief An example of user defined simulation case
*/
class UserCase : public SimulationCase {
class UserCase : public s2e::simulation::SimulationCase {
public:
/**
* @fn UserCase
Expand Down
26 changes: 14 additions & 12 deletions src/simulation/spacecraft/user_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

#include "user_components.hpp"

#include <library/initialize/initialize_file_access.hpp>
#include <library/utilities/macros.hpp>

UserComponents::UserComponents(const Dynamics *dynamics, Structure *structure, const LocalEnvironment *local_environment,
const GlobalEnvironment *global_environment, const SimulationConfiguration *configuration,
ClockGenerator *clock_generator, const unsigned int spacecraft_id)
#include <setting_file_reader/initialize_file_access.hpp>
#include <utilities/macros.hpp>

UserComponents::UserComponents(const s2e::dynamics::Dynamics *dynamics, s2e::spacecraft::Structure *structure,
const s2e::environment::LocalEnvironment *local_environment,
const s2e::environment::GlobalEnvironment *global_environment,
const s2e::simulation::SimulationConfiguration *configuration, s2e::environment::ClockGenerator *clock_generator,
const unsigned int spacecraft_id)
: configuration_(configuration),
dynamics_(dynamics),
structure_(structure),
Expand All @@ -25,27 +27,27 @@ UserComponents::UserComponents(const Dynamics *dynamics, Structure *structure, c
UNUSED(global_environment_);

// Component instances
obc_ = new OnBoardComputer(clock_generator);
obc_ = new s2e::components::OnBoardComputer(clock_generator);
}

UserComponents::~UserComponents() {
// OBC must be deleted the last since it has com ports
delete obc_;
}

Vector<3> UserComponents::GenerateForce_b_N() {
s2e::math::Vector<3> UserComponents::GenerateForce_b_N() {
// There is no orbit control component, so it remains 0
Vector<3> force_b_N(0.0);
s2e::math::Vector<3> force_b_N(0.0);
return force_b_N;
}

Vector<3> UserComponents::GenerateTorque_b_Nm() {
s2e::math::Vector<3> UserComponents::GenerateTorque_b_Nm() {
// No attitude control component
Vector<3> torque_b_Nm(0.0);
s2e::math::Vector<3> torque_b_Nm(0.0);
return torque_b_Nm;
}

void UserComponents::LogSetup(Logger &logger) {
void UserComponents::LogSetup(s2e::logger::Logger &logger) {
// Users can set log output when they need component log
UNUSED(logger);
}
28 changes: 14 additions & 14 deletions src/simulation/spacecraft/user_components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@
#include <dynamics/dynamics.hpp>
#include <environment/global/global_environment.hpp>
#include <environment/local/local_environment.hpp>
#include <library/math/vector.hpp>
#include <math_physics/math/vector.hpp>
#include <simulation/spacecraft/installed_components.hpp>

// include for components
#include <components/real/cdh/on_board_computer.hpp>

class UserComponents : public InstalledComponents {
class UserComponents : public s2e::spacecraft::InstalledComponents {
public:
UserComponents(const Dynamics *dynamics, Structure *structure, const LocalEnvironment *local_environment,
const GlobalEnvironment *global_environment, const SimulationConfiguration *configuration, ClockGenerator *clock_generator,
UserComponents(const s2e::dynamics::Dynamics *dynamics, s2e::spacecraft::Structure *structure,
const s2e::environment::LocalEnvironment *local_environment, const s2e::environment::GlobalEnvironment *global_environment,
const s2e::simulation::SimulationConfiguration *configuration, s2e::environment::ClockGenerator *clock_generator,
const unsigned int spacecraft_id);
~UserComponents();
libra::Vector<3> GenerateForce_b_N();
libra::Vector<3> GenerateTorque_b_Nm();
void LogSetup(Logger &logger);
s2e::math::Vector<3> GenerateForce_b_N();
s2e::math::Vector<3> GenerateTorque_b_Nm();
void LogSetup(s2e::logger::Logger &logger);

private:
// Components
OnBoardComputer *obc_; //!< Onboard Computer
s2e::components::OnBoardComputer *obc_; //!< Onboard Computer

// States
const SimulationConfiguration *configuration_; //!< Simulation settings
const Dynamics *dynamics_; //!< Dynamics information of the spacecraft
Structure *structure_; //!< Structure information of the spacecraft
const LocalEnvironment *local_environment_; //!< Local environment information around the spacecraft
const GlobalEnvironment *global_environment_; //!< Global environment information
const s2e::simulation::SimulationConfiguration *configuration_; //!< Simulation settings
const s2e::dynamics::Dynamics *dynamics_; //!< Dynamics information of the spacecraft
s2e::spacecraft::Structure *structure_; //!< Structure information of the spacecraft
const s2e::environment::LocalEnvironment *local_environment_; //!< Local environment information around the spacecraft
const s2e::environment::GlobalEnvironment *global_environment_; //!< Global environment information
};

#endif // S2E_SIMULATION_SPACECRAFT_USER_COMPONENTS_HPP_

6 changes: 3 additions & 3 deletions src/simulation/spacecraft/user_satellite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include "user_components.hpp"

UserSatellite::UserSatellite(const SimulationConfiguration *simulation_configuration, const GlobalEnvironment *global_environment,
const unsigned int spacecraft_id)
: Spacecraft(simulation_configuration, global_environment, spacecraft_id) {
UserSatellite::UserSatellite(const s2e::simulation::SimulationConfiguration *simulation_configuration,
const s2e::environment::GlobalEnvironment *global_environment, const unsigned int spacecraft_id)
: s2e::spacecraft::Spacecraft(simulation_configuration, global_environment, spacecraft_id) {
components_ =
new UserComponents(dynamics_, structure_, local_environment_, global_environment, simulation_configuration, &clock_generator_, spacecraft_id);
}
Loading