96 lines
3.4 KiB
C++
96 lines
3.4 KiB
C++
#pragma once
|
|
|
|
#include "Placement.h"
|
|
#include "Sensor.h"
|
|
|
|
namespace Passer {
|
|
namespace RoboidControl {
|
|
|
|
class Perception {
|
|
public:
|
|
/// @brief Setup perception
|
|
Perception();
|
|
|
|
/// @brief Template to make it possible to leave out ths sensorCount
|
|
/// @tparam sensorCount
|
|
/// @param sensors An array of sensor placements
|
|
template <unsigned int sensorCount>
|
|
inline Perception(Placement (&sensors)[sensorCount]) {
|
|
Perception(sensors, sensorCount);
|
|
}
|
|
Perception(Placement* sensors, unsigned int sensorCount);
|
|
|
|
void AddSensors(Placement* sensors, unsigned int sensorCount);
|
|
|
|
unsigned int GetSensorCount();
|
|
Sensor* GetSensor(unsigned int sensorId);
|
|
/*
|
|
float DistanceForward(float angle = 90);
|
|
|
|
/// @brief Distance to the closest object on the left
|
|
/// @return distance in meters, INFINITY when no object is detected.
|
|
/// @note An object is on the left when the `angle` is between -180 and 0
|
|
/// degrees.
|
|
/// @note An object dead straight (0 degrees) is not reported.
|
|
float DistanceLeft() { return DistanceLeft(180); }
|
|
/// @brief Distance to the closest object on the left
|
|
/// @param angle the maximum angle on the left used for detection.
|
|
/// @return distance in meters, INFINITY when no object is detected.
|
|
/// @note An object is on the left when the `angle` is between -`angle` and
|
|
0
|
|
/// degrees.
|
|
/// @note An object dead straight (0 degrees) is not reported.
|
|
/// @note When an object is beyond `angle` meters, it is not reported.
|
|
float DistanceLeft(float angle);
|
|
|
|
/// @brief Distance to the closest object on the right
|
|
/// @return distance in meters, INFINITY when no object is detected
|
|
/// @note An object is on the right when the `angle` is between 0 and 180
|
|
/// degrees
|
|
/// @note An object dead straight (0 degrees) is not reported
|
|
float DistanceRight() { return DistanceRight(180); }
|
|
/// @brief Distance to the closest object on the right
|
|
/// @param angle the maximum angle on the left used for detection.
|
|
/// @return distance in meters, INFINITY when no object is detected
|
|
/// @note An object is on the left when the `angle` is between 0 and `angle`
|
|
/// degrees.
|
|
/// @note An object dead straight (0 degrees) is not reported.
|
|
/// @note When an object is beyond `angle` meters, it is not reported.
|
|
float DistanceRight(float angle);
|
|
|
|
float DistanceUp() { return DistanceUp(180); }
|
|
float DistanceUp(float angle);
|
|
float DistanceDown() { return DistanceDown(180); }
|
|
float DistanceDown(float angle);
|
|
*/
|
|
float GetDistance(float fromAngle, float toAngle);
|
|
float GetDistance(float fromHorizontalAngle,
|
|
float toHorizontalAngle,
|
|
float fromVerticalAngle,
|
|
float toVerticalAngle);
|
|
// float GetDistance(float angle);
|
|
|
|
bool SwitchOn(float fromAngle, float toAngle);
|
|
|
|
void SetResolution(unsigned int resolution);
|
|
void SetRange(float min, float max);
|
|
float* GetDepthMap();
|
|
unsigned int ToDepthMapIndex(float angle);
|
|
void SetDepthMap(float angle, float distance);
|
|
|
|
Sensor* GetSensor(float angle);
|
|
|
|
protected:
|
|
// SensorPlacement* sensors = nullptr;
|
|
Placement* sensorPlacements = nullptr;
|
|
unsigned int sensorCount = 0;
|
|
|
|
unsigned int resolution;
|
|
float rangeMinimum;
|
|
float rangeMaximum;
|
|
float* depthMap = nullptr;
|
|
};
|
|
|
|
} // namespace RoboidControl
|
|
} // namespace Passer
|
|
using namespace Passer::RoboidControl; |