From 2948ec1c9365439fc0591b822e152f98ff876ac7 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Thu, 16 May 2024 23:44:25 -0500 Subject: [PATCH] feat: update to espp v0.8.0 --- components/espp | 2 +- main/main.cpp | 38 +++++++++----------------------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/components/espp b/components/espp index e423f93..74c3dd3 160000 --- a/components/espp +++ b/components/espp @@ -1 +1 @@ -Subproject commit e423f934efa44370036db48fc9498b8d16e792c9 +Subproject commit 74c3dd34eb3d656acfdaa2287489b1c0d11fb974 diff --git a/main/main.cpp b/main/main.cpp index 6ad8ba3..776e54c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -30,36 +30,16 @@ extern "C" void app_main(void) { // make the velocity filter static constexpr float core_update_period = 0.001f; // seconds - static constexpr float filter_cutoff_hz = 4.0f; - espp::ButterworthFilter<2, espp::BiquadFilterDf2> bwfilter({ - .normalized_cutoff_frequency = 2.0f * filter_cutoff_hz * 0.01 // core_update_period - }); - espp::LowpassFilter lpfilter( - {.normalized_cutoff_frequency = 2.0f * filter_cutoff_hz * 0.01, // core_update_period, - .q_factor = 1.0f}); - auto filter_fn = [&bwfilter, &lpfilter](float raw) -> float { - // return bwfilter.update(raw); - // return lpfilter.update(raw); - - // NOTE: right now there seems to be something wrong with the filter - // configuration, so we don't filter at all. Either 1) the filtering - // is not actually removing the noise we want, 2) it is adding too - // much delay for the PID to compensate for, or 3) there is a bug in - // the update function which doesn't take previous state into - // account? - return raw; - }; // now make the mt6701 which decodes the data - std::shared_ptr mt6701 = std::make_shared( - espp::Mt6701::Config{.write = std::bind(&espp::I2c::write, &i2c, std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3), - .read_register = std::bind(&espp::I2c::read_at_register, &i2c, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3, std::placeholders::_4), - .velocity_filter = filter_fn, - .update_period = std::chrono::duration(core_update_period), - .log_level = espp::Logger::Verbosity::WARN}); + using Encoder = espp::Mt6701<>; + std::shared_ptr mt6701 = std::make_shared( + Encoder::Config{.write = std::bind(&espp::I2c::write, &i2c, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3), + .read = std::bind(&espp::I2c::read, &i2c, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3), + .update_period = std::chrono::duration(core_update_period), + .log_level = espp::Logger::Verbosity::WARN}); // now make the bldc driver std::shared_ptr driver = std::make_shared( @@ -78,7 +58,7 @@ extern "C" void app_main(void) { .log_level = espp::Logger::Verbosity::WARN}); // now make the bldc motor - using BldcMotor = espp::BldcMotor; + using BldcMotor = espp::BldcMotor; auto motor = BldcMotor(BldcMotor::Config{ // measured by setting it into ANGLE_OPENLOOP and then counting how many // spots you feel when rotating it.