43 lines
1.2 KiB
C++
43 lines
1.2 KiB
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 minimum range at which the sensor gives reliable measurements
|
|
float minRange = 0.01F;
|
|
/// @brief The maximum range at which the sensor gives reliable measurements
|
|
float maxRange = 10.0F;
|
|
|
|
/// @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();
|
|
|
|
virtual void ProcessBytes(unsigned char *bytes) override;
|
|
|
|
protected:
|
|
/// @brief Distance to the closest object
|
|
float distance = 0;
|
|
};
|
|
|
|
} // namespace RoboidControl
|
|
} // namespace Passer
|
|
using namespace Passer::RoboidControl; |