Cleanup
This commit is contained in:
parent
47dbbc5b61
commit
3e969a3939
140
Perception.cpp
140
Perception.cpp
@ -24,118 +24,6 @@ Sensor *Perception::GetSensor(unsigned int sensorId) {
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
float Perception::DistanceForward(float angle) {
|
|
||||||
float minDistance = INFINITY;
|
|
||||||
for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
|
|
||||||
Placement placement = sensorPlacements[sensorIx];
|
|
||||||
Sensor* sensor = (Sensor*)placement.thing;
|
|
||||||
if (sensor->IsSensor())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
DistanceSensor* distanceSensor = (DistanceSensor*)placement.thing;
|
|
||||||
if (placement.verticalDirection > -angle &&
|
|
||||||
placement.verticalDirection < angle &&
|
|
||||||
placement.horizontalDirection > -angle &&
|
|
||||||
placement.horizontalDirection < angle) {
|
|
||||||
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return minDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Perception::DistanceLeft(float angle) {
|
|
||||||
float minDistance = INFINITY;
|
|
||||||
for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
|
|
||||||
Placement placement = sensorPlacements[sensorIx];
|
|
||||||
Sensor* sensor = (Sensor*)placement.thing;
|
|
||||||
if (sensor->IsSensor())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
DistanceSensor* distanceSensor = (DistanceSensor*)placement.thing;
|
|
||||||
float sensorAngle = placement.horizontalDirection;
|
|
||||||
if (sensorAngle < 0 && sensorAngle > -angle) {
|
|
||||||
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return minDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Perception::DistanceRight(float angle) {
|
|
||||||
float minDistance = INFINITY;
|
|
||||||
for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
|
|
||||||
Placement placement = sensorPlacements[sensorIx];
|
|
||||||
Sensor* sensor = (Sensor*)placement.thing;
|
|
||||||
if (sensor->type != Thing::DistanceSensorType)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
DistanceSensor* distanceSensor = (DistanceSensor*)placement.thing;
|
|
||||||
float sensorAngle = placement.horizontalDirection;
|
|
||||||
if (sensorAngle > 0 && sensorAngle < angle) {
|
|
||||||
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return minDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Perception::DistanceUp(float angle) {
|
|
||||||
float minDistance = INFINITY;
|
|
||||||
for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
|
|
||||||
Placement placement = sensorPlacements[sensorIx];
|
|
||||||
Sensor* sensor = (Sensor*)placement.thing;
|
|
||||||
if (sensor->IsSensor())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
DistanceSensor* distanceSensor = (DistanceSensor*)placement.thing;
|
|
||||||
float sensorAngle = placement.verticalDirection;
|
|
||||||
if (sensorAngle > 0 && sensorAngle < angle) {
|
|
||||||
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return minDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Perception::DistanceDown(float angle) {
|
|
||||||
float minDistance = INFINITY;
|
|
||||||
for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
|
|
||||||
Placement placement = sensorPlacements[sensorIx];
|
|
||||||
Sensor* sensor = (Sensor*)placement.thing;
|
|
||||||
if (sensor->IsSensor())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
DistanceSensor* distanceSensor = (DistanceSensor*)placement.thing;
|
|
||||||
float sensorAngle = placement.verticalDirection;
|
|
||||||
if (sensorAngle < 0 && sensorAngle > -angle) {
|
|
||||||
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return minDistance;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// float Perception::GetDistance(float fromAngle, float toAngle) {
|
|
||||||
// float minDistance = INFINITY;
|
|
||||||
// if (toAngle < fromAngle)
|
|
||||||
// // Hmm. Can't look backward properly for now
|
|
||||||
// return minDistance;
|
|
||||||
|
|
||||||
// for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
|
|
||||||
// Placement placement = sensorPlacements[sensorIx];
|
|
||||||
// float angle = placement.horizontalDirection;
|
|
||||||
// if (angle > fromAngle && angle < toAngle) {
|
|
||||||
// Thing* thing = placement.thing;
|
|
||||||
// if (thing == nullptr)
|
|
||||||
// continue;
|
|
||||||
|
|
||||||
// if (thing->type == Thing::DistanceSensorType) {
|
|
||||||
// DistanceSensor* distanceSensor = (DistanceSensor*)thing;
|
|
||||||
// if (distanceSensor != nullptr && distanceSensor->ObjectNearby())
|
|
||||||
// minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return minDistance;
|
|
||||||
// }
|
|
||||||
|
|
||||||
float Perception::GetDistance(float direction, float range) {
|
float Perception::GetDistance(float direction, float range) {
|
||||||
float minDistance = INFINITY;
|
float minDistance = INFINITY;
|
||||||
@ -160,34 +48,6 @@ float Perception::GetDistance(float direction, float range) {
|
|||||||
}
|
}
|
||||||
return minDistance;
|
return minDistance;
|
||||||
}
|
}
|
||||||
// float Perception::GetDistance(float fromHorizontalAngle,
|
|
||||||
// float toHorizontalAngle, float
|
|
||||||
// fromVerticalAngle, float toVerticalAngle) {
|
|
||||||
// float minDistance = INFINITY;
|
|
||||||
// if (toHorizontalAngle < fromHorizontalAngle ||
|
|
||||||
// toVerticalAngle < fromVerticalAngle)
|
|
||||||
// // Hmm. Can't look backward properly for now
|
|
||||||
// return minDistance;
|
|
||||||
|
|
||||||
// for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
|
|
||||||
// Placement placement = sensorPlacements[sensorIx];
|
|
||||||
// if (placement.horizontalDirection > fromHorizontalAngle &&
|
|
||||||
// placement.horizontalDirection < toHorizontalAngle &&
|
|
||||||
// placement.verticalDirection > fromVerticalAngle &&
|
|
||||||
// placement.verticalDirection < toVerticalAngle) {
|
|
||||||
// Thing *thing = placement.thing;
|
|
||||||
// if (thing == nullptr)
|
|
||||||
// continue;
|
|
||||||
|
|
||||||
// if (thing->type == Thing::DistanceSensorType) {
|
|
||||||
// DistanceSensor *distanceSensor = (DistanceSensor *)thing;
|
|
||||||
// if (distanceSensor != nullptr && distanceSensor->ObjectNearby())
|
|
||||||
// minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return minDistance;
|
|
||||||
// }
|
|
||||||
|
|
||||||
float Perception::GetDistance(float horizontalDirection,
|
float Perception::GetDistance(float horizontalDirection,
|
||||||
float verticalDirection, float range) {
|
float verticalDirection, float range) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user