add test, remove time delay in car move, fixed bug with sonar emulator on angle between 90 and 270
This commit is contained in:
@@ -17,6 +17,17 @@ private fun testCarEmulator() {
|
|||||||
eq(dist90.toDouble(), Room.bottomLine.C / Room.bottomLine.B, "check angle 90", 2.5)
|
eq(dist90.toDouble(), Room.bottomLine.C / Room.bottomLine.B, "check angle 90", 2.5)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
println("--------------------")
|
||||||
|
sonarRequest = SonarRequest.BuilderSonarRequest(IntArray(2, { 120 + 60 * it })).build()
|
||||||
|
sonarResponse = SonarResponse.BuilderSonarResponse(IntArray(0)).build()
|
||||||
|
controller.executeRequestSensorData(sonarRequest, { bytes ->
|
||||||
|
sonarResponse.mergeFrom(CodedInputStream(bytes))
|
||||||
|
val dist120 = sonarResponse.distances[0]
|
||||||
|
val dist180 = sonarResponse.distances[1]
|
||||||
|
eq(dist120.toDouble(), 23.094, "check angle 120", 2.5)
|
||||||
|
eq(dist180.toDouble(), 150.0, "check angle 180", 2.5)
|
||||||
|
})
|
||||||
|
|
||||||
println("--------------------")
|
println("--------------------")
|
||||||
CarState.instance.x = 50
|
CarState.instance.x = 50
|
||||||
CarState.instance.y = 50
|
CarState.instance.y = 50
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ class ControllerEmulator : Controller {
|
|||||||
xSensor1 = xSensor0
|
xSensor1 = xSensor0
|
||||||
ySensor1 = (ySensor0 - 1).toDouble()
|
ySensor1 = (ySensor0 - 1).toDouble()
|
||||||
}
|
}
|
||||||
|
in (90..270) -> {
|
||||||
|
xSensor1 = xSensor0 - 1
|
||||||
|
ySensor1 = ySensor0 + (xSensor1 - xSensor0) * Math.tan(angleFinal * Math.PI / 180)
|
||||||
|
}
|
||||||
else -> {
|
else -> {
|
||||||
xSensor1 = xSensor0 + 1
|
xSensor1 = xSensor0 + 1
|
||||||
ySensor1 = ySensor0 + (xSensor1 - xSensor0) * Math.tan(angleFinal * Math.PI / 180)
|
ySensor1 = ySensor0 + (xSensor1 - xSensor0) * Math.tan(angleFinal * Math.PI / 180)
|
||||||
@@ -164,9 +168,9 @@ class ControllerEmulator : Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout({
|
// setTimeout({
|
||||||
executeCommand(commands, currentCommandIdx + 1, callBack)
|
executeCommand(commands, currentCommandIdx + 1, callBack)
|
||||||
}, currentCommand.second)
|
// }, currentCommand.second)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user