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.
Merge pull request #44 from ut-issl/feature/add-relative-velocity-rtn
Add relative velocity sensor
- Loading branch information
Showing
10 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
Submodule s2e-core
updated
27 files
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[RelativeVelocitySensor] | ||
// Target satellite ID | ||
target_sat_id = 1 | ||
|
||
// Normally, reference_sat_id is set the id of mounted satellite | ||
reference_sat_id = 0 | ||
|
||
// Users can choose the frame for error settings | ||
// INERTIAL, RTN | ||
error_frame = RTN | ||
|
||
[ComponentBase] | ||
// Prescaler with respect to the component update period | ||
prescaler = 1 | ||
|
||
[SensorBase] | ||
// 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 [m/s] | ||
constant_bias_c(0) = 0.0 | ||
constant_bias_c(1) = 0.0 | ||
constant_bias_c(2) = 0.0 | ||
|
||
// Standard deviation of normal random noise [m/s] | ||
normal_random_standard_deviation_c(0) = 0.0 | ||
normal_random_standard_deviation_c(1) = 0.0 | ||
normal_random_standard_deviation_c(2) = 0.0 | ||
|
||
// Standard deviation for random walk noise [m/s] | ||
random_walk_standard_deviation_c(0) = 0.0 | ||
random_walk_standard_deviation_c(1) = 0.0 | ||
random_walk_standard_deviation_c(2) = 0.0 | ||
|
||
// Limit of random walk noise [m/s] | ||
random_walk_limit_c(0) = 0.0 | ||
random_walk_limit_c(1) = 0.0 | ||
random_walk_limit_c(2) = 0.0 | ||
|
||
// Range [m/s] | ||
range_to_const = 1000000.0 // smaller than range_to_zero_m | ||
range_to_zero = 10000000.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
39 changes: 39 additions & 0 deletions
39
s2e-ff/src/Components/AOCS/InitializeRelativeVelocitySensor.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,39 @@ | ||
#include "InitializeRelativeVelocitySensor.hpp" | ||
|
||
#include <Interface/InitInput/IniAccess.h> | ||
|
||
#include "../Abstract/InitializeSensorBase.hpp" | ||
|
||
RelativeVelocitySensor InitializeRelativeVelocitySensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, | ||
const RelativeInformation& rel_info, const Dynamics& dynamics) { | ||
// General | ||
IniAccess ini_file(file_name); | ||
|
||
// CompoBase | ||
int prescaler = ini_file.ReadInt("ComponentBase", "prescaler"); | ||
if (prescaler <= 1) prescaler = 1; | ||
|
||
// SensorBase | ||
SensorBase<3> sensor_base = ReadSensorBaseInformation<3>(file_name, compo_step_time_s * (double)(prescaler)); | ||
|
||
// RelativeVelocitySensor | ||
char section[30] = "RelativeVelocitySensor"; | ||
int target_sat_id = ini_file.ReadInt(section, "target_sat_id"); | ||
int reference_sat_id = ini_file.ReadInt(section, "reference_sat_id"); | ||
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; | ||
} | ||
|
||
RelativeVelocitySensor relative_velocity_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, error_frame, rel_info, | ||
dynamics); | ||
|
||
return relative_velocity_sensor; | ||
} |
6 changes: 6 additions & 0 deletions
6
s2e-ff/src/Components/AOCS/InitializeRelativeVelocitySensor.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,6 @@ | ||
#pragma once | ||
|
||
#include "RelativeVelocitySensor.hpp" | ||
|
||
RelativeVelocitySensor InitializeRelativeVelocitySensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, | ||
const RelativeInformation& rel_info, const Dynamics& dynamics); |
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,63 @@ | ||
#include "RelativeVelocitySensor.hpp" | ||
|
||
RelativeVelocitySensor::RelativeVelocitySensor(const int prescaler, ClockGenerator* clock_gen, SensorBase& sensor_base, const int target_sat_id, | ||
const int reference_sat_id, const RelativeVelocitySensorErrorFrame error_frame, | ||
const RelativeInformation& rel_info, const Dynamics& dynamics) | ||
: ComponentBase(prescaler, clock_gen), | ||
SensorBase(sensor_base), | ||
target_sat_id_(target_sat_id), | ||
reference_sat_id_(reference_sat_id), | ||
error_frame_(error_frame), | ||
rel_info_(rel_info), | ||
dynamics_(dynamics) {} | ||
|
||
RelativeVelocitySensor::~RelativeVelocitySensor() {} | ||
|
||
void RelativeVelocitySensor::MainRoutine(int count) { | ||
UNUSED(count); | ||
|
||
// Get true value | ||
libra::Vector<3> true_target_velocity_i_m_s = rel_info_.GetRelativeVelocity_i_m_s(target_sat_id_, reference_sat_id_); | ||
libra::Vector<3> true_target_velocity_rtn_m_s = rel_info_.GetRelativeVelocity_rtn_m_s(target_sat_id_, reference_sat_id_); | ||
|
||
// Add noise at body frame and frame conversion | ||
libra::Quaternion q_i2rtn = dynamics_.GetOrbit().CalcQuaternionI2LVLH(); | ||
switch (error_frame_) { | ||
case RelativeVelocitySensorErrorFrame::INERTIAL: { | ||
measured_target_velocity_i_m_s_ = Measure(true_target_velocity_i_m_s); | ||
libra::Vector<3> d_vel_i_m_s = measured_target_velocity_i_m_s_ - true_target_velocity_i_m_s; | ||
// Frame conversion | ||
libra::Vector<3> d_vel_rtn_m_s = q_i2rtn.frame_conv(d_vel_i_m_s); | ||
measured_target_velocity_rtn_m_s_ = true_target_velocity_rtn_m_s + d_vel_rtn_m_s; | ||
break; | ||
} | ||
case RelativeVelocitySensorErrorFrame::RTN: { | ||
measured_target_velocity_rtn_m_s_ = Measure(true_target_velocity_rtn_m_s); | ||
libra::Vector<3> d_vel_rtn_m_s = measured_target_velocity_rtn_m_s_ - true_target_velocity_rtn_m_s; | ||
// Frame conversion | ||
libra::Vector<3> d_vel_i_m_s = q_i2rtn.frame_conv_inv(d_vel_rtn_m_s); | ||
measured_target_velocity_i_m_s_ = true_target_velocity_i_m_s + d_vel_i_m_s; | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
std::string RelativeVelocitySensor::GetLogHeader() const { | ||
std::string str_tmp = ""; | ||
std::string head = "RelativeVelocitySensor_"; | ||
str_tmp += WriteVector(head + "velocity", "i", "m", 3); | ||
str_tmp += WriteVector(head + "velocity", "rtn", "m", 3); | ||
|
||
return str_tmp; | ||
} | ||
|
||
std::string RelativeVelocitySensor::GetLogValue() const { | ||
std::string str_tmp = ""; | ||
|
||
str_tmp += WriteVector(measured_target_velocity_i_m_s_); | ||
str_tmp += WriteVector(measured_target_velocity_rtn_m_s_); | ||
|
||
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,42 @@ | ||
#ifndef RELATIVE_VELOCITY_SENSOR_H_ | ||
#define RELATIVE_VELOCITY_SENSOR_H_ | ||
|
||
#include <Component/Abstract/ComponentBase.h> | ||
#include <Component/Abstract/SensorBase.h> | ||
#include <Interface/LogOutput/ILoggable.h> | ||
#include <RelativeInformation/RelativeInformation.h> | ||
|
||
enum class RelativeVelocitySensorErrorFrame { INERTIAL, RTN }; | ||
|
||
class RelativeVelocitySensor : public ComponentBase, public SensorBase<3>, public ILoggable { | ||
public: | ||
RelativeVelocitySensor(const int prescaler, ClockGenerator* clock_gen, SensorBase& sensor_base, const int target_sat_id, const int reference_sat_id, | ||
const RelativeVelocitySensorErrorFrame error_frame, const RelativeInformation& rel_info, const Dynamics& dynamics); | ||
~RelativeVelocitySensor(); | ||
// ComponentBase | ||
void MainRoutine(int count) override; | ||
|
||
// ILoggable | ||
virtual std::string GetLogHeader() const; | ||
virtual std::string GetLogValue() const; | ||
|
||
// Getter | ||
inline libra::Vector<3> GetMeasuredTargetVelocity_i_m_s() const { return measured_target_velocity_i_m_s_; } | ||
inline libra::Vector<3> GetMeasuredTargetVelocity_rtn_m_s() const { return measured_target_velocity_rtn_m_s_; } | ||
|
||
// Setter | ||
void SetTargetSatId(const int target_sat_id) { target_sat_id_ = target_sat_id; } | ||
|
||
protected: | ||
int target_sat_id_; | ||
const int reference_sat_id_; | ||
RelativeVelocitySensorErrorFrame error_frame_; | ||
|
||
libra::Vector<3> measured_target_velocity_i_m_s_{0.0}; | ||
libra::Vector<3> measured_target_velocity_rtn_m_s_{0.0}; | ||
|
||
const RelativeInformation& rel_info_; | ||
const Dynamics& dynamics_; | ||
}; | ||
|
||
#endif |
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