interface changes

added new data-strcutures for new sensors
new helper methods
fixed some issues
This commit is contained in:
2017-05-24 09:23:27 +02:00
parent f67f95d1ce
commit d40032ca74
29 changed files with 471 additions and 68 deletions

View File

@@ -46,28 +46,62 @@ namespace Floorplan {
}
/** get the number of ceilings between z1 and z2 */
float numCeilingsBetweenFloat(const Point3 pos1, const Point3 pos2) const {
std::vector<float> getCeilings() const {
return ceilingsAtHeight_m;
}
void addCeiling(const float height_m) {
ceilingsAtHeight_m.push_back(height_m);
}
void clear() {
ceilingsAtHeight_m.clear();
}
/** get a fading number of floors between ap and person using sigmod in the area where the ceiling is */
float numCeilingsBetweenFloat(const Point3 ap, const Point3 person) const {
// sanity checks
Assert::isNot0(ceilingsAtHeight_m.size(), "no ceilings available for testing! incorrect map?");
const float zMin = std::min(pos1.z, pos2.z);
const float zMax = std::max(pos1.z, pos2.z);
// fading between floors using sigmoid
const float near = 1.0;
float cnt = 0;
for (const float z : ceilingsAtHeight_m) {
if (zMin < z && zMax > z) {
const float dmax = zMax - z;
cnt += (dmax > 1) ? (1) : (dmax);
const float myDistToCeil = (ap.z < person.z) ? (person.z - z) : (z - person.z);
if ( std::abs(myDistToCeil) < near ) {
cnt += sigmoid(myDistToCeil * 6);
} else if (ap.z < z && person.z >= z+near) { // AP below celing, me above ceiling
cnt += 1;
} else if (ap.z > z && person.z <= z-near) { // AP above ceiling, me below ceiling
cnt += 1;
}
}
return cnt;
}
float numCeilingsBetweenLinearInt(const Point3 ap, const Point3 person) const {
// sanity checks
Assert::isNot0(ceilingsAtHeight_m.size(), "no ceilings available for testing! incorrect map?");
int cnt = 0;
float sum = 0;
for (float z = -1.0; z <= +1.0; z+= 0.25) {
sum += numCeilingsBetween(ap, person + Point3(0,0,z));
++cnt;
}
return sum/cnt;
}
/** get the number of ceilings between z1 and z2 */
int numCeilingsBetween(const Point3 pos1, const Point3 pos2) const {
@@ -80,14 +114,14 @@ namespace Floorplan {
#ifdef WITH_ASSERTIONS
static int numNear = 0;
static int numFar = 0;
static size_t numNear = 0;
static size_t numFar = 0;
for (const float z : ceilingsAtHeight_m) {
const float diff = std::min( std::abs(z-zMin), std::abs(z-zMax) );
if (diff < 0.1) {++numNear;} else {++numFar;}
}
if ((numNear + numFar) > 150000) {
Assert::isTrue(numNear < numFar*0.15,
Assert::isTrue(numNear < numFar*0.5,
"many requests to Floorplan::Ceilings::numCeilingsBetween address nodes (very) near to a ground! \
due to rounding issues, determining the number of floors between AP and point-in-question is NOT possible! \
expect very wrong outputs! \
@@ -105,6 +139,12 @@ namespace Floorplan {
}
private:
static inline float sigmoid(const float val) {
return 1.0f / (1.0f + std::exp(-val));
}
};
}

View File

@@ -97,6 +97,11 @@ namespace Floorplan {
checkStair(res, floor, s);
}
// check elevators
for (const Elevator* e : floor->elevators) {
checkElevator(res, floor, e);
}
}
// done
@@ -190,7 +195,7 @@ namespace Floorplan {
for (int i = 0; i < (int) parts.size(); ++i) {
const Floorplan::Quad3& quad = quads[i];
//const Floorplan::Quad3& quad = quads[i];
// disconnected within?
if (i > 0) {
@@ -201,7 +206,17 @@ namespace Floorplan {
}
}
static void checkElevator(Issues& res, const Floor* floor, const Elevator* e) {
if (e->depth < 0.5) {
res.push_back(Issue(Type::ERROR, floor, "elevator's depth @" + e->center.asString() + " is too small: " + std::to_string(e->depth) + "m"));
}
if (e->width < 0.5) {
res.push_back(Issue(Type::ERROR, floor, "elevator's width @" + e->center.asString() + " is too small: " + std::to_string(e->width) + "m"));
}
}