|
TinyRobotics
|
Estimates speed from throttle with acceleration/inertia modeling (for boats, etc). More...
#include <SpeedFromThrottleWithInertia.h>


Public Member Functions | |
| SpeedFromThrottleWithInertia (float maxSpeedMps, float accelerationMps2, uint8_t numMotors=1) | |
| SpeedFromThrottleWithInertia (Speed maxSpeed, float accelerationMps2, uint8_t numMotors=1) | |
| void | setAcceleration (float a) |
| float | getAcceleration () const |
| void | setThrottlePercent (float throttle, uint8_t motor=0) override |
| Define the actual throttle value. | |
| void | setSpeedInstant (float speed, uint8_t motor=0) |
| Speed | getSpeed (uint8_t motor=0) const override |
| Get the actual speed based on the last throttle value. | |
| Speed | updateSpeed (uint32_t deltaTimeMs, uint8_t motor=0) override |
| 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. | |
Public Member Functions inherited from SpeedFromThrottle | |
| SpeedFromThrottle (float maxSpeedMps, uint8_t numMotors=1) | |
| SpeedFromThrottle (Speed maxSpeed, uint8_t numMotors=1) | |
| void | setMaxSpeed (Speed speed) |
| bool | onMessage (const Message< float > &msg) override |
| Handle Throttle messages to update speed. | |
| void | addSpeedCalibration (float throttlePercent, float speedMps) |
| Add or update a calibration point (throttlePercent, speedMps) | |
| void | clearCalibration () |
| Clear all calibration data. | |
| void | setThrottlePercent (float throttlePercent, uint8_t motor=0) override |
| Define the actual throttle value. | |
| Speed | getSpeed (uint8_t motor=0) const override |
| Get the actual speed based on the last throttle value. | |
| Speed | updateSpeed (uint32_t deltaTimeMs, uint8_t motor=0) override |
| 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. | |
| size_t | getMotorCount () const override |
Public Member Functions inherited from MessageSource | |
| void | subscribe (MessageHandler &handler, MessageOrigin origin=MessageOrigin::Undefined, MessageContent content=MessageContent::Undefined) |
| Subscribe a message handler to this source, with optional filtering. | |
| void | unsubscribeAll () |
| Remove all registered message handlers. | |
| void | sendMessage (Message< float > &msg) |
| Publish a message to all registered handlers. | |
| void | sendMessage (const Message< Coordinate< float > > &msg) |
| Publish a message to all registered handlers. | |
| void | sendMessage (const Message< GPSCoordinate > &msg) |
| Publish a message to all registered handlers. | |
| void | sendMessage (const Message< MotionState3D > &msg) |
| Overload for MotionState3D messages. | |
Public Member Functions inherited from MessageHandler | |
| virtual bool | onMessage (const Message< float > &msg)=0 |
| Handle an incoming message (pure virtual). | |
| virtual bool | onMessage (const Message< Coordinate< float > > &msg) |
| virtual bool | onMessage (const Message< GPSCoordinate > &msg) |
| virtual bool | onMessage (const Message< MotionState3D > &msg) |
| 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 update the speed estimate for a specific motor. | |
| virtual size_t | getMotorCount () const =0 |
Protected Attributes | |
| float | acceleration |
| std::vector< float > | throttlePercent |
| std::vector< unsigned long > | lastUpdateMs |
Protected Attributes inherited from SpeedFromThrottle | |
| std::vector< std::pair< float, float > > | calibrationData |
| std::vector< float > | speedMps |
| uint8_t | numMotors = 1 |
| float | maxSpeedMps = 0.0f |
Protected Attributes inherited from MessageSource | |
| std::vector< MessageHandlerEntry > | messageHandlers_ |
Additional Inherited Members | |
Protected Member Functions inherited from SpeedFromThrottle | |
| bool | init () |
| void | sendSpeedMessage (uint8_t motor=0) |
| float | getSpeedMPS (float throttlePercent) const |
| Get speed in meters per second by interpolating calibration data. | |
Estimates speed from throttle with acceleration/inertia modeling (for boats, etc).
This class extends SpeedFromThrottle by simulating acceleration/inertia:
Example usage:
|
inlineoverridevirtual |
Get the actual speed based on the last throttle value.
Reimplemented from SpeedFromThrottle.
|
inlineoverridevirtual |
Define the actual throttle value.
Reimplemented from SpeedFromThrottle.
|
inlineoverridevirtual |
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.
Reimplemented from SpeedFromThrottle.