add sendind walls length to client

This commit is contained in:
MaximZaitsev
2016-08-30 17:22:55 +03:00
parent d55960258c
commit fcc3b68ad8
2 changed files with 11 additions and 2 deletions
@@ -13,6 +13,7 @@ message DebugResponse {
repeated int32 x = 8 [packed = true]; repeated int32 x = 8 [packed = true];
repeated int32 y = 9 [packed = true]; repeated int32 y = 9 [packed = true];
repeated int32 wall_distances = 10 [packed = true];
} }
+10 -2
View File
@@ -96,13 +96,21 @@ object RoomModel {
end_x[i] = (nextPoint.x + 0.5).toInt() end_x[i] = (nextPoint.x + 0.5).toInt()
end_y[i] = (nextPoint.y + 0.5).toInt() end_y[i] = (nextPoint.y + 0.5).toInt()
} }
val wallDistances = walls.filter { it.isFinished }.map {
val firstPoint = it.points.first()
val lastPoint = it.points.last()
val vector = algorithm.geometry.Vector(firstPoint, lastPoint)
vector.length().toInt()
}.toIntArray()
val alg = DebugClInterface.algorithmImpl val alg = DebugClInterface.algorithmImpl
if (alg is RoomBypassingAlgorithm) { if (alg is RoomBypassingAlgorithm) {
return DebugResponse.BuilderDebugResponse(begin_x, begin_y, end_x, end_y, alg.carX, return DebugResponse.BuilderDebugResponse(begin_x, begin_y, end_x, end_y, alg.carX,
alg.carY, alg.carAngle, pointsX, pointsY).build() alg.carY, alg.carAngle, pointsX, pointsY, wallDistances).build()
} }
return DebugResponse.BuilderDebugResponse(begin_x, begin_y, end_x, end_y, 0, return DebugResponse.BuilderDebugResponse(begin_x, begin_y, end_x, end_y, 0,
0, 0, pointsX, pointsY).build() 0, 0, pointsX, pointsY, wallDistances).build()
} }
} }