Better distance calculations
This commit is contained in:
parent
056e7844ee
commit
cf3d17e1f5
@ -284,7 +284,7 @@ class BoostHub extends Hub {
|
||||
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;
|
||||
}
|
||||
case Consts.Devices.WEDO2_TILT:
|
||||
|
4
test.js
4
test.js
@ -18,7 +18,7 @@ lpf2.on("discover", (hub) => {
|
||||
|
||||
moveHub.on("distance", (port, distance) => {
|
||||
console.log(`Distance ${distance} received on port ${port}`);
|
||||
if (distance < 80) {
|
||||
if (distance < 100) {
|
||||
moveHub.setMotorSpeed("D", 40);
|
||||
} else {
|
||||
moveHub.setMotorSpeed("D", 0);
|
||||
@ -31,7 +31,7 @@ lpf2.on("discover", (hub) => {
|
||||
|
||||
wedoHub.on("distance", (port, distance) => {
|
||||
console.log(`Distance ${distance} received on port ${port}`);
|
||||
if (distance < 80) {
|
||||
if (distance < 100) {
|
||||
wedoHub.setMotorSpeed("B", 40);
|
||||
} else {
|
||||
wedoHub.setMotorSpeed("B", 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user