Skip to content

Commit

Permalink
remove initialize_relative_attitude_sensors.hpp/cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMochizuki committed Jan 1, 2024
1 parent 7a2a4e2 commit 0e20406
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 67 deletions.
1 change: 0 additions & 1 deletion s2e-ff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ set(SOURCE_FILES
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/initialize_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
Expand Down
35 changes: 0 additions & 35 deletions s2e-ff/src/components/aocs/initialize_relative_attitude_sensor.cpp

This file was deleted.

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

This file was deleted.

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

#include "relative_attitude_sensor.hpp"

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

RelativeAttitudeSensor::RelativeAttitudeSensor(const int prescaler, ClockGenerator* clock_gen, Sensor& sensor_base, const int target_sat_id,
const int reference_sat_id, const RelativeInformation& rel_info, const Dynamics& dynamics)
: Component(prescaler, clock_gen),
Expand All @@ -20,10 +23,10 @@ void RelativeAttitudeSensor::MainRoutine(int count) {
UNUSED(count);

// Get true value
measured_target_attitude_b_quaternion_ = rel_info_.GetRelativeAttitudeQuaternion(target_sat_id_, reference_sat_id_);
measured_target_attitude_b_rad_ = measured_target_attitude_b_quaternion_.ConvertToEuler();
measured_target_attitude_b_rad_ = Measure(measured_target_attitude_b_rad_);
measured_target_attitude_b_quaternion_ = libra::Quaternion::ConvertFromEuler(measured_target_attitude_b_rad_);
measured_target_attitude_rb2tb_quaternion_ = rel_info_.GetRelativeAttitudeQuaternion(target_sat_id_, reference_sat_id_);
measured_target_attitude_rb2tb_rad_ = measured_target_attitude_rb2tb_quaternion_.ConvertToEuler();
measured_target_attitude_rb2tb_rad_ = Measure(measured_target_attitude_rb2tb_rad_);
measured_target_attitude_rb2tb_quaternion_ = libra::Quaternion::ConvertFromEuler(measured_target_attitude_rb2tb_rad_);
}

std::string RelativeAttitudeSensor::GetLogHeader() const {
Expand All @@ -40,8 +43,34 @@ std::string RelativeAttitudeSensor::GetLogHeader() const {
std::string RelativeAttitudeSensor::GetLogValue() const {
std::string str_tmp = "";

str_tmp += WriteQuaternion(measured_target_attitude_b_quaternion_);
str_tmp += WriteVector(measured_target_attitude_b_rad_);
str_tmp += WriteQuaternion(measured_target_attitude_rb2tb_quaternion_);
str_tmp += WriteVector(measured_target_attitude_rb2tb_rad_);

return str_tmp;
}

RelativeAttitudeSensor InitializeRelativeAttitudeSensor(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_ATTITUDE_SENSOR";

// CompoBase
int prescaler = ini_file.ReadInt(section, "prescaler");
if (prescaler <= 1) prescaler = 1;

// RelativeAttitudeSensor
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;
}

// SensorBase
Sensor<3> sensor_base = ReadSensorInformation<3>(file_name, compo_step_time_s * (double)(prescaler), section, "rad");

RelativeAttitudeSensor relative_attitude_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, rel_info, dynamics);

return relative_attitude_sensor;
}
12 changes: 8 additions & 4 deletions s2e-ff/src/components/aocs/relative_attitude_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class RelativeAttitudeSensor : public Component, public Sensor<3>, public ILogga
virtual std::string GetLogValue() const;

// Getter
inline libra::Quaternion GetMeasuredTargetQuaternion_b_m() const { return measured_target_attitude_b_quaternion_; }
inline libra::Vector<3> GetMeasuredTargetAttitude_b_m() const { return measured_target_attitude_b_rad_; }
inline libra::Quaternion GetMeasuredTargetQuaternion_rb2tb() const { return measured_target_attitude_rb2tb_quaternion_; }
inline libra::Vector<3> GetMeasuredTargetAttitude_rb2tb_rad() const { return measured_target_attitude_rb2tb_rad_; }

// Setter
void SetTargetSatId(const int target_sat_id) { target_sat_id_ = target_sat_id; }
Expand All @@ -60,12 +60,16 @@ class RelativeAttitudeSensor : public Component, public Sensor<3>, public ILogga
const int reference_sat_id_; //!< Reference satellite ID

// Measured value
libra::Quaternion measured_target_attitude_b_quaternion_;
libra::Vector<3> measured_target_attitude_b_rad_{0.0}; //!< Measured attitude in BODY frame [m]
libra::Quaternion measured_target_attitude_rb2tb_quaternion_; //!< Measured quaternion of target body from reference body
libra::Vector<3> measured_target_attitude_rb2tb_rad_{0.0}; //!< Measured attitude of target body in BODY frame [m]

// References
const RelativeInformation& rel_info_; //!< Relative information
const Dynamics& dynamics_; //!< Dynamics
};

RelativeAttitudeSensor InitializeRelativeAttitudeSensor(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_ATTITUDE_SENSOR_HPP_
2 changes: 1 addition & 1 deletion s2e-ff/src/simulation/spacecraft/ff_components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#include <components/ideal/force_generator.hpp>
#include <components/real/cdh/on_board_computer.hpp>

#include "../../components/aocs/initialize_relative_attitude_sensor.hpp"
#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/relative_attitude_sensor.hpp"
#include "../../components/ideal/initialize_relative_attitude_controller.hpp"

/**
Expand Down
2 changes: 1 addition & 1 deletion s2e-ff/src/simulation/spacecraft/ff_components_2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <components/real/cdh/on_board_computer.hpp>

#include "../../components/aocs/corner_cube_reflector.hpp"
#include "../../components/aocs/initialize_relative_attitude_sensor.hpp"
#include "../../components/aocs/initialize_relative_distance_sensor.hpp"
#include "../../components/aocs/initialize_relative_position_sensor.hpp"
#include "../../components/aocs/relative_attitude_sensor.hpp"
#include "../../components/ideal/initialize_relative_attitude_controller.hpp"

/**
Expand Down

0 comments on commit 0e20406

Please sign in to comment.