core-rocket / amatsukaze

2019年11月大島
2 stars 1 forks source link

moving_averageにsizeが見つからない #9

Closed Yukuro closed 5 years ago

Yukuro commented 5 years ago

詳細

utility/filter.hppのsample codeでbuildしたところ、以下のエラーメッセージが表示された

In file included from src/main.cpp:4:0:
include/utility/filter.hpp: In instantiation of 'T utility::moving_average<T, size>::filtered() const [with T = float; unsigned int size = 5u]':
src/main.cpp:83:76:   required from here
include/utility/filter.hpp:35:14: error: 'const class utility::moving_average<float, 5u>' has no member named 'size'
    average<T>(this->buf, this->size);
              ^
include/utility/filter.hpp:36:3: warning: no return statement in function returning non-void [-Wreturn-type]
   }
   ^
/* main.cpp */
#include <Arduino.h>
#include "SparkFunBME280.h" 
#include <utility/filter.hpp>

 namespace global {
    BME280 altsensor;
    utility::moving_average<float, 5> altitude_average_filter;
 }

void setup(){
    Serial.begin(9600);
}

void loop(){
    if(open_by_BME280()) Serial.println("OPENbyBME280_[SUCCESS]");
}

bool open_by_BME280(){
    int limit_counter = 0;
    float altitude_old = 10000000000.0;
    for(int i = 0; i < 5; i++){
        const auto al = global::altsensor.readFloatAltitudeMeters();
        global::altitude_average_filter.add_data(al);

        const auto altitude_new = global::altitude_average_filter.filtered();
        if(global::altitude_average_filter.filtered() <  altitude_old){
            limit_counter++;
        }else{
            limit_counter = 0;
        }
        altitude_old = altitude_new;
    }
    if(limit_counter >= 5) return true;
    return false;
}

実行環境

備考

sksat commented 5 years ago

確認しました.僕のミスです.修正します.

sksat commented 5 years ago

10 にて修正を行いました.