-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
This only happens once after initializing the robot but causes some bugs for some programs.
For example, the next code works fine:
robot.onObstacleDistanceChanged(function () {
distance = robot.obstacleDistance()
if (scanning) {
if (distance > 15) {
scanning = 0
robot.motorTank(30, 30)
}
} else {
if (distance < 15) {
robot.motorTank(-30, -30)
robot.motorTank(0, 0)
robot.motorTank(-25, 25)
basic.pause(1000)
scanning = 1
robot.motorTank(25, -25)
} else {
robot.motorTank(30, 30)
}
}
})
let scanning = 0
let distance = 0
robot.dfRobotMaqueen.start()
But if I invert the conditional, that single frame where it is NaN makes it such that the robot starts spinning at the beginning of the program.
robot.onObstacleDistanceChanged(function () {
distance = robot.obstacleDistance()
if (scanning) {
if (distance > 15) {
scanning = 0
robot.motorTank(30, 30)
}
} else {
if (distance > 15) {
robot.motorTank(30, 30)
} else {
robot.motorTank(-30, -30)
robot.motorTank(0, 0)
robot.motorTank(-25, 25)
basic.pause(1000)
scanning = 1
robot.motorTank(25, -25)
}
}
})
let scanning = 0
let distance = 0
robot.dfRobotMaqueen.start()
If I'm not wrong, this could be fixed changing line 45 of the file drivers/kalmanfilter1d.ts to if (isNaN(this.x) || isNaN(this.cov)) {.
I do not make a pull request because I don't know how to test this libraries.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels