diff --git a/s2e-ff/CMakeLists.txt b/s2e-ff/CMakeLists.txt index a9a4a5ec..3fda80f1 100644 --- a/s2e-ff/CMakeLists.txt +++ b/s2e-ff/CMakeLists.txt @@ -46,12 +46,9 @@ add_subdirectory(${S2E_CORE_DIR}/src/simulation s2e_core/simulation) set(SOURCE_FILES src/s2e_ff.cpp src/components/aocs/relative_distance_sensor.cpp - src/components/aocs/initialize_relative_distance_sensor.cpp src/components/aocs/relative_position_sensor.cpp - src/components/aocs/initialize_relative_position_sensor.cpp src/components/aocs/relative_attitude_sensor.cpp src/components/aocs/relative_velocity_sensor.cpp - src/components/aocs/initialize_relative_velocity_sensor.cpp src/components/aocs/laser_distance_meter.cpp src/components/aocs/laser_emitter.cpp src/components/aocs/qpd_positioning_sensor.cpp diff --git a/s2e-ff/src/components/aocs/initialize_relative_distance_sensor.cpp b/s2e-ff/src/components/aocs/initialize_relative_distance_sensor.cpp deleted file mode 100644 index ada8e57e..00000000 --- a/s2e-ff/src/components/aocs/initialize_relative_distance_sensor.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file initialize_relative_distance_sensor.cpp - * @brief Relative distance sensor - */ - -#include "initialize_relative_distance_sensor.hpp" - -#include -#include - -RelativeDistanceSensor InitializeRelativeDistanceSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, - const RelativeInformation& rel_info, const int reference_sat_id_input) { - // General - IniAccess ini_file(file_name); - char section[30] = "RELATIVE_DISTANCE_SENSOR"; - - // RelativeDistanceSensor - int prescaler = ini_file.ReadInt(section, "prescaler"); - if (prescaler <= 1) prescaler = 1; - - int target_sat_id = ini_file.ReadInt(section, "target_sat_id"); - int reference_sat_id = ini_file.ReadInt(section, "reference_sat_id"); - if (reference_sat_id < 0) { - reference_sat_id = reference_sat_id_input; - } - - // Sensor - Sensor<1> sensor_base = ReadSensorInformation<1>(file_name, compo_step_time_s * (double)(prescaler), section, "m"); - - RelativeDistanceSensor relative_distance_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, rel_info); - - return relative_distance_sensor; -} diff --git a/s2e-ff/src/components/aocs/initialize_relative_distance_sensor.hpp b/s2e-ff/src/components/aocs/initialize_relative_distance_sensor.hpp deleted file mode 100644 index 299d1c98..00000000 --- a/s2e-ff/src/components/aocs/initialize_relative_distance_sensor.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @file initialize_relative_distance_sensor.hpp - * @brief Relative distance sensor - */ - -#ifndef S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_DISTANCE_SENSOR_HPP_ -#define S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_DISTANCE_SENSOR_HPP_ - -#include "relative_distance_sensor.hpp" - -/** - * @fn InitializeRelativeDistanceSensor - * @brief Initialize function - */ -RelativeDistanceSensor InitializeRelativeDistanceSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, - const RelativeInformation& rel_info, const int reference_sat_id_input = -1); - -#endif // S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_DISTANCE_SENSOR_HPP_ diff --git a/s2e-ff/src/components/aocs/initialize_relative_position_sensor.cpp b/s2e-ff/src/components/aocs/initialize_relative_position_sensor.cpp deleted file mode 100644 index aa1c870e..00000000 --- a/s2e-ff/src/components/aocs/initialize_relative_position_sensor.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file initialize_relative_velocity_sensor.cpp - * @brief Initialize function for RelativeVelocitySensor - */ - -#include "initialize_relative_position_sensor.hpp" - -#include -#include - -RelativePositionSensor InitializeRelativePositionSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, - const RelativeInformation& rel_info, const Dynamics& dynamics, - const int reference_sat_id_input) { - // General - IniAccess ini_file(file_name); - char section[30] = "RELATIVE_POSITION_SENSOR"; - - // CompoBase - int prescaler = ini_file.ReadInt(section, "prescaler"); - if (prescaler <= 1) prescaler = 1; - - // RelativePositionSensor - int target_sat_id = ini_file.ReadInt(section, "target_sat_id"); - int reference_sat_id = ini_file.ReadInt(section, "reference_sat_id"); - if (reference_sat_id < 0) { - reference_sat_id = reference_sat_id_input; - } - - std::string error_frame_string = ini_file.ReadString(section, "error_frame"); - RelativePositionSensorErrorFrame error_frame; - - if (error_frame_string == "INERTIAL") { - error_frame = RelativePositionSensorErrorFrame::INERTIAL; - } else if (error_frame_string == "RTN") { - error_frame = RelativePositionSensorErrorFrame::RTN; - } else if (error_frame_string == "BODY") { - error_frame = RelativePositionSensorErrorFrame::BODY; - } else { - std::cerr << "Warnings: InitializeRelativePositionSensor: The error frame setting was failed. It is automatically set as BODY frame." - << std::endl; - error_frame = RelativePositionSensorErrorFrame::BODY; - } - - // SensorBase - Sensor<3> sensor_base = ReadSensorInformation<3>(file_name, compo_step_time_s * (double)(prescaler), section, "m"); - - RelativePositionSensor relative_position_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, error_frame, rel_info, - dynamics); - - return relative_position_sensor; -} diff --git a/s2e-ff/src/components/aocs/initialize_relative_position_sensor.hpp b/s2e-ff/src/components/aocs/initialize_relative_position_sensor.hpp deleted file mode 100644 index 0be56362..00000000 --- a/s2e-ff/src/components/aocs/initialize_relative_position_sensor.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @file initialize_relative_velocity_sensor.hpp - * @brief Initialize function for RelativeVelocitySensor - */ - -#ifndef S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_POSITION_SENSOR_HPP_ -#define S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_POSITION_SENSOR_HPP_ - -#include "relative_position_sensor.hpp" - -/** - * @fn InitializeRelativePositionSensor - * @brief Initialize function - */ -RelativePositionSensor InitializeRelativePositionSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, - const RelativeInformation& rel_info, const Dynamics& dynamics, - const int reference_sat_id_input = -1); - -#endif // S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_POSITION_SENSOR_HPP_ diff --git a/s2e-ff/src/components/aocs/initialize_relative_velocity_sensor.cpp b/s2e-ff/src/components/aocs/initialize_relative_velocity_sensor.cpp deleted file mode 100644 index 9f8c8627..00000000 --- a/s2e-ff/src/components/aocs/initialize_relative_velocity_sensor.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file initialize_relative_velocity_sensor.cpp - * @brief Initialize function for RelativeVelocitySensor - */ - -#include "initialize_relative_velocity_sensor.hpp" - -#include -#include - -RelativeVelocitySensor InitializeRelativeVelocitySensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, - const RelativeInformation& rel_info, const Dynamics& dynamics, - const int reference_sat_id_input) { - // General - IniAccess ini_file(file_name); - char section[30] = "RELATIVE_VELOCITY_SENSOR"; - - int prescaler = ini_file.ReadInt(section, "prescaler"); - if (prescaler <= 1) prescaler = 1; - - // RelativeVelocitySensor - int target_sat_id = ini_file.ReadInt(section, "target_sat_id"); - int reference_sat_id = ini_file.ReadInt(section, "reference_sat_id"); - if (reference_sat_id < 0) { - reference_sat_id = reference_sat_id_input; - } - std::string error_frame_string = ini_file.ReadString(section, "error_frame"); - RelativeVelocitySensorErrorFrame error_frame; - - if (error_frame_string == "INERTIAL") { - error_frame = RelativeVelocitySensorErrorFrame::INERTIAL; - } else if (error_frame_string == "RTN") { - error_frame = RelativeVelocitySensorErrorFrame::RTN; - } else { - std::cerr << "Warnings: InitializeRelativeVelocitySensor: The error frame setting was failed. It is automatically set as RTN frame." << std::endl; - error_frame = RelativeVelocitySensorErrorFrame::RTN; - } - - // SensorBase - Sensor<3> sensor_base = ReadSensorInformation<3>(file_name, compo_step_time_s * (double)(prescaler), section, "m_s"); - - RelativeVelocitySensor relative_velocity_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, error_frame, rel_info, - dynamics); - - return relative_velocity_sensor; -} diff --git a/s2e-ff/src/components/aocs/initialize_relative_velocity_sensor.hpp b/s2e-ff/src/components/aocs/initialize_relative_velocity_sensor.hpp deleted file mode 100644 index 8e07b7be..00000000 --- a/s2e-ff/src/components/aocs/initialize_relative_velocity_sensor.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @file initialize_relative_velocity_sensor.hpp - * @brief Initialize function for RelativeVelocitySensor - */ - -#ifndef S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_VELOCITY_SENSOR_HPP_ -#define S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_VELOCITY_SENSOR_HPP_ - -#include "relative_velocity_sensor.hpp" - -/** - * @fn InitializeRelativeVelocitySensor - * @brief Initialize function - */ -RelativeVelocitySensor InitializeRelativeVelocitySensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, - const RelativeInformation& rel_info, const Dynamics& dynamics, - const int reference_sat_id_input = -1); - -#endif // S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_VELOCITY_SENSOR_HPP_ diff --git a/s2e-ff/src/components/aocs/relative_distance_sensor.cpp b/s2e-ff/src/components/aocs/relative_distance_sensor.cpp index f1e53d28..cdcac459 100644 --- a/s2e-ff/src/components/aocs/relative_distance_sensor.cpp +++ b/s2e-ff/src/components/aocs/relative_distance_sensor.cpp @@ -5,6 +5,9 @@ #include "relative_distance_sensor.hpp" +#include +#include + RelativeDistanceSensor::RelativeDistanceSensor(const int prescaler, ClockGenerator* clock_gen, Sensor& sensor_base, const int target_sat_id, const int reference_sat_id, const RelativeInformation& rel_info) : Component(prescaler, clock_gen), Sensor(sensor_base), target_sat_id_(target_sat_id), reference_sat_id_(reference_sat_id), rel_info_(rel_info) {} @@ -32,3 +35,27 @@ std::string RelativeDistanceSensor::GetLogValue() const { return str_tmp; } + +RelativeDistanceSensor InitializeRelativeDistanceSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, + const RelativeInformation& rel_info, const int reference_sat_id_input) { + // General + IniAccess ini_file(file_name); + char section[30] = "RELATIVE_DISTANCE_SENSOR"; + + // RelativeDistanceSensor + int prescaler = ini_file.ReadInt(section, "prescaler"); + if (prescaler <= 1) prescaler = 1; + + int target_sat_id = ini_file.ReadInt(section, "target_sat_id"); + int reference_sat_id = ini_file.ReadInt(section, "reference_sat_id"); + if (reference_sat_id < 0) { + reference_sat_id = reference_sat_id_input; + } + + // Sensor + Sensor<1> sensor_base = ReadSensorInformation<1>(file_name, compo_step_time_s * (double)(prescaler), section, "m"); + + RelativeDistanceSensor relative_distance_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, rel_info); + + return relative_distance_sensor; +} \ No newline at end of file diff --git a/s2e-ff/src/components/aocs/relative_distance_sensor.hpp b/s2e-ff/src/components/aocs/relative_distance_sensor.hpp index fbbca30e..0aa6bae9 100644 --- a/s2e-ff/src/components/aocs/relative_distance_sensor.hpp +++ b/s2e-ff/src/components/aocs/relative_distance_sensor.hpp @@ -65,4 +65,11 @@ class RelativeDistanceSensor : public Component, public Sensor<1>, public ILogga const RelativeInformation& rel_info_; //!< Relative information }; +/** + * @fn InitializeRelativeDistanceSensor + * @brief Initialize function + */ +RelativeDistanceSensor InitializeRelativeDistanceSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, + const RelativeInformation& rel_info, const int reference_sat_id_input = -1); + #endif // S2E_COMPONENTS_AOCS_RELATIVE_DISTANCE_SENSOR_HPP_ diff --git a/s2e-ff/src/components/aocs/relative_position_sensor.cpp b/s2e-ff/src/components/aocs/relative_position_sensor.cpp index 87eb8fe1..07cdd4ed 100644 --- a/s2e-ff/src/components/aocs/relative_position_sensor.cpp +++ b/s2e-ff/src/components/aocs/relative_position_sensor.cpp @@ -5,6 +5,9 @@ #include "relative_position_sensor.hpp" +#include +#include + RelativePositionSensor::RelativePositionSensor(const int prescaler, ClockGenerator* clock_gen, Sensor& sensor_base, const int target_sat_id, const int reference_sat_id, const RelativePositionSensorErrorFrame error_frame, const RelativeInformation& rel_info, const Dynamics& dynamics) @@ -72,3 +75,45 @@ std::string RelativePositionSensor::GetLogValue() const { return str_tmp; } + +RelativePositionSensor InitializeRelativePositionSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, + const RelativeInformation& rel_info, const Dynamics& dynamics, + const int reference_sat_id_input) { + // General + IniAccess ini_file(file_name); + char section[30] = "RELATIVE_POSITION_SENSOR"; + + // CompoBase + int prescaler = ini_file.ReadInt(section, "prescaler"); + if (prescaler <= 1) prescaler = 1; + + // RelativePositionSensor + int target_sat_id = ini_file.ReadInt(section, "target_sat_id"); + int reference_sat_id = ini_file.ReadInt(section, "reference_sat_id"); + if (reference_sat_id < 0) { + reference_sat_id = reference_sat_id_input; + } + + std::string error_frame_string = ini_file.ReadString(section, "error_frame"); + RelativePositionSensorErrorFrame error_frame; + + if (error_frame_string == "INERTIAL") { + error_frame = RelativePositionSensorErrorFrame::INERTIAL; + } else if (error_frame_string == "RTN") { + error_frame = RelativePositionSensorErrorFrame::RTN; + } else if (error_frame_string == "BODY") { + error_frame = RelativePositionSensorErrorFrame::BODY; + } else { + std::cerr << "Warnings: InitializeRelativePositionSensor: The error frame setting was failed. It is automatically set as BODY frame." + << std::endl; + error_frame = RelativePositionSensorErrorFrame::BODY; + } + + // SensorBase + Sensor<3> sensor_base = ReadSensorInformation<3>(file_name, compo_step_time_s * (double)(prescaler), section, "m"); + + RelativePositionSensor relative_position_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, error_frame, rel_info, + dynamics); + + return relative_position_sensor; +} diff --git a/s2e-ff/src/components/aocs/relative_position_sensor.hpp b/s2e-ff/src/components/aocs/relative_position_sensor.hpp index 2b631f37..c83dacf0 100644 --- a/s2e-ff/src/components/aocs/relative_position_sensor.hpp +++ b/s2e-ff/src/components/aocs/relative_position_sensor.hpp @@ -81,4 +81,12 @@ class RelativePositionSensor : public Component, public Sensor<3>, public ILogga const Dynamics& dynamics_; //!< Dynamics }; +/** + * @fn InitializeRelativePositionSensor + * @brief Initialize function + */ +RelativePositionSensor InitializeRelativePositionSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, + const RelativeInformation& rel_info, const Dynamics& dynamics, + const int reference_sat_id_input = -1); + #endif // S2E_COMPONENTS_AOCS_RELATIVE_POSITION_SENSOR_HPP_ diff --git a/s2e-ff/src/components/aocs/relative_velocity_sensor.cpp b/s2e-ff/src/components/aocs/relative_velocity_sensor.cpp index 79db7584..8faa09d1 100644 --- a/s2e-ff/src/components/aocs/relative_velocity_sensor.cpp +++ b/s2e-ff/src/components/aocs/relative_velocity_sensor.cpp @@ -5,6 +5,9 @@ #include "relative_velocity_sensor.hpp" +#include +#include + RelativeVelocitySensor::RelativeVelocitySensor(const int prescaler, ClockGenerator* clock_gen, Sensor& sensor_base, const int target_sat_id, const int reference_sat_id, const RelativeVelocitySensorErrorFrame error_frame, const RelativeInformation& rel_info, const Dynamics& dynamics) @@ -66,3 +69,40 @@ std::string RelativeVelocitySensor::GetLogValue() const { return str_tmp; } + +RelativeVelocitySensor InitializeRelativeVelocitySensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, + const RelativeInformation& rel_info, const Dynamics& dynamics, + const int reference_sat_id_input) { + // General + IniAccess ini_file(file_name); + char section[30] = "RELATIVE_VELOCITY_SENSOR"; + + int prescaler = ini_file.ReadInt(section, "prescaler"); + if (prescaler <= 1) prescaler = 1; + + // RelativeVelocitySensor + int target_sat_id = ini_file.ReadInt(section, "target_sat_id"); + int reference_sat_id = ini_file.ReadInt(section, "reference_sat_id"); + if (reference_sat_id < 0) { + reference_sat_id = reference_sat_id_input; + } + std::string error_frame_string = ini_file.ReadString(section, "error_frame"); + RelativeVelocitySensorErrorFrame error_frame; + + if (error_frame_string == "INERTIAL") { + error_frame = RelativeVelocitySensorErrorFrame::INERTIAL; + } else if (error_frame_string == "RTN") { + error_frame = RelativeVelocitySensorErrorFrame::RTN; + } else { + std::cerr << "Warnings: InitializeRelativeVelocitySensor: The error frame setting was failed. It is automatically set as RTN frame." << std::endl; + error_frame = RelativeVelocitySensorErrorFrame::RTN; + } + + // SensorBase + Sensor<3> sensor_base = ReadSensorInformation<3>(file_name, compo_step_time_s * (double)(prescaler), section, "m_s"); + + RelativeVelocitySensor relative_velocity_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, error_frame, rel_info, + dynamics); + + return relative_velocity_sensor; +} diff --git a/s2e-ff/src/components/aocs/relative_velocity_sensor.hpp b/s2e-ff/src/components/aocs/relative_velocity_sensor.hpp index a52dd617..9406695a 100644 --- a/s2e-ff/src/components/aocs/relative_velocity_sensor.hpp +++ b/s2e-ff/src/components/aocs/relative_velocity_sensor.hpp @@ -78,4 +78,12 @@ class RelativeVelocitySensor : public Component, public Sensor<3>, public ILogga const Dynamics& dynamics_; //!< Dynamics }; +/** + * @fn InitializeRelativeVelocitySensor + * @brief Initialize function + */ +RelativeVelocitySensor InitializeRelativeVelocitySensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, + const RelativeInformation& rel_info, const Dynamics& dynamics, + const int reference_sat_id_input = -1); + #endif // S2E_COMPONENTS_AOCS_RELATIVE_VELOCITY_SENSOR_HPP_ diff --git a/s2e-ff/src/simulation/spacecraft/ff_components.hpp b/s2e-ff/src/simulation/spacecraft/ff_components.hpp index 4df84f2a..7062990c 100644 --- a/s2e-ff/src/simulation/spacecraft/ff_components.hpp +++ b/s2e-ff/src/simulation/spacecraft/ff_components.hpp @@ -17,12 +17,12 @@ #include #include -#include "../../components/aocs/initialize_relative_distance_sensor.hpp" -#include "../../components/aocs/initialize_relative_position_sensor.hpp" -#include "../../components/aocs/initialize_relative_velocity_sensor.hpp" #include "../../components/aocs/laser_distance_meter.hpp" #include "../../components/aocs/qpd_positioning_sensor.hpp" #include "../../components/aocs/relative_attitude_sensor.hpp" +#include "../../components/aocs/relative_distance_sensor.hpp" +#include "../../components/aocs/relative_position_sensor.hpp" +#include "../../components/aocs/relative_velocity_sensor.hpp" #include "../../components/ideal/initialize_relative_attitude_controller.hpp" /** diff --git a/s2e-ff/src/simulation/spacecraft/ff_components_2.hpp b/s2e-ff/src/simulation/spacecraft/ff_components_2.hpp index 7ca55b9b..2f631637 100644 --- a/s2e-ff/src/simulation/spacecraft/ff_components_2.hpp +++ b/s2e-ff/src/simulation/spacecraft/ff_components_2.hpp @@ -17,10 +17,10 @@ #include #include "../../components/aocs/corner_cube_reflector.hpp" -#include "../../components/aocs/initialize_relative_distance_sensor.hpp" -#include "../../components/aocs/initialize_relative_position_sensor.hpp" #include "../../components/aocs/laser_emitter.hpp" #include "../../components/aocs/relative_attitude_sensor.hpp" +#include "../../components/aocs/relative_distance_sensor.hpp" +#include "../../components/aocs/relative_position_sensor.hpp" #include "../../components/ideal/initialize_relative_attitude_controller.hpp" /**