45 if (first_timestamp_ < 1e-3) {
46 first_timestamp_ = timestamp;
48 double relative_timestamp = timestamp - first_timestamp_;
49 while (!prev_status_.empty() &&
50 relative_timestamp - prev_status_.front().first > s_tracking_time_win_) {
51 prev_status_.pop_front();
53 prev_status_.push_back(std::make_pair(relative_timestamp, open_percent));
56 if (prev_status_.size() == 1) {
57 AINFO <<
"No cached open_percent status, return unkown.";
59 }
else if (open_percent < close_threshold_) {
62 std::vector<float> status_samples(
static_cast<int>(prev_status_.size() * 2), 0);
63 for (
size_t i = 0; i < prev_status_.size(); i++) {
64 auto& status = prev_status_.at(i);
65 status_samples[i*2] = status.first;
66 status_samples[i*2+1] = status.second;
69 float fit_line[3] = {0};
73 theta = std::atan(-fit_line[0] / (fit_line[1] + 1e-6));
75 if (std::abs(theta) < status_change_threshold_) {
76 if (open_percent > open_threshold_) {
78 }
else if (open_percent < close_threshold_) {
83 }
else if (theta > 0.) {
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...