TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
AccelerometerObstacleDetector Class Reference

Simple obstacle detector using accelerometer data. More...

#include <AccelerometerObstacleDetector.h>

Inheritance diagram for AccelerometerObstacleDetector:
Inheritance graph
[legend]
Collaboration diagram for AccelerometerObstacleDetector:
Collaboration graph
[legend]

Public Member Functions

 AccelerometerObstacleDetector (float threshold=3.0f)
 Construct with a deceleration threshold.
 
void update (float ax, float ay, float az)
 Update the detector with new acceleration values. Checks for sudden deceleration.
 
void setThreshold (float t)
 Set the deceleration threshold (m/s^2).
 
- 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.
 

Protected Attributes

float threshold
 
float lastMagnitude = 0.0f
 
- Protected Attributes inherited from MessageSource
std::vector< MessageHandlerEntrymessageHandlers_
 

Detailed Description

Simple obstacle detector using accelerometer data.

Detects sudden deceleration (collision/obstacle) events by monitoring the X/Y/Z acceleration. When a deceleration above a threshold is detected, a callback (with user data) or message is triggered.

Usage Example

AccelerometerObstacleDetector detector(3.0f); // 3 m/s^2 threshold
detected!"); }, nullptr); void loop() { detector.update(ax, ay, az); }
Simple obstacle detector using accelerometer data.
Definition: AccelerometerObstacleDetector.h:26

Constructor & Destructor Documentation

◆ AccelerometerObstacleDetector()

AccelerometerObstacleDetector ( float  threshold = 3.0f)
inline

Construct with a deceleration threshold.

Parameters
thresholdDeceleration threshold (m/s^2)

Member Function Documentation

◆ update()

void update ( float  ax,
float  ay,
float  az 
)
inline

Update the detector with new acceleration values. Checks for sudden deceleration.

Parameters
axAcceleration in X (m/s^2)
ayAcceleration in Y (m/s^2)
azAcceleration in Z (m/s^2)

The documentation for this class was generated from the following file: