Better distance calculations

This commit is contained in:
Nathan Kunicki 2018-06-14 17:23:55 +01:00
parent 056e7844ee
commit cf3d17e1f5
2 changed files with 3 additions and 3 deletions

View File

@ -284,7 +284,7 @@ class BoostHub extends Hub {
distance += 1 / partial; distance += 1 / partial;
} }
this.emit("distance", port.id, Math.floor(distance * 25.4)); this.emit("distance", port.id, Math.floor(distance * 25.4) - 20);
break; break;
} }
case Consts.Devices.WEDO2_TILT: case Consts.Devices.WEDO2_TILT:

View File

@ -18,7 +18,7 @@ lpf2.on("discover", (hub) => {
moveHub.on("distance", (port, distance) => { moveHub.on("distance", (port, distance) => {
console.log(`Distance ${distance} received on port ${port}`); console.log(`Distance ${distance} received on port ${port}`);
if (distance < 80) { if (distance < 100) {
moveHub.setMotorSpeed("D", 40); moveHub.setMotorSpeed("D", 40);
} else { } else {
moveHub.setMotorSpeed("D", 0); moveHub.setMotorSpeed("D", 0);
@ -31,7 +31,7 @@ lpf2.on("discover", (hub) => {
wedoHub.on("distance", (port, distance) => { wedoHub.on("distance", (port, distance) => {
console.log(`Distance ${distance} received on port ${port}`); console.log(`Distance ${distance} received on port ${port}`);
if (distance < 80) { if (distance < 100) {
wedoHub.setMotorSpeed("B", 40); wedoHub.setMotorSpeed("B", 40);
} else { } else {
wedoHub.setMotorSpeed("B", 0); wedoHub.setMotorSpeed("B", 0);