RoboidControl-cpp/DistanceSensor.h
2023-12-05 12:39:12 +01:00

36 lines
1005 B
C++

#pragma once
#include "Sensor.h"
namespace Passer {
namespace RoboidControl {
/// @brief A Sensor which can measure the distance to the nearest object
class DistanceSensor : public Sensor {
public:
/// @brief Default constructor
DistanceSensor();
/// @brief Creates a DistanceSensor with the given trigger distance
/// @param triggerDistance The distance at which the sensors indicates that a
/// object is close by
DistanceSensor(float triggerDistance);
/// @brief Determine the distance to the nearest object
/// @return the measured distance in meters to the nearest object
virtual float GetDistance();
/// @brief The distance at which ObjectNearby triggers
float triggerDistance = 1;
/// @brief Indicate that an object is nearby
/// @return True when an object is nearby
bool ObjectNearby();
protected:
/// @brief Distance to the closest object
float distance = 0;
};
} // namespace RoboidControl
} // namespace Passer
using namespace Passer::RoboidControl;