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 #15 from ut-issl/feature/add-distance-sensor
Add distance sensor
- Loading branch information
Showing
14 changed files
with
201 additions
and
9 deletions.
There are no files selected for viewing
Submodule s2e-core
updated
72 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,26 @@ | ||
[RelativeDistanceSensor] | ||
target_sat_id = 1 | ||
reference_sat_id = 0 | ||
|
||
[ComponentBase] | ||
// Prescaler with respect to the component update period | ||
prescaler = 1 | ||
|
||
[SensorBase] | ||
scale_factor_c(0) = 1; | ||
|
||
// Constant bias noise [m] | ||
constant_bias_c(0) = 10.0 | ||
|
||
// Standard deviation of normal random noise [m] | ||
normal_random_standard_deviation_c(0) = 1.0 | ||
|
||
// Standard deviation for random walk noise [m] | ||
random_walk_standard_deviation_c(0) = 0.0 | ||
|
||
// Limit of random walk noise [m] | ||
random_walk_limit_c(0) = 0.0 | ||
|
||
// Range [m] | ||
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
27 changes: 27 additions & 0 deletions
27
s2e-ff/src/Components/AOCS/InitializeRelativeDistanceSensor.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,27 @@ | ||
#include "InitializeRelativeDistanceSensor.hpp" | ||
|
||
#include <Interface/InitInput/IniAccess.h> | ||
|
||
#include "../Abstract/InitializeSensorBase.hpp" | ||
|
||
RelativeDistanceSensor InitializeRelativeDistanceSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, | ||
const RelativeInformation& rel_info) { | ||
// General | ||
IniAccess ini_file(file_name); | ||
|
||
// CompoBase | ||
int prescaler = ini_file.ReadInt("ComponentBase", "prescaler"); | ||
if (prescaler <= 1) prescaler = 1; | ||
|
||
// SensorBase | ||
SensorBase<1> sensor_base = ReadSensorBaseInformation<1>(file_name, compo_step_time_s * (double)(prescaler)); | ||
|
||
// RelativeDistanceSensor | ||
char section[30] = "RelativeDistanceSensor"; | ||
int target_sat_id = ini_file.ReadInt(section, "target_sat_id"); | ||
int reference_sat_id = ini_file.ReadInt(section, "reference_sat_id"); | ||
|
||
RelativeDistanceSensor relative_distance_sensor(prescaler, clock_gen, sensor_base, target_sat_id, reference_sat_id, rel_info); | ||
|
||
return relative_distance_sensor; | ||
} |
6 changes: 6 additions & 0 deletions
6
s2e-ff/src/Components/AOCS/InitializeRelativeDistanceSensor.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 "RelativeDistanceSensor.hpp" | ||
|
||
RelativeDistanceSensor InitializeRelativeDistanceSensor(ClockGenerator* clock_gen, const std::string file_name, const double compo_step_time_s, | ||
const RelativeInformation& rel_info); |
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,31 @@ | ||
#include "RelativeDistanceSensor.hpp" | ||
|
||
RelativeDistanceSensor::RelativeDistanceSensor(const int prescaler, ClockGenerator* clock_gen, SensorBase& sensor_base, | ||
const int target_sat_id, const int reference_sat_id, | ||
const RelativeInformation& rel_info) | ||
: ComponentBase(prescaler, clock_gen), SensorBase(sensor_base), | ||
target_sat_id_(target_sat_id), reference_sat_id_(reference_sat_id), rel_info_(rel_info) {} | ||
|
||
RelativeDistanceSensor::~RelativeDistanceSensor() {} | ||
|
||
void RelativeDistanceSensor::MainRoutine(int count) { | ||
UNUSED(count); | ||
|
||
measured_distance_bw_ref_target_m_[0] = rel_info_.GetRelativeDistance_m(target_sat_id_, reference_sat_id_); | ||
measured_distance_bw_ref_target_m_ = Measure(measured_distance_bw_ref_target_m_); // Add Noise | ||
} | ||
|
||
std::string RelativeDistanceSensor::GetLogHeader() const { | ||
std::string str_tmp = ""; | ||
str_tmp += WriteScalar("relative_distance_sensor_ref_to_target", "m"); | ||
|
||
return str_tmp; | ||
} | ||
|
||
std::string RelativeDistanceSensor::GetLogValue() const { | ||
std::string str_tmp = ""; | ||
|
||
str_tmp += WriteScalar(measured_distance_bw_ref_target_m_[0]); | ||
|
||
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,38 @@ | ||
#ifndef RELATIVE_DISTANCE_SENSOR_H_ | ||
#define RELATIVE_DISTANCE_SENSOR_H_ | ||
|
||
#include <Interface/LogOutput/ILoggable.h> | ||
#include <RelativeInformation/RelativeInformation.h> | ||
|
||
#include <Component/Abstract/ComponentBase.h> | ||
#include <Component/Abstract/SensorBase.h> | ||
|
||
class RelativeDistanceSensor : public ComponentBase, public SensorBase<1>, public ILoggable { | ||
public: | ||
RelativeDistanceSensor(const int prescaler, ClockGenerator* clock_gen, SensorBase& sensor_base, | ||
const int target_sat_id, const int reference_sat_id, | ||
const RelativeInformation& rel_info); | ||
~RelativeDistanceSensor(); | ||
// ComponentBase | ||
void MainRoutine(int count) override; | ||
|
||
// ILoggable | ||
virtual std::string GetLogHeader() const; | ||
virtual std::string GetLogValue() const; | ||
|
||
// Getter | ||
inline double GetMeasuredDistance_m() const { return measured_distance_bw_ref_target_m_[0]; } | ||
|
||
// Setter | ||
void SetTargetSatId(const int target_sat_id) { target_sat_id_ = target_sat_id; } | ||
|
||
protected: | ||
int target_sat_id_; | ||
const int reference_sat_id_; | ||
|
||
libra::Vector<1> measured_distance_bw_ref_target_m_{0.0}; | ||
|
||
const RelativeInformation& rel_info_; | ||
}; | ||
|
||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include <Component/Abstract/SensorBase.h> | ||
|
||
// TODO:これをコアに移して全体で共有したい | ||
template <size_t N> | ||
SensorBase<N> ReadSensorBaseInformation(const std::string file_name, const double step_width_s); | ||
|
||
#include "InitializeSensorBase_tfs.hpp" |
37 changes: 37 additions & 0 deletions
37
s2e-ff/src/Components/Abstract/InitializeSensorBase_tfs.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,37 @@ | ||
|
||
#pragma once | ||
#include <Interface/InitInput/IniAccess.h> | ||
|
||
template <size_t N> | ||
SensorBase<N> ReadSensorBaseInformation(const std::string file_name, const double step_width_s) { | ||
IniAccess ini_file(file_name); | ||
char section[30] = "SensorBase"; | ||
|
||
libra::Vector<N * N> scale_factor_vector; | ||
ini_file.ReadVector(section, "scale_factor_c", scale_factor_vector); | ||
libra::Matrix<N, N> scale_factor_c; | ||
for (size_t i = 0; i < N; i++) { | ||
for (size_t j = 0; j < N; j++) { | ||
scale_factor_c[i][j] = scale_factor_vector[i * N + j]; | ||
} | ||
} | ||
|
||
libra::Vector<N> constant_bias_c; | ||
ini_file.ReadVector(section, "constant_bias_c", constant_bias_c); | ||
libra::Vector<N> normal_random_standard_deviation_c; | ||
ini_file.ReadVector(section, "normal_random_standard_deviation_c", normal_random_standard_deviation_c); | ||
libra::Vector<N> random_walk_standard_deviation_c; | ||
ini_file.ReadVector(section, "random_walk_standard_deviation_c", random_walk_standard_deviation_c); | ||
libra::Vector<N> random_walk_limit_c; | ||
ini_file.ReadVector(section, "random_walk_limit_c", random_walk_limit_c); | ||
|
||
double range_to_const = ini_file.ReadDouble(section, "range_to_const"); | ||
libra::Vector<N> range_to_const_c{range_to_const}; | ||
double range_to_zero = ini_file.ReadDouble(section, "range_to_zero"); | ||
libra::Vector<N> range_to_zero_c{range_to_zero}; | ||
|
||
SensorBase<N> sensor_base(scale_factor_c, range_to_const_c, range_to_zero_c, constant_bias_c, normal_random_standard_deviation_c, step_width_s, | ||
random_walk_standard_deviation_c, random_walk_limit_c); | ||
|
||
return sensor_base; | ||
} |
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
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