fixed bugs
This commit is contained in:
@@ -33,13 +33,6 @@ fun <T> encodeProtoBuf(protoMessage: T): ByteArray {
|
||||
protoMessage.writeTo(codedOutput)
|
||||
}
|
||||
|
||||
is DirectionResponse -> {
|
||||
val protoSize = protoMessage.getSizeNoTag()
|
||||
routeBytes = ByteArray(protoSize)
|
||||
val codedOutput = CodedOutputStream(routeBytes)
|
||||
protoMessage.writeTo(codedOutput)
|
||||
}
|
||||
|
||||
is RouteResponse -> {
|
||||
val protoSize = protoMessage.getSizeNoTag()
|
||||
routeBytes = ByteArray(protoSize)
|
||||
|
||||
@@ -123,7 +123,7 @@ class ControllerEmulator : Controller {
|
||||
continue
|
||||
}
|
||||
val currentDistance = Math.round(Math.sqrt(Math.pow(xIntersection - xSensor0, 2.0)
|
||||
+ Math.pow(yIntersection - ySensor0, 2.0))*100000)
|
||||
+ Math.pow(yIntersection - ySensor0, 2.0)))
|
||||
if (currentDistance < result) {
|
||||
result = currentDistance
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import control.Controller
|
||||
import encodeProtoBuf
|
||||
import net.server.handlers.AbstractHandler
|
||||
|
||||
class GetSonarData(val controller: Controller): AbstractHandler() {
|
||||
class GetSonarData(val controller: Controller) : AbstractHandler() {
|
||||
val fromServerObjectBuilder = SonarRequest.BuilderSonarRequest(IntArray(0))
|
||||
val toServerObjectBuilder = SonarResponse.BuilderSonarResponse(IntArray(0))
|
||||
|
||||
@@ -18,6 +18,7 @@ class GetSonarData(val controller: Controller): AbstractHandler() {
|
||||
|
||||
if (McState.instance.isConnected()) {
|
||||
controller.executeRequestSensorData(message, callback)
|
||||
return
|
||||
}
|
||||
|
||||
println("mc is disconnected!")
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
package net.server.handlers.rc
|
||||
|
||||
import CodedInputStream
|
||||
import DirectionRequest
|
||||
import DirectionResponse
|
||||
import control.emulator.ControllerEmulator.MoveDirection
|
||||
import encodeProtoBuf
|
||||
import net.server.handlers.AbstractHandler
|
||||
|
||||
class Control : AbstractHandler {
|
||||
class Control() : AbstractHandler() {
|
||||
|
||||
val fromServerObjectBuilder: DirectionRequest.BuilderDirectionRequest
|
||||
val toServerObjectBuilder: DirectionResponse.BuilderDirectionResponse
|
||||
|
||||
constructor() : super() {
|
||||
this.fromServerObjectBuilder = DirectionRequest.BuilderDirectionRequest(DirectionRequest.Command.fromIntToCommand(0), 0)
|
||||
this.toServerObjectBuilder = DirectionResponse.BuilderDirectionResponse(0)
|
||||
}
|
||||
val request = DirectionRequest.BuilderDirectionRequest(DirectionRequest.Command.fromIntToCommand(0), 0, false)
|
||||
|
||||
override fun getBytesResponse(data: ByteArray, callback: (b: ByteArray) -> Unit) {
|
||||
//TODO now this handler don't make nothing. need fix:)
|
||||
@@ -41,8 +31,6 @@ class Control : AbstractHandler {
|
||||
// }
|
||||
// else -> MoveDirection.STOP
|
||||
// }
|
||||
val resultCode: Int = 0
|
||||
val resultMessage = toServerObjectBuilder.setCode(resultCode).build()
|
||||
callback.invoke(encodeProtoBuf(resultMessage))
|
||||
callback.invoke(ByteArray(0))
|
||||
}
|
||||
}
|
||||
@@ -13,16 +13,16 @@ object Room {
|
||||
|
||||
*/
|
||||
|
||||
// val upLine = Line(0.0, 1.0, -300.0)
|
||||
// val leftLine = Line(1.0, 0.0, 150.0)
|
||||
// val bottomLine = Line(0.0, 1.0, 20.0)
|
||||
// val rightLine = Line(1.0, 0.0, -200.0)
|
||||
//
|
||||
// val walls = listOf<Wall>(Wall(upLine, 200, -150, 300, 300),
|
||||
// Wall(leftLine, -150, -150, 300, -20),
|
||||
// Wall(bottomLine, -150, 200, -20, -20),
|
||||
// Wall(rightLine, 200, 200, -20, 300)
|
||||
// )
|
||||
val upLine = Line(0.0, 1.0, -300.0)
|
||||
val leftLine = Line(1.0, 0.0, 150.0)
|
||||
val bottomLine = Line(0.0, 1.0, 20.0)
|
||||
val rightLine = Line(1.0, 0.0, -200.0)
|
||||
|
||||
val walls = listOf<Wall>(Wall(upLine, 200, -150, 300, 300),
|
||||
Wall(leftLine, -150, -150, 300, -20),
|
||||
Wall(bottomLine, -150, 200, -20, -20),
|
||||
Wall(rightLine, 200, 200, -20, 300)
|
||||
)
|
||||
|
||||
|
||||
/*
|
||||
@@ -57,17 +57,17 @@ object Room {
|
||||
|
||||
*/
|
||||
|
||||
val upLine = Line(0.0, 1.0, -300.0)
|
||||
val leftLine = Line(1.0, 0.0, 150.0)
|
||||
val bottomLine = Line(0.0, 1.0, 20.0)
|
||||
val rightLine = Line(-1.2, 1.0, 140.0)
|
||||
val rightLine2 = Line(1.0, 1.0, -350.0)
|
||||
|
||||
val walls = listOf<Wall>(Wall(upLine, 200, -150, 300, 300),
|
||||
Wall(leftLine, -150, -150, 300, -20),
|
||||
Wall(bottomLine, -150, 100, -20, -20),
|
||||
Wall(rightLine, 100, 200, -20, 100),
|
||||
Wall(rightLine2, 200, 200, 100, 300)
|
||||
)
|
||||
// val upLine = Line(0.0, 1.0, -300.0)
|
||||
// val leftLine = Line(1.0, 0.0, 150.0)
|
||||
// val bottomLine = Line(0.0, 1.0, 20.0)
|
||||
// val rightLine = Line(-1.2, 1.0, 140.0)
|
||||
// val rightLine2 = Line(1.0, 1.0, -350.0)
|
||||
//
|
||||
// val walls = listOf<Wall>(Wall(upLine, 200, -150, 300, 300),
|
||||
// Wall(leftLine, -150, -150, 300, -20),
|
||||
// Wall(bottomLine, -150, 100, -20, -20),
|
||||
// Wall(rightLine, 100, 200, -20, 100),
|
||||
// Wall(rightLine2, 200, 200, 100, 300)
|
||||
// )
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user