Skip to content

Commit

Permalink
rename functions and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMochizuki committed Jan 4, 2024
1 parent 199159d commit 7a5eeba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
22 changes: 9 additions & 13 deletions s2e-ff/src/components/aocs/relative_attitude_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
#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 double standard_deviation_rad)
RelativeAttitudeSensor::RelativeAttitudeSensor(const int prescaler, ClockGenerator* clock_gen, const int target_sat_id, const int reference_sat_id,
const RelativeInformation& rel_info, const double standard_deviation_rad)
: Component(prescaler, clock_gen),
Sensor(sensor_base),
target_sat_id_(target_sat_id),
reference_sat_id_(reference_sat_id),
rel_info_(rel_info),
Expand All @@ -34,9 +33,9 @@ void RelativeAttitudeSensor::MainRoutine(int count) {
libra::Quaternion error_quaternion(random_direction, error_angle_rad);

// Get true value
measured_target_attitude_rb2tb_quaternion_ = rel_info_.GetRelativeAttitudeQuaternion(target_sat_id_, reference_sat_id_);
measured_target_attitude_rb2tb_quaternion_ = error_quaternion * measured_target_attitude_rb2tb_quaternion_;
measured_target_attitude_rb2tb_rad_ = measured_target_attitude_rb2tb_quaternion_.ConvertToEuler();
measured_quaternion_rb2tb_ = rel_info_.GetRelativeAttitudeQuaternion(target_sat_id_, reference_sat_id_);
measured_quaternion_rb2tb_ = error_quaternion * measured_quaternion_rb2tb_;
measured_euler_angle_rb2tb_rad_ = measured_quaternion_rb2tb_.ConvertToEuler();
}

std::string RelativeAttitudeSensor::GetLogHeader() const {
Expand All @@ -45,16 +44,16 @@ std::string RelativeAttitudeSensor::GetLogHeader() const {

const std::string frame_name = std::to_string(reference_sat_id_) + "to" + std::to_string(target_sat_id_);
str_tmp += WriteQuaternion(head + "quaternion", frame_name);
str_tmp += WriteVector(head + "attitude", frame_name, "rad", 3);
str_tmp += WriteVector(head + "euler_angle", frame_name, "rad", 3);

return str_tmp;
}

std::string RelativeAttitudeSensor::GetLogValue() const {
std::string str_tmp = "";

str_tmp += WriteQuaternion(measured_target_attitude_rb2tb_quaternion_);
str_tmp += WriteVector(measured_target_attitude_rb2tb_rad_);
str_tmp += WriteQuaternion(measured_quaternion_rb2tb_);
str_tmp += WriteVector(measured_euler_angle_rb2tb_rad_);

return str_tmp;
}
Expand All @@ -79,10 +78,7 @@ RelativeAttitudeSensor InitializeRelativeAttitudeSensor(ClockGenerator* clock_ge
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,
RelativeAttitudeSensor relative_attitude_sensor(prescaler, clock_gen, target_sat_id, reference_sat_id, rel_info,
error_angle_standard_deviation_rad);

return relative_attitude_sensor;
Expand Down
17 changes: 8 additions & 9 deletions s2e-ff/src/components/aocs/relative_attitude_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@
#define S2E_COMPONENTS_AOCS_RELATIVE_ATTITUDE_SENSOR_HPP_

#include <components/base/component.hpp>
#include <components/base/sensor.hpp>
#include <library/logger/logger.hpp>
#include <simulation/multiple_spacecraft/relative_information.hpp>

/**
* @class RelativeAttitudeSensor
* @brief Relative position sensor
* @brief Relative attitude sensor
*/
class RelativeAttitudeSensor : public Component, public Sensor<3>, public ILoggable {
class RelativeAttitudeSensor : public Component, public ILoggable {
public:
/**
* @fn RelativeAttitudeSensor
* @brief Constructor
*/
RelativeAttitudeSensor(const int prescaler, ClockGenerator* clock_gen, Sensor& sensor_base, const int target_sat_id, const int reference_sat_id,
RelativeAttitudeSensor(const int prescaler, ClockGenerator* clock_gen, const int target_sat_id, const int reference_sat_id,
const RelativeInformation& rel_info, const double standard_deviation_rad);
/**
* @fn ~RelativeAttitudeSensor
Expand Down Expand Up @@ -49,8 +48,8 @@ class RelativeAttitudeSensor : public Component, public Sensor<3>, public ILogga
virtual std::string GetLogValue() const;

// Getter
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_; }
inline libra::Quaternion GetMeasuredQuaternion_rb2tb() const { return measured_quaternion_rb2tb_; }
inline libra::Vector<3> GetMeasuredEulerAngle_rb2tb_rad() const { return measured_euler_angle_rb2tb_rad_; }

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

// Measured value
libra::Quaternion measured_target_attitude_rb2tb_quaternion_ = {0.0, 0.0, 0.0, 1.0}; //!< 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 [rad], 3-2-1 Euler angle (1: roll, 2: pitch, 3: yaw order)
libra::Quaternion measured_quaternion_rb2tb_ = {0.0, 0.0, 0.0, 1.0}; //!< Measured quaternion of target body from reference body
libra::Vector<3> measured_euler_angle_rb2tb_rad_{
0.0}; //!< Measured Euler angle of target body in BODY frame [rad], 3-2-1 Euler angle (1: roll, 2: pitch, 3: yaw order)

// Noises
libra::NormalRand angle_noise_; //!< Normal random for magnitude noise
Expand Down

0 comments on commit 7a5eeba

Please sign in to comment.