kopia lustrzana https://github.com/ogre/pizero_tracker
dynamics_t: value always up-to-date
rodzic
6a3181ef55
commit
4f15f0d310
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
// utc_seconds is HHMMSS converted to seconds. return true if sample was accepted
|
||||
bool dynamics_t::add(const tp timestamp, const float val)
|
||||
|
@ -10,6 +12,7 @@ bool dynamics_t::add(const tp timestamp, const float val)
|
|||
if( !initialised_ && timestamp.time_since_epoch().count() )
|
||||
{
|
||||
val_ = val;
|
||||
val_prev_ = val;
|
||||
val_prev_timestamp_ = timestamp;
|
||||
dVdT_ = 0;
|
||||
|
||||
|
@ -22,18 +25,16 @@ bool dynamics_t::add(const tp timestamp, const float val)
|
|||
return true;
|
||||
}
|
||||
|
||||
if( (timestamp - val_prev_timestamp_).count()/1e9 < min_dT_ )
|
||||
val_ = val;
|
||||
val_min_ = std::min(val_, val_min_);
|
||||
val_max_ = std::max(val_, val_max_);
|
||||
|
||||
const float dT = float((timestamp - val_prev_timestamp_).count())/1e9;
|
||||
if( dT < min_dT_ )
|
||||
return false;
|
||||
|
||||
dVdT_ = (val - val_) / float((timestamp - val_prev_timestamp_).count()/1e9);
|
||||
|
||||
if(val > val_max_)
|
||||
val_max_ = val;
|
||||
|
||||
if(val < val_min_)
|
||||
val_min_ = val;
|
||||
|
||||
val_ = val;
|
||||
dVdT_ = (val - val_prev_) / dT;
|
||||
val_prev_ = val;
|
||||
val_prev_timestamp_ = timestamp;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -12,7 +12,8 @@ public:
|
|||
|
||||
private:
|
||||
bool initialised_ = false;
|
||||
float val_ = 0;
|
||||
float val_ = 0; // updated on every add()
|
||||
float val_prev_ = 0; // updated after min_dT_
|
||||
tp val_prev_timestamp_; // timestamp of previous value
|
||||
float val_min_ = std::numeric_limits<float>::max();
|
||||
float val_max_ = -std::numeric_limits<float>::min();
|
||||
|
|
Ładowanie…
Reference in New Issue