generated from ut-issl/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edc0223
commit 7a2a4e2
Showing
10 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
s2e-ff/data/initialize_files/components/relative_attitude_sensor.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[RELATIVE_ATTITUDE_SENSOR] | ||
// Prescaler with respect to the component update period | ||
prescaler = 1 | ||
|
||
// Target satellite ID | ||
target_sat_id = 1 | ||
|
||
// When this value is negative, reference_sat_id is automatically set as the mounting satellite ID | ||
reference_sat_id = -1 | ||
|
||
[SENSOR_BASE_RELATIVE_ATTITUDE_SENSOR] | ||
// The coordinate of the error is selected by the error_frame | ||
// Scale factor [-] | ||
scale_factor_c(0) = 1; | ||
scale_factor_c(1) = 0; | ||
scale_factor_c(2) = 0; | ||
scale_factor_c(3) = 0; | ||
scale_factor_c(4) = 1; | ||
scale_factor_c(5) = 0; | ||
scale_factor_c(6) = 0; | ||
scale_factor_c(7) = 0; | ||
scale_factor_c(8) = 1; | ||
|
||
// Constant bias noise [rad] | ||
constant_bias_c_rad(0) = 0.0 | ||
constant_bias_c_rad(1) = 0.0 | ||
constant_bias_c_rad(2) = 0.0 | ||
|
||
// Standard deviation of normal random noise [rad] | ||
normal_random_standard_deviation_c_rad(0) = 0.0 | ||
normal_random_standard_deviation_c_rad(1) = 0.0 | ||
normal_random_standard_deviation_c_rad(2) = 0.0 | ||
|
||
// Standard deviation for random walk noise [rad] | ||
random_walk_standard_deviation_c_rad(0) = 0.0 | ||
random_walk_standard_deviation_c_rad(1) = 0.0 | ||
random_walk_standard_deviation_c_rad(2) = 0.0 | ||
|
||
// Limit of random walk noise [rad] | ||
random_walk_limit_c_rad(0) = 0.0 | ||
random_walk_limit_c_rad(1) = 0.0 | ||
random_walk_limit_c_rad(2) = 0.0 | ||
|
||
// Range [rad] | ||
range_to_constant_rad = 6.283186 // smaller than range_to_zero_rad | ||
range_to_zero_rad = 7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
s2e-ff/src/components/aocs/initialize_relative_attitude_sensor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @file initialize_relative_attitude_sensor.cpp | ||
* @brief Initialize function for RelativeAttitudeSensor | ||
*/ | ||
|
||
#include "initialize_relative_attitude_sensor.hpp" | ||
|
||
#include <components/base/initialize_sensor.hpp> | ||
#include <library/initialize/initialize_file_access.hpp> | ||
|
||
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; | ||
} |
19 changes: 19 additions & 0 deletions
19
s2e-ff/src/components/aocs/initialize_relative_attitude_sensor.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @file initialize_relative_attitude_sensor.hpp | ||
* @brief Initialize function for RelativeAttitudeSensor | ||
*/ | ||
|
||
#ifndef S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_ATTITUDE_SENSOR_HPP_ | ||
#define S2E_COMPONENTS_AOCS_INITIALIZE_RELATIVE_ATTITUDE_SENSOR_HPP_ | ||
|
||
#include "relative_attitude_sensor.hpp" | ||
|
||
/** | ||
* @fn InitializeRelativeAttitudeSensor | ||
* @brief Initialize function | ||
*/ | ||
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_INITIALIZE_RELATIVE_ATTITUDE_SENSOR_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @file relative_attitude_sensor.cpp | ||
* @brief Relative attitude sensor | ||
*/ | ||
|
||
#include "relative_attitude_sensor.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), | ||
Sensor(sensor_base), | ||
target_sat_id_(target_sat_id), | ||
reference_sat_id_(reference_sat_id), | ||
rel_info_(rel_info), | ||
dynamics_(dynamics) {} | ||
|
||
RelativeAttitudeSensor::~RelativeAttitudeSensor() {} | ||
|
||
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_); | ||
} | ||
|
||
std::string RelativeAttitudeSensor::GetLogHeader() const { | ||
std::string str_tmp = ""; | ||
std::string head = "RelativeAttitudeSensor_"; | ||
|
||
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); | ||
|
||
return str_tmp; | ||
} | ||
|
||
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_); | ||
|
||
return str_tmp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* @file relative_attitude_sensor.hpp | ||
* @brief Relative attitude sensor | ||
*/ | ||
|
||
#ifndef S2E_COMPONENTS_AOCS_RELATIVE_ATTITUDE_SENSOR_HPP_ | ||
#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 | ||
*/ | ||
class RelativeAttitudeSensor : public Component, public Sensor<3>, 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, | ||
const RelativeInformation& rel_info, const Dynamics& dynamics); | ||
/** | ||
* @fn ~RelativeAttitudeSensor | ||
* @brief Destructor | ||
*/ | ||
~RelativeAttitudeSensor(); | ||
|
||
// ComponentBase override function | ||
/** | ||
* @fn MainRoutine | ||
* @brief Main routine | ||
*/ | ||
void MainRoutine(int count); | ||
|
||
// Override ILoggable | ||
/** | ||
* @fn GetLogHeader | ||
* @brief Override GetLogHeader function of ILoggable | ||
*/ | ||
virtual std::string GetLogHeader() const; | ||
/** | ||
* @fn GetLogValue | ||
* @brief Override GetLogValue function of ILoggable | ||
*/ | ||
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_; } | ||
|
||
// Setter | ||
void SetTargetSatId(const int target_sat_id) { target_sat_id_ = target_sat_id; } | ||
|
||
protected: | ||
int target_sat_id_; //!< Target satellite ID | ||
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] | ||
|
||
// References | ||
const RelativeInformation& rel_info_; //!< Relative information | ||
const Dynamics& dynamics_; //!< Dynamics | ||
}; | ||
|
||
#endif // S2E_COMPONENTS_AOCS_RELATIVE_ATTITUDE_SENSOR_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters