Skip to content

Commit

Permalink
Add randomization namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
200km committed Jul 20, 2024
1 parent ac3c2a1 commit d521601
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/components/base/sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Sensor {
math::Matrix<N, N> scale_factor_; //!< Scale factor matrix
math::Vector<N> range_to_const_c_; //!< Output range limit to be constant output value at the component frame
math::Vector<N> range_to_zero_c_; //!< Output range limit to be zero output value at the component frame
libra::NormalRand normal_random_noise_c_[N]; //!< Normal random
randomization::NormalRand normal_random_noise_c_[N]; //!< Normal random
RandomWalk<N> random_walk_noise_c_; //!< Random Walk

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/ideal/attitude_observer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class AttitudeObserver : public Component, public ILoggable {
protected:
math::Quaternion observed_quaternion_i2b_ = {0.0, 0.0, 0.0, 1.0}; //!< Observed quaternion

libra::NormalRand angle_noise_; //!< Normal random for magnitude noise
libra::NormalRand direction_noise_; //!< Normal random for direction noise
randomization::NormalRand angle_noise_; //!< Normal random for magnitude noise
randomization::NormalRand direction_noise_; //!< Normal random for direction noise

const Attitude& attitude_; //!< Attitude information
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/ideal/force_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class ForceGenerator : public Component, public ILoggable {
math::Vector<3> generated_force_rtn_N_{0.0}; //!< Generated force in the RTN frame [N]

// Noise
libra::NormalRand magnitude_noise_; //!< Normal random for magnitude noise
libra::NormalRand direction_noise_; //!< Normal random for direction noise
randomization::NormalRand magnitude_noise_; //!< Normal random for magnitude noise
randomization::NormalRand direction_noise_; //!< Normal random for direction noise
double direction_error_standard_deviation_rad_; //!< Standard deviation of direction error [rad]

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/ideal/orbit_observer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class OrbitObserver : public Component, public ILoggable {
math::Vector<3> observed_velocity_i_m_s_{0.0}; //!< Observed velocity @ inertial frame [m/s]

NoiseFrame noise_frame_; //!< Noise definition frame
libra::NormalRand normal_random_noise_[6]; //!< Position and Velocity noise [m, m/s]
randomization::NormalRand normal_random_noise_[6]; //!< Position and Velocity noise [m, m/s]

// Observed variables
const Orbit& orbit_; //!< Orbit information
Expand Down
4 changes: 2 additions & 2 deletions src/components/ideal/torque_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class TorqueGenerator : public Component, public ILoggable {
math::Vector<3> generated_torque_b_Nm_{0.0}; //!< Generated torque in the body fixed frame [Nm]

// Noise
libra::NormalRand magnitude_noise_; //!< Normal random for magnitude noise
libra::NormalRand direction_noise_; //!< Normal random for direction noise
randomization::NormalRand magnitude_noise_; //!< Normal random for magnitude noise
randomization::NormalRand direction_noise_; //!< Normal random for direction noise
double direction_error_standard_deviation_rad_; //!< Standard deviation of direction error [rad]

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/real/aocs/gnss_receiver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class GnssReceiver : public Component, public ILoggable {
AntennaModel antenna_model_; //!< Antenna model

// Simple position observation
libra::NormalRand position_random_noise_ecef_m_[3]; //!< Random noise for position at the ECEF frame [m]
libra::NormalRand velocity_random_noise_ecef_m_s_[3]; //!< Random noise for velocity at the ECEF frame [m]
randomization::NormalRand position_random_noise_ecef_m_[3]; //!< Random noise for position at the ECEF frame [m]
randomization::NormalRand velocity_random_noise_ecef_m_s_[3]; //!< Random noise for velocity at the ECEF frame [m]
math::Vector<3> position_ecef_m_{0.0}; //!< Observed position in the ECEF frame [m]
math::Vector<3> velocity_ecef_m_s_{0.0}; //!< Observed velocity in the ECEF frame [m/s]
GeodeticPosition geodetic_position_; //!< Observed position in the geodetic frame
Expand Down
2 changes: 1 addition & 1 deletion src/components/real/aocs/magnetorquer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Magnetorquer : public Component, public ILoggable {

math::Vector<kMtqDimension> bias_noise_c_Am2_{0.0}; //!< Constant bias noise in the component frame [Am2]
RandomWalk<kMtqDimension> random_walk_c_Am2_; //!< Random walk noise
libra::NormalRand random_noise_c_Am2_[kMtqDimension]; //!< Normal random noise
randomization::NormalRand random_noise_c_Am2_[kMtqDimension]; //!< Normal random noise

const GeomagneticField* geomagnetic_field_; //!< Geomagnetic environment

Expand Down
6 changes: 3 additions & 3 deletions src/components/real/aocs/star_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class StarSensor : public Component, public ILoggable {
math::Vector<3> second_orthogonal_direction_c; //!< The second orthogonal direction of sight at component frame

// Noise parameters
libra::MinimalStandardLcgWithShuffle rotation_noise_; //!< Randomize object for orthogonal direction
libra::NormalRand orthogonal_direction_noise_; //!< Random noise for orthogonal direction of sight
libra::NormalRand sight_direction_noise_; //!< Random noise for sight direction
randomization::MinimalStandardLcgWithShuffle rotation_noise_; //!< Randomize object for orthogonal direction
randomization::NormalRand orthogonal_direction_noise_; //!< Random noise for orthogonal direction of sight
randomization::NormalRand sight_direction_noise_; //!< Random noise for sight direction

// Delay emulation parameters
int max_delay_; //!< Max delay
Expand Down
2 changes: 1 addition & 1 deletion src/components/real/aocs/sun_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <math_physics/math/constants.hpp>
#include <math_physics/randomization/normal_randomization.hpp>
using libra::NormalRand;
using randomization::NormalRand;
#include <logger/log_utility.hpp>
#include <math_physics/randomization/global_randomization.hpp>
#include <setting_file_reader/initialize_file_access.hpp>
Expand Down
4 changes: 2 additions & 2 deletions src/components/real/aocs/sun_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class SunSensor : public Component, public ILoggable {
double detectable_angle_rad_; //!< half angle (>0) [rad]
bool sun_detected_flag_ = false; //!< Sun detected flag
// Noise parameters
libra::NormalRand random_noise_alpha_; //!< Normal random for alpha angle
libra::NormalRand random_noise_beta_; //!< Normal random for beta angle
randomization::NormalRand random_noise_alpha_; //!< Normal random for alpha angle
randomization::NormalRand random_noise_beta_; //!< Normal random for beta angle
double bias_noise_alpha_rad_ = 0.0; //!< Constant bias for alpha angle (Value is calculated by random number generator)
double bias_noise_beta_rad_ = 0.0; //!< Constant bias for beta angle (Value is calculated by random number generator)

Expand Down
4 changes: 2 additions & 2 deletions src/components/real/propulsion/simple_thruster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class SimpleThruster : public Component, public ILoggable {
double duty_ = 0.0; //!< PWM Duty [0.0 : 1.0]
double thrust_magnitude_max_N_ = 0.0; //!< Maximum thrust magnitude [N]
double direction_noise_standard_deviation_rad_ = 0.0; //!< Standard deviation of thrust direction error [rad]
libra::NormalRand magnitude_random_noise_; //!< Normal random for thrust magnitude error
libra::NormalRand direction_random_noise_; //!< Normal random for thrust direction error
randomization::NormalRand magnitude_random_noise_; //!< Normal random for thrust magnitude error
randomization::NormalRand direction_random_noise_; //!< Normal random for thrust direction error
// outputs
Vector<3> output_thrust_b_N_{0.0}; //!< Generated thrust on the body fixed frame [N]
Vector<3> output_torque_b_Nm_{0.0}; //!< Generated torque on the body fixed frame [Nm]
Expand Down
2 changes: 1 addition & 1 deletion src/disturbances/magnetic_disturbance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void MagneticDisturbance::CalcRMM() {
static math::Vector<3> random_walk_std_dev(residual_magnetic_moment_.GetRandomWalkStandardDeviation_Am2());
static math::Vector<3> random_walk_limit(residual_magnetic_moment_.GetRandomWalkLimit_Am2());
static RandomWalk<3> random_walk(0.1, random_walk_std_dev, random_walk_limit); // [FIXME] step width is constant
static libra::NormalRand normal_random(0.0, residual_magnetic_moment_.GetRandomNoiseStandardDeviation_Am2(), global_randomization.MakeSeed());
static randomization::NormalRand normal_random(0.0, residual_magnetic_moment_.GetRandomNoiseStandardDeviation_Am2(), global_randomization.MakeSeed());

rmm_b_Am2_ = residual_magnetic_moment_.GetConstantValue_b_Am2();
for (int i = 0; i < 3; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/environment/local/atmosphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ double Atmosphere::CalcAirDensity_kg_m3(const double decimal_year, const Orbit&

double Atmosphere::AddNoise(const double rho_kg_m3) {
// RandomWalk rw(rho_kg_m3*rw_stepwidth_,rho_kg_m3*rw_stddev_,rho_kg_m3*rw_limit_);
libra::NormalRand nr(0.0, rho_kg_m3 * gauss_standard_deviation_rate_, global_randomization.MakeSeed());
randomization::NormalRand nr(0.0, rho_kg_m3 * gauss_standard_deviation_rate_, global_randomization.MakeSeed());
double nrd = nr;

return rho_kg_m3 + nrd;
Expand Down
2 changes: 1 addition & 1 deletion src/environment/local/geomagnetic_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void GeomagneticField::AddNoise(double* magnetic_field_array_i_nT) {
static math::Vector<3> limit(random_walk_limit_nT_);
static RandomWalk<3> random_walk(0.1, standard_deviation, limit);

static libra::NormalRand white_noise(0.0, white_noise_standard_deviation_nT_, global_randomization.MakeSeed());
static randomization::NormalRand white_noise(0.0, white_noise_standard_deviation_nT_, global_randomization.MakeSeed());

for (int i = 0; i < 3; ++i) {
magnetic_field_array_i_nT[i] += random_walk[i] + white_noise;
Expand Down
2 changes: 1 addition & 1 deletion src/math_physics/randomization/global_randomization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GlobalRandomization {

private:
static const unsigned int kMaxSeed = 0xffffffff; //!< Maximum value of seed
libra::MinimalStandardLcg base_randomizer_; //!< Base of global randomization
randomization::MinimalStandardLcg base_randomizer_; //!< Base of global randomization
long seed_; //!< Seed of global randomization
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include "minimal_standard_linear_congruential_generator.hpp"
using libra::MinimalStandardLcg;
using randomization::MinimalStandardLcg;

#include <stdexcept>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef S2E_LIBRARY_RANDOMIZATION_MINIMAL_STANDARD_LINEAR_CONGRUENTIAL_GENERATOR_HPP_
#define S2E_LIBRARY_RANDOMIZATION_MINIMAL_STANDARD_LINEAR_CONGRUENTIAL_GENERATOR_HPP_

namespace libra {
namespace randomization {

/**
* @class MinimalStandardLcg
Expand Down Expand Up @@ -52,6 +52,6 @@ class MinimalStandardLcg {
long seed_; //!< Seed of randomization
};

} // namespace libra
} // namespace randomization

#endif // S2E_LIBRARY_RANDOMIZATION_MINIMAL_STANDARD_LINEAR_CONGRUENTIAL_GENERATOR_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include "minimal_standard_linear_congruential_generator_with_shuffle.hpp"
using libra::MinimalStandardLcgWithShuffle;
using randomization::MinimalStandardLcgWithShuffle;

MinimalStandardLcgWithShuffle::MinimalStandardLcgWithShuffle() : table_position_(0) { Initialize(); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "minimal_standard_linear_congruential_generator.hpp"

namespace libra {
namespace randomization {

/**
* @class MinimalStandardLcgWithShuffle
Expand Down Expand Up @@ -58,6 +58,6 @@ class MinimalStandardLcgWithShuffle {
double mixing_table_[kTableSize]; //!< Mixing table
};

} // namespace libra
} // namespace randomization

#endif // S2E_LIBRARY_RANDOMIZATION_MINIMAL_STANDARD_LINEAR_CONGRUENTIAL_GENERATOR_WITH_SHUFFLE_HPP_
2 changes: 1 addition & 1 deletion src/math_physics/randomization/normal_randomization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @note Ref: NUMERICAL RECIPES in C, p.216-p.217
*/
#include "normal_randomization.hpp"
using libra::NormalRand;
using randomization::NormalRand;

#include <cfloat> //DBL_EPSILON
#include <cmath> //sqrt, log;
Expand Down
6 changes: 3 additions & 3 deletions src/math_physics/randomization/normal_randomization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#define S2E_LIBRARY_RANDOMIZATION_NORMAL_RANDOMIZATION_HPP_

#include "minimal_standard_linear_congruential_generator_with_shuffle.hpp"
using libra::MinimalStandardLcgWithShuffle;
using randomization::MinimalStandardLcgWithShuffle;

namespace libra {
namespace randomization {

/**
* @class NormalRand
Expand Down Expand Up @@ -106,6 +106,6 @@ class NormalRand {
bool is_empty_; //!< Flag to show the holder_ has available value
};

} // namespace libra
} // namespace randomization

#endif // S2E_LIBRARY_RANDOMIZATION_NORMAL_RANDOMIZATION_HPP_
2 changes: 1 addition & 1 deletion src/math_physics/randomization/random_walk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RandomWalk : public math::OrdinaryDifferentialEquation<N> {

private:
math::Vector<N> limit_; //!< Limit of random walk
libra::NormalRand normal_randomizer_[N]; //!< Random walk excitation noise
randomization::NormalRand normal_randomizer_[N]; //!< Random walk excitation noise
};

#include "random_walk_template_functions.hpp" // template function definisions.
Expand Down

0 comments on commit d521601

Please sign in to comment.