Skip to content

Commit

Permalink
remove initialized_*.cpp files
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMochizuki committed Feb 5, 2024
1 parent ec73cae commit a650f41
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 194 deletions.
3 changes: 0 additions & 3 deletions s2e-ff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 0 additions & 33 deletions s2e-ff/src/components/aocs/initialize_relative_distance_sensor.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions s2e-ff/src/components/aocs/initialize_relative_distance_sensor.hpp

This file was deleted.

51 changes: 0 additions & 51 deletions s2e-ff/src/components/aocs/initialize_relative_position_sensor.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions s2e-ff/src/components/aocs/initialize_relative_position_sensor.hpp

This file was deleted.

46 changes: 0 additions & 46 deletions s2e-ff/src/components/aocs/initialize_relative_velocity_sensor.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions s2e-ff/src/components/aocs/initialize_relative_velocity_sensor.hpp

This file was deleted.

27 changes: 27 additions & 0 deletions s2e-ff/src/components/aocs/relative_distance_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

#include "relative_distance_sensor.hpp"

#include <components/base/sensor.hpp>
#include <library/initialize/initialize_file_access.hpp>

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) {}
Expand Down Expand Up @@ -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;
}
7 changes: 7 additions & 0 deletions s2e-ff/src/components/aocs/relative_distance_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_
45 changes: 45 additions & 0 deletions s2e-ff/src/components/aocs/relative_position_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

#include "relative_position_sensor.hpp"

#include <components/base/sensor.hpp>
#include <library/initialize/initialize_file_access.hpp>

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)
Expand Down Expand Up @@ -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;
}
8 changes: 8 additions & 0 deletions s2e-ff/src/components/aocs/relative_position_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_
40 changes: 40 additions & 0 deletions s2e-ff/src/components/aocs/relative_velocity_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

#include "relative_velocity_sensor.hpp"

#include <components/base/sensor.hpp>
#include <library/initialize/initialize_file_access.hpp>

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)
Expand Down Expand Up @@ -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;
}
8 changes: 8 additions & 0 deletions s2e-ff/src/components/aocs/relative_velocity_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Loading

0 comments on commit a650f41

Please sign in to comment.