#pragma once #include #include class DistanceSensor; class Switch; class NewSensorPlacement : public Placement { }; struct SensorPlacement { DistanceSensor* distanceSensor; Switch* switchSensor; Vector2 direction; SensorPlacement(DistanceSensor* distanceSensor, Vector2 direction); SensorPlacement(Switch* switchSensor, Vector2 direction); }; class Sensing { public: /// @brief Setup sensing Sensing(); // void AddSensors(SensorPlacement* sensors, unsigned int sensorCount); void AddSensors(Placement* sensors, unsigned int sensorCount); 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 Distance(float leftAngle, float rightAngle); bool SwitchOn(float fromAngle, float toAngle); protected: // SensorPlacement* sensors = nullptr; Placement* sensorPlacements = nullptr; unsigned int sensorCount = 0; };