61
61
#define HYSTERESIS 0.1 // for the hybrid mode
62
62
63
63
GaussianProcessGuider::GaussianProcessGuider (guide_parameters parameters)
64
- : start_time_(std::chrono::system_clock:: now()), last_time_(std::chrono::system_clock:: now()), control_signal_(0 ),
65
- prediction_( 0 ), last_prediction_end_( 0 ), dither_steps_(0 ), dithering_active_(false ), dither_offset_(0.0 ),
66
- circular_buffer_data_(CIRCULAR_BUFFER_SIZE ), covariance_function_ (), output_covariance_function_( ),
67
- gp_(covariance_function_), learning_rate_(DEFAULT_LEARNING_RATE), parameters(parameters)
64
+ : start_time_(clock:: now()), last_time_(clock:: now()), control_signal_( 0 ), prediction_( 0 ), last_prediction_end_ (0 ),
65
+ dither_steps_(0 ), dithering_active_(false ), dither_offset_(0.0 ), circular_buffer_data_(CIRCULAR_BUFFER_SIZE ),
66
+ covariance_function_( ), output_covariance_function_ (), gp_(covariance_function_), learning_rate_(DEFAULT_LEARNING_RATE ),
67
+ parameters(parameters)
68
68
{
69
69
circular_buffer_data_.push_front (data_point ()); // add first point
70
70
circular_buffer_data_[0 ].control = 0 ; // set first control to zero
@@ -86,7 +86,7 @@ GaussianProcessGuider::~GaussianProcessGuider() { }
86
86
87
87
void GaussianProcessGuider::SetTimestamp ()
88
88
{
89
- auto current_time = std::chrono::system_clock ::now ();
89
+ auto current_time = clock ::now ();
90
90
double delta_measurement_time = std::chrono::duration<double >(current_time - last_time_).count ();
91
91
last_time_ = current_time;
92
92
get_last_point ().timestamp = std::chrono::duration<double >(current_time - start_time_).count () -
@@ -238,7 +238,7 @@ double GaussianProcessGuider::PredictGearError(double prediction_location)
238
238
// in the first step of each sequence, use the current time stamp as last prediction end
239
239
if (last_prediction_end_ < 0.0 )
240
240
{
241
- last_prediction_end_ = std::chrono::duration<double >(std::chrono::system_clock ::now () - start_time_).count ();
241
+ last_prediction_end_ = std::chrono::duration<double >(clock ::now () - start_time_).count ();
242
242
}
243
243
244
244
// prediction from the last endpoint to the prediction point
@@ -296,7 +296,7 @@ double GaussianProcessGuider::result(double input, double SNR, double time_step,
296
296
// the starting time is set at the first call of result after startup or reset
297
297
if (get_number_of_measurements () == 1 )
298
298
{
299
- start_time_ = std::chrono::system_clock ::now ();
299
+ start_time_ = clock ::now ();
300
300
last_time_ = start_time_; // this is OK, since last_time_ only provides a minor correction
301
301
}
302
302
@@ -325,7 +325,7 @@ double GaussianProcessGuider::result(double input, double SNR, double time_step,
325
325
{
326
326
if (prediction_point < 0.0 )
327
327
{
328
- prediction_point = std::chrono::duration<double >(std::chrono::system_clock ::now () - start_time_).count ();
328
+ prediction_point = std::chrono::duration<double >(clock ::now () - start_time_).count ();
329
329
}
330
330
// the point of highest precision shoud be between now and the next step
331
331
UpdateGP (prediction_point + 0.5 * time_step);
@@ -380,7 +380,7 @@ double GaussianProcessGuider::deduceResult(double time_step, double prediction_p
380
380
{
381
381
if (prediction_point < 0.0 )
382
382
{
383
- prediction_point = std::chrono::duration<double >(std::chrono::system_clock ::now () - start_time_).count ();
383
+ prediction_point = std::chrono::duration<double >(clock ::now () - start_time_).count ();
384
384
}
385
385
// the point of highest precision should be between now and the next step
386
386
UpdateGP (prediction_point + 0.5 * time_step);
@@ -416,8 +416,8 @@ void GaussianProcessGuider::reset()
416
416
circular_buffer_data_[0 ].control = 0 ; // set first control to zero
417
417
418
418
last_prediction_end_ = -1.0 ; // the negative value signals we didn't predict yet
419
- start_time_ = std::chrono::system_clock ::now ();
420
- last_time_ = std::chrono::system_clock ::now ();
419
+ start_time_ = clock ::now ();
420
+ last_time_ = clock ::now ();
421
421
422
422
dither_offset_ = 0.0 ;
423
423
dither_steps_ = 0 ;
@@ -573,7 +573,7 @@ void GaussianProcessGuider::inject_data_point(double timestamp, double input, do
573
573
last_prediction_end_ = timestamp;
574
574
get_last_point ().timestamp = timestamp; // overrides the usual HandleTimestamps();
575
575
576
- start_time_ = std::chrono::system_clock ::now () - std::chrono::seconds ((int ) timestamp);
576
+ start_time_ = clock ::now () - std::chrono::seconds ((int ) timestamp);
577
577
578
578
add_one_point (); // add new point here, since the control is for the next point in time
579
579
HandleControls (control); // already store control signal
0 commit comments