Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to espp v0.8.0 #9

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/espp
Submodule espp updated 86 files
+4 −0 .github/workflows/build.yml
+6 −1 .github/workflows/static_analysis.yml
+14 −0 components/base_component/include/base_component.hpp
+197 −157 components/base_peripheral/include/base_peripheral.hpp
+1 −0 components/bldc_driver/CMakeLists.txt
+23 −13 components/bldc_driver/include/bldc_driver.hpp
+3 −0 components/bldc_driver/src/bldc_driver.cpp
+1 −1 components/bldc_haptics/example/CMakeLists.txt
+11 −32 components/bldc_haptics/example/main/bldc_haptics_example.cpp
+1 −1 components/bldc_motor/example/CMakeLists.txt
+31 −50 components/bldc_motor/example/main/bldc_motor_example.cpp
+95 −22 components/bldc_motor/include/bldc_motor.hpp
+62 −0 components/bldc_motor/include/bldc_types.hpp
+20 −0 components/bldc_motor/include/sensor_direction.hpp
+2 −1 components/ble_gatt_server/example/main/ble_gatt_server_example.cpp
+73 −1 components/ble_gatt_server/include/ble_gatt_server.hpp
+75 −2 components/ble_gatt_server/include/ble_gatt_server_menu.hpp
+35 −1 components/ble_gatt_server/src/ble_gatt_server_callbacks.cpp
+11 −2 components/cli/CMakeLists.txt
+243 −35 components/cli/include/cli.hpp
+89 −10 components/cli/include/line_input.hpp
+5 −0 components/cli/src/cli.cpp
+1 −1 components/esp-nimble-cpp
+2 −1 components/event_manager/src/event_manager.cpp
+90 −0 components/filters/include/simple_lowpass_filter.hpp
+2 −0 components/gfps_service/CMakeLists.txt
+2 −1 components/gfps_service/example/main/gfps_service_example.cpp
+1 −1 components/gfps_service/include/gfps.hpp
+4 −4 components/gfps_service/include/gfps_service.hpp
+6 −0 components/gfps_service/src/gfps_service.cpp
+16 −12 components/gfps_service/src/nearby_platform.cpp
+3 −2 components/hid-rp/example/main/hid_rp_example.cpp
+20 −18 components/hid-rp/include/hid-rp-gamepad.hpp
+5 −3 components/hid_service/example/main/hid_service_example.cpp
+12 −28 components/i2c/include/i2c.hpp
+4 −22 components/interrupt/include/interrupt.hpp
+8 −1 components/joystick/include/joystick.hpp
+2 −2 components/led/include/led.hpp
+15 −1 components/logger/include/logger.hpp
+1 −1 components/math/example/CMakeLists.txt
+118 −31 components/math/example/main/math_example.cpp
+14 −0 components/math/include/bezier.hpp
+68 −2 components/math/include/fast_math.hpp
+3 −0 components/math/include/gaussian.hpp
+57 −19 components/math/include/range_mapper.hpp
+33 −13 components/math/include/vector2d.hpp
+1 −1 components/monitor/CMakeLists.txt
+0 −8 components/monitor/example/main/monitor_example.cpp
+58 −25 components/monitor/include/task_monitor.hpp
+4 −0 components/motorgo-mini/CMakeLists.txt
+21 −0 components/motorgo-mini/example/CMakeLists.txt
+41 −0 components/motorgo-mini/example/README.md
+2 −0 components/motorgo-mini/example/main/CMakeLists.txt
+193 −0 components/motorgo-mini/example/main/motorgo_mini_example.cpp
+24 −0 components/motorgo-mini/example/sdkconfig.defaults
+521 −0 components/motorgo-mini/include/motorgo-mini.hpp
+1 −1 components/mt6701/CMakeLists.txt
+1 −1 components/mt6701/example/CMakeLists.txt
+62 −1 components/mt6701/example/main/Kconfig.projbuild
+157 −15 components/mt6701/example/main/mt6701_example.cpp
+247 −66 components/mt6701/include/mt6701.hpp
+4 −0 components/nvs/CMakeLists.txt
+23 −0 components/nvs/example/CMakeLists.txt
+23 −0 components/nvs/example/README.md
+2 −0 components/nvs/example/main/CMakeLists.txt
+43 −0 components/nvs/example/main/nvs_example.cpp
+4 −0 components/nvs/example/partitions.csv
+9 −0 components/nvs/example/sdkconfig.defaults
+208 −0 components/nvs/include/nvs.hpp
+17 −10 components/pid/include/pid.hpp
+37 −0 components/task/example/main/task_example.cpp
+91 −1 components/task/include/task.hpp
+4 −2 components/timer/example/main/timer_example.cpp
+21 −14 components/timer/include/high_resolution_timer.hpp
+5 −0 doc/Doxyfile
+1 −0 doc/en/filters/index.rst
+12 −0 doc/en/filters/simple_lowpass.rst
+2 −0 doc/en/index.rst
+5 −0 doc/en/math/fast_math.rst
+21 −0 doc/en/motorgo_mini.rst
+16 −0 doc/en/nvs.rst
+1 −1 external/alpaca
+3 −0 lib/CMakeLists.txt
+12 −6 lib/bind.cpp
+3 −2 python/task.py
+3 −2 python/udp_client.py
38 changes: 9 additions & 29 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<espp::Mt6701> mt6701 = std::make_shared<espp::Mt6701>(
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<float>(core_update_period),
.log_level = espp::Logger::Verbosity::WARN});
using Encoder = espp::Mt6701<>;
std::shared_ptr<Encoder> mt6701 = std::make_shared<Encoder>(
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<float>(core_update_period),
.log_level = espp::Logger::Verbosity::WARN});

// now make the bldc driver
std::shared_ptr<espp::BldcDriver> driver = std::make_shared<espp::BldcDriver>(
Expand All @@ -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<espp::BldcDriver, espp::Mt6701>;
using BldcMotor = espp::BldcMotor<espp::BldcDriver, Encoder>;
auto motor = BldcMotor(BldcMotor::Config{
// measured by setting it into ANGLE_OPENLOOP and then counting how many
// spots you feel when rotating it.
Expand Down
Loading