TinyRobotics
Loading...
Searching...
No Matches
IMotor.h
1#pragma once
2
3#include "TinyRobotics/utils/Config.h"
4
5namespace tinyrobotics {
6
7/**
8 * @class IMotor
9 * @ingroup motors
10 * @brief Abstract base class for all motor driver types.
11 *
12 * The Motor class defines a common interface for all motor drivers in the
13 * library. It enforces the implementation of:
14 * - end(): to safely stop or release the motor hardware
15 * - isPinsSet(): to check if the required pins have been configured
16 *
17 * All specific motor driver classes (e.g., HBridge, ServoMotor) should inherit
18 * from Motor.
19 */
20template <typename T = float>
21class IMotor {
22 public:
23 IMotor() = default;
24 virtual bool begin() = 0;
25 virtual void end() = 0;
26 virtual bool isPinsSet() const = 0;
27 virtual bool setValuePercent(T percent) = 0;
28 virtual T getValuePercent() const = 0;
29 void setID(uint8_t id) { this->id = id; }
30 uint8_t getID() const { return id; }
31
32 protected:
33 uint8_t id = 0; // Optional ID for identifying the motor
34};
35
36} // namespace tinyrobotics
Abstract base class for all motor driver types.
Definition: IMotor.h:21