RoboidControl-cpp/DistanceSensor.h
Pascal Serrarens 189ea6c689 Initial commit
2023-11-06 14:24:18 +01:00

25 lines
586 B
C++

#pragma once
#include "Sensor.h"
/// @brief A sensor which can measure the distance the the nearest object
class DistanceSensor : public Sensor {
public:
/// @brief Determine the distance to the nearest object
/// @return the measured distance in meters to the nearest object
virtual float GetDistance() = 0;
/// @brief The distance at which ObjectNearby triggers
float triggerDistance = 1;
bool IsOn() {
bool isOn = GetDistance() <= triggerDistance;
return isOn;
}
bool isOff() {
bool isOff = GetDistance() > triggerDistance;
return isOff;
}
};