blob: e0fa28c7559ff8f0c6ea1594eecb411c4b17755f [file] [log] [blame]
Brian Silverman8d3816a2017-07-03 18:52:15 -07001#ifndef MOTORS_MOTOR_CONTROLS_H_
2#define MOTORS_MOTOR_CONTROLS_H_
3
4#include <array>
5#include <complex>
6
7#include "motors/math.h"
8#include "motors/motor.h"
9
10#include "Eigen/Dense"
11
12namespace frc971 {
13namespace salsa {
14
15class MotorControlsImplementation : public MotorControls {
16 public:
17 template <int kRows, int kCols>
18 using ComplexMatrix = ::Eigen::Matrix<::std::complex<float>, kRows, kCols>;
19
20 MotorControlsImplementation();
21 ~MotorControlsImplementation() override = default;
22
23 ::std::array<uint32_t, 3> DoIteration(const float raw_currents[3],
24 uint32_t theta,
25 const float command_current) override;
26
27 int16_t Debug(uint32_t theta) override;
28
29 float estimated_velocity() const override { return estimated_velocity_; }
30
31 private:
32 const ComplexMatrix<3, 1> E1Unrotated_, E2Unrotated_;
33
34 float estimated_velocity_ = 0;
35 float filtered_current_ = 0;
36
37 ::Eigen::Matrix<float, 3, 1> I_last_ = ::Eigen::Matrix<float, 3, 1>::Zero();
38
39 int16_t debug_[9];
40};
41
42} // namespace salsa
43} // namespace frc971
44
45#endif // MOTORS_MOTOR_CONTROLS_H_