Skip to content

Commit

Permalink
Merge pull request #190 from ut-issl/hotfix/fix-sensor-base-randomize
Browse files Browse the repository at this point in the history
[Hotfix] Fix sensor base randomize
  • Loading branch information
200km authored Aug 1, 2022
2 parents bca585d + 6db375d commit 7b6fc0d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/Component/Abstract/SensorBase_tfs.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <Library/math/GlobalRand.h>

template <size_t N>
SensorBase<N>::SensorBase(const libra::Matrix<N, N>& scale_factor, const libra::Vector<N>& range_to_const_c, const libra::Vector<N>& range_to_zero_c,
const libra::Vector<N>& bias_c, const libra::Vector<N>& nr_stddev_c, double rw_stepwidth,
Expand All @@ -10,7 +12,7 @@ SensorBase<N>::SensorBase(const libra::Matrix<N, N>& scale_factor, const libra::
bias_c_(bias_c),
n_rw_c_(rw_stepwidth, rw_stddev_c, rw_limit_c) {
for (size_t i = 0; i < N; i++) {
nrs_c_[i].set_param(0.0, nr_stddev_c[i]); // g_rand.MakeSeed()
nrs_c_[i].set_param(0.0, nr_stddev_c[i], g_rand.MakeSeed());
}
RangeCheck();
}
Expand Down
8 changes: 0 additions & 8 deletions src/Library/math/GlobalRand.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@

class GlobalRand {
public:
//! コンストラクタ
/*!
\param q_bd 機体座標(B)からSTT設計座標(D)への変換Quaternion
\param q_ds STT設計座標(D)からSTT実座標(S)への変換Quaternion
\param sigma_ortho 視線直交方向誤差標準偏差[rad/sec]
\param sigma_sight 視線方向誤差標準偏差[rad/sec]
\param delay STT出力遅れ。0.1秒単位範囲[0-MAX_DELAY]。
*/
GlobalRand();
void SetSeed(long seed);
long MakeSeed();
Expand Down
2 changes: 2 additions & 0 deletions src/Library/math/NormalRand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class NormalRand {
*/
inline void set_param(double avg, double stddev);

inline void set_param(double avg, double stddev, long seed);

private:
//! 平均値を保持するメンバ
double avg_;
Expand Down
6 changes: 6 additions & 0 deletions src/Library/math/NormalRand_ifs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ void NormalRand::set_param(double avg, double stddev) {
stddev_ = stddev;
}

void NormalRand::set_param(double avg, double stddev, long seed) {
avg_ = avg;
stddev_ = stddev;
rand_.init_seed(seed);
}

} // namespace libra

#endif // NORMAL_RAND_IFS_HPP_
5 changes: 5 additions & 0 deletions src/Library/math/Ran1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Ran1::Ran1() : y_(0) { init_(); }

Ran1::Ran1(long seed) : ran0_(seed), y_(0) { init_(); }

void Ran1::init_seed(long seed) {
ran0_.init(seed);
init_();
}

void Ran1::init_() {
// ran0_のウォームアップ
for (int i = 0; i < 8; i++) {
Expand Down
2 changes: 2 additions & 0 deletions src/Library/math/Ran1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Ran1 {
*/
operator double();

void init_seed(long seed);

private:
//! 切り混ぜ表の初期化処理を行う関数
void init_();
Expand Down
3 changes: 2 additions & 1 deletion src/Library/math/RandomWalk_tfs.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#pragma once

#include <Library/utils/Macros.hpp>
#include <Library/math/GlobalRand.h>

template <size_t N>
RandomWalk<N>::RandomWalk(double step_width, const libra::Vector<N>& stddev, const libra::Vector<N>& limit)
: libra::ODE<N>(step_width), limit_(limit) {
// 標準偏差設定
for (size_t i = 0; i < N; ++i) {
nrs_[i].set_param(0.0, stddev[i]); // g_rand.MakeSeed()
nrs_[i].set_param(0.0, stddev[i], g_rand.MakeSeed());
}
}

Expand Down

0 comments on commit 7b6fc0d

Please sign in to comment.