Add GetDistance(angle)
This commit is contained in:
parent
2ff984b5bc
commit
bcbec5da32
12
Sensing.cpp
12
Sensing.cpp
@ -164,4 +164,16 @@ bool Sensing::SwitchOn(float fromAngle, float toAngle) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float Sensing::GetDistance(float angle) {
|
||||
for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
|
||||
Placement placement = sensorPlacements[sensorIx];
|
||||
float placementAngle = placement.direction.x;
|
||||
if (placementAngle == angle) {
|
||||
DistanceSensor* distanceSensor = (DistanceSensor*)placement.thing;
|
||||
return distanceSensor->GetDistance();
|
||||
}
|
||||
}
|
||||
return INFINITY;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Sensor.h"
|
||||
#include "Placement.h"
|
||||
#include "Sensor.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
@ -20,6 +20,9 @@ struct SensorPlacement {
|
||||
SensorPlacement(Switch* switchSensor, Vector2 direction);
|
||||
};
|
||||
|
||||
// class Perception : public Sensing {
|
||||
// }
|
||||
|
||||
class Sensing {
|
||||
public:
|
||||
/// @brief Setup sensing
|
||||
@ -65,6 +68,7 @@ class Sensing {
|
||||
float DistanceDown(float angle);
|
||||
|
||||
float Distance(float leftAngle, float rightAngle);
|
||||
float GetDistance(float angle);
|
||||
|
||||
bool SwitchOn(float fromAngle, float toAngle);
|
||||
|
||||
@ -73,3 +77,5 @@ class Sensing {
|
||||
Placement* sensorPlacements = nullptr;
|
||||
unsigned int sensorCount = 0;
|
||||
};
|
||||
|
||||
using Perception = Sensing;
|
||||
|
Loading…
x
Reference in New Issue
Block a user