28 lines
756 B
C++
28 lines
756 B
C++
//
|
|
// Created by baiguwen on 2022/4/23.
|
|
//
|
|
#include "periodic_interference.h"
|
|
#include <math.h>
|
|
#include <numbers>
|
|
#include <random>
|
|
|
|
void periodic_interference::set_config(const nlohmann::json &config) {
|
|
try {
|
|
eval_time_ = 0;
|
|
amplitude_ = jsonValue(config, "PERIODIC_INTERFERENCE_AMPLITUDE");
|
|
amplitude_base_ = jsonValue(config, "PERIODIC_INTERFERENCE_AMPLITUDE_BASE");
|
|
cycle_ = jsonValue(config, "CYCLE_");
|
|
config_ = config;
|
|
} catch (...) {
|
|
|
|
}
|
|
}
|
|
|
|
nlohmann::json periodic_interference::config() {
|
|
return config_;
|
|
}
|
|
|
|
|
|
double periodic_interference::eval(double value) {
|
|
return value + amplitude_base_ * sin((2 * std::numbers::pi / cycle_) * eval_time_++) + amplitude_;
|
|
} |