libstp
Robotics library for Botball
Loading...
Searching...
No Matches
firmware_pid_tune.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <string>
5#include <vector>
6
7#include "autotune/types.hpp"
8#include "hal/IIMU.hpp"
9#include "hal/IMotor.hpp"
10
11namespace libstp::autotune
12{
26 {
27 public:
34 explicit FirmwarePidTuner(const std::vector<hal::motor::IMotor*>& motors,
35 hal::imu::IIMU* imu = nullptr);
36
47 hal::motor::IMotor* motor,
48 int max_bemf_speed,
49 const FirmwarePidConfig& cfg) const;
50
61 [[nodiscard]] std::map<int, FirmwarePidResult> tune(
62 const std::map<int, int>& max_bemf_speeds,
63 const FirmwarePidConfig& cfg) const;
64
65 private:
79 [[nodiscard]] StepResponseData runStepResponse(
80 hal::motor::IMotor* motor,
81 int bemf_target,
82 double duration_s,
83 int sample_hz,
84 const std::string& csv_path = "") const;
85
102 [[nodiscard]] std::vector<StepResponseData> runParallelStepResponse(
103 const std::vector<hal::motor::IMotor*>& motors,
104 const std::vector<int>& bemf_targets,
105 double duration_s,
106 int sample_hz) const;
107
108 std::vector<hal::motor::IMotor*> motors_;
109 hal::imu::IIMU* imu_{nullptr};
110 };
111
112} // namespace libstp::autotune
FirmwarePidTuner(const std::vector< hal::motor::IMotor * > &motors, hal::imu::IIMU *imu=nullptr)
std::map< int, FirmwarePidResult > tune(const std::map< int, int > &max_bemf_speeds, const FirmwarePidConfig &cfg) const
Tune every motor passed at construction.
FirmwarePidResult tuneMotor(hal::motor::IMotor *motor, int max_bemf_speed, const FirmwarePidConfig &cfg) const
Tune a single motor.
Configuration for the FirmwarePidTuner.
Definition types.hpp:216
Result of tuning a single motor's firmware-side velocity PID.
Definition types.hpp:291
Raw step-response recording for one velocity axis.
Definition types.hpp:56
Interface for IMU abstraction.
Definition IIMU.hpp:97
Interface for motor abstraction.
Definition IMotor.hpp:17