TinyRobotics
Loading...
Searching...
No Matches
ISpeedSource.h
1#pragma once
2#include "TinyRobotics/units/Units.h"
3
4namespace tinyrobotics {
5
6/**
7 * @brief Interface for speed sources.
8 */
9class ISpeedSource {
10 public:
11 virtual ~ISpeedSource() = default;
12 /**
13 * @brief Get the current speed.
14 * @return Speed value (with units)
15 */
16
17 virtual Speed getSpeed(uint8_t motor = 0) const = 0;
18
19
20 /// Publish actual speed for a specific motor
21 virtual void setThrottlePercent(float value, uint8_t motor = 0) = 0;
22
23
24 /// For sources with inertia, call this in your main loop with the elapsed time (in milliseconds) to update the speed estimate for a specific motor.
25 virtual Speed updateSpeed(uint32_t deltaTimeMs, uint8_t motor = 0) = 0;
26
27 virtual size_t getMotorCount() const = 0;
28};
29
30} // namespace tinyrobotics
Interface for speed sources.
Definition: ISpeedSource.h:9
virtual Speed getSpeed(uint8_t motor=0) const =0
Get the current speed.
virtual void setThrottlePercent(float value, uint8_t motor=0)=0
Publish actual speed for a specific motor.
virtual Speed updateSpeed(uint32_t deltaTimeMs, uint8_t motor=0)=0
For sources with inertia, call this in your main loop with the elapsed time (in milliseconds) to upda...
Represents a speed measurement with unit conversion support.
Definition: Speed.h:40