|
libstp
Robotics library for Botball
|
#include <Motor.hpp>
Public Member Functions | |
| Motor (int port, bool inverted, const foundation::MotorCalibration &calibration={}) | |
| ~Motor () override | |
| void | setSpeed (int percent) override |
| Open-loop percent output in the range expected by the platform driver. | |
| void | setVelocity (int velocity) override |
| Closed-loop velocity target in firmware-specific BEMF units. | |
| void | moveToPosition (int velocity, int goalPosition) override |
| Closed-loop absolute move in firmware-specific position units. | |
| void | moveRelative (int velocity, int deltaPosition) override |
| Closed-loop relative move in firmware-specific position units. | |
| 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. | |
| bool | isDone () const override |
| Return whether the last position command has completed. | |
| void | brake () override |
| Actively stop this motor using the platform's safest available path. | |
| void | off () override |
| Disable this motor completely (no power, no brake — free-spinning). | |
| void | resetPositionCounter () override |
| Reset the position counter to zero. | |
| const foundation::MotorCalibration & | getCalibration () const override |
| void | setCalibration (const foundation::MotorCalibration &calibration) override |
| int | getPort () const override |
| bool | isInverted () const override |
| void | setFirmwarePidGains (float kp, float ki, float kd) override |
| void | setSimulatedBemfResponse (int steady_state_bemf, double time_constant_s) |
| void | clearSimulatedBemfResponse () |
| Disable the simulated BEMF response (mock platform only). | |
| void | getLastFirmwarePidGains (float &kp, float &ki, float &kd) const override |
| Public Member Functions inherited from libstp::hal::motor::IMotor | |
| virtual | ~IMotor ()=default |
Static Public Member Functions | |
| static void | disableAll () |
| Put every motor managed by the active platform into its disabled state. | |
| static void | enableAll () |
| Re-enable globally disabled motors when the platform supports it. | |
Concrete motor wrapper whose method bodies are provided by the selected platform bundle.
The public contract here is what higher-level modules and Python bindings program against. Shared process-wide safety behavior, such as duplicate port tracking and fail-safe shutdown hooks, lives in libstp-hal.
|
explicit |
Construct a motor on the given port.
inverted flips command and feedback sign conventions so callers can keep chassis-level logic independent of wiring direction.
|
override |
|
overridevirtual |
Actively stop this motor using the platform's safest available path.
Implements libstp::hal::motor::IMotor.
| void libstp::hal::motor::Motor::clearSimulatedBemfResponse | ( | ) |
Disable the simulated BEMF response (mock platform only).
|
static |
Put every motor managed by the active platform into its disabled state.
|
static |
Re-enable globally disabled motors when the platform supports it.
|
nodiscardoverridevirtual |
Return the driver's current BEMF or velocity-like feedback value.
Implements libstp::hal::motor::IMotor.
|
nodiscardoverridevirtual |
Implements libstp::hal::motor::IMotor.
|
overridevirtual |
Read back the gains most recently passed to setFirmwarePidGains(). Useful for asserting tuner behavior in unit tests.
Reimplemented from libstp::hal::motor::IMotor.
|
inlinenodiscardoverridevirtual |
Implements libstp::hal::motor::IMotor.
|
nodiscardoverridevirtual |
Return the current motor position using the driver's sign convention.
Implements libstp::hal::motor::IMotor.
|
nodiscardoverridevirtual |
Return whether the last position command has completed.
Implements libstp::hal::motor::IMotor.
|
inlinenodiscardoverridevirtual |
Implements libstp::hal::motor::IMotor.
|
overridevirtual |
Closed-loop relative move in firmware-specific position units.
Implements libstp::hal::motor::IMotor.
|
overridevirtual |
Closed-loop absolute move in firmware-specific position units.
Implements libstp::hal::motor::IMotor.
|
overridevirtual |
Disable this motor completely (no power, no brake — free-spinning).
Implements libstp::hal::motor::IMotor.
|
overridevirtual |
Reset the position counter to zero.
Implements libstp::hal::motor::IMotor.
|
overridevirtual |
Implements libstp::hal::motor::IMotor.
|
overridevirtual |
Push per-motor firmware-side velocity PID gains.
On wombat this publishes to the STM32; on the mock platform the gains are stored for getLastFirmwarePidGains().
Reimplemented from libstp::hal::motor::IMotor.
| void libstp::hal::motor::Motor::setSimulatedBemfResponse | ( | int | steady_state_bemf, |
| double | time_constant_s ) |
Configure a simulated first-order BEMF step response. When active (mock platform only), getBemf() returns steady_state * (1 - exp(-t / time_constant_s)) where t is the time since the last setVelocity() call.
|
overridevirtual |
Open-loop percent output in the range expected by the platform driver.
Implements libstp::hal::motor::IMotor.
|
overridevirtual |
Closed-loop velocity target in firmware-specific BEMF units.
Implements libstp::hal::motor::IMotor.