21#ifdef SAFETY_CHECKS_ENABLED
22 static inline detail::PortRegistry registry_{};
24 static void registerMotorPort(
int port);
26 static void unregisterMotorPort(
int port);
51 [[nodiscard]]
int getBemf()
const override;
53 [[nodiscard]]
bool isDone()
const override;
64 [[nodiscard]]
int getPort()
const override {
return port_; }
65 [[nodiscard]]
bool isInverted()
const override {
return inverted_; }
106 bool sim_active_{
false};
107 int sim_steady_state_{0};
108 double sim_time_constant_s_{0.1};
109 std::chrono::steady_clock::time_point sim_t_ref_{};
111 float last_fw_kp_{0.0f};
112 float last_fw_ki_{0.0f};
113 float last_fw_kd_{0.0f};
const foundation::MotorCalibration & getCalibration() const override
bool isDone() const override
Return whether the last position command has completed.
void setSimulatedBemfResponse(int steady_state_bemf, double time_constant_s)
void brake() override
Actively stop this motor using the platform's safest available path.
Motor(int port, bool inverted, const foundation::MotorCalibration &calibration={})
void clearSimulatedBemfResponse()
Disable the simulated BEMF response (mock platform only).
static void disableAll()
Put every motor managed by the active platform into its disabled state.
void moveRelative(int velocity, int deltaPosition) override
Closed-loop relative move in firmware-specific position units.
void moveToPosition(int velocity, int goalPosition) override
Closed-loop absolute move in firmware-specific position units.
bool isInverted() const override
static void enableAll()
Re-enable globally disabled motors when the platform supports it.
void setVelocity(int velocity) override
Closed-loop velocity target in firmware-specific BEMF units.
void setCalibration(const foundation::MotorCalibration &calibration) override
void off() override
Disable this motor completely (no power, no brake — free-spinning).
void getLastFirmwarePidGains(float &kp, float &ki, float &kd) const override
void resetPositionCounter() override
Reset the position counter to zero.
int getPort() const override
int getPosition() const override
Return the current motor position using the driver's sign convention.
int getBemf() const override
Return the driver's current BEMF or velocity-like feedback value.
void setSpeed(int percent) override
Open-loop percent output in the range expected by the platform driver.
void setFirmwarePidGains(float kp, float ki, float kd) override
Calibration constants commonly needed for motor encoder conversions.
Interface for motor abstraction.