Skip to content

Commit 388fee3

Browse files
committed
Polished graphics + added extended walls for ROS
Signed-off-by: [ 大鳄 ] Asew <[email protected]>
1 parent a3a3b19 commit 388fee3

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/ros/advanced/ros.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
from utility.threading import Lock # noqa: E402
3333

3434
class Ros:
35-
INFLATE: int = 3 # radius of agent for extended walls. Note, this currently isn't supported with dynamic maps due to time constraints (parameter is ignored).
35+
INFLATE: int = 2 # radius of agent for extended walls.
3636
INIT_MAP_SIZE: int = 128 # maximum map size for the first received map (this determines the scaling factor for all subsequent map updates).
3737
MAP_SIZE: int = 256 # the overall map size, can be as big as you like. Note, the initial map fragment will be located at the center of this 'big' map.
38+
TRAVERSABLE_THRESHOLD: int = 30 # weight grid values above this value are considered to be obstacles
3839

3940
_sim: Optional[Simulator] # simulator
4041
_grid: Optional[NDArray[(MAP_SIZE, MAP_SIZE), np.float32]] # weight grid, shape (width, height), weight bounds: (0, 100), unmapped: -1
@@ -104,10 +105,23 @@ def _set_slam(self, msg: OccupancyGrid) -> None:
104105
if i >= 0 and j >= 0 and i < raw_grid.shape[1] and j < raw_grid.shape[0]:
105106
grid[i - start[0]][j - start[1]] = raw_grid[j][i]
106107

108+
# hacky work-around for not having extended walls implemented. Here we manually
109+
# extend the walls, by placing obstacles (works just as well, but should still
110+
# ideally implement extended walls).
111+
INVALID_VALUE = -2
112+
grid_walls_extended = np.full(self._size, INVALID_VALUE)
113+
for idx in np.ndindex(grid_walls_extended.shape):
114+
if grid_walls_extended[idx] == INVALID_VALUE:
115+
grid_walls_extended[idx] = grid[idx]
116+
if grid[idx] > self.TRAVERSABLE_THRESHOLD:
117+
for i in range(-self.INFLATE, self.INFLATE+1):
118+
for j in range(-self.INFLATE, self.INFLATE+1):
119+
grid_walls_extended[(idx[0]+i, idx[1]+j)] = grid[idx]
120+
107121
# make new grid accessible.
108122
# Note, it's up to the user / algorithm to request a map update for thread
109123
# safety, e.g. via `self._sim.services.algorithm.map.request_update()`.
110-
self.grid = grid
124+
self.grid = grid_walls_extended
111125

112126
@property
113127
def grid(self) -> str:
@@ -229,7 +243,7 @@ def _map_update_requested(self) -> None:
229243
Map update was requested.
230244
"""
231245
pass
232-
246+
233247
def _world_to_grid(self, world_pos: Point, origin: Optional[Point] = None) -> Point:
234248
"""
235249
Converts from meters coordinates to PathBench's grid coordinates (`self.grid`).
@@ -291,7 +305,7 @@ def _setup_sim(self, config: Optional[Configuration] = None, goal: Optional[Poin
291305
mp = RosMap(agent,
292306
goal,
293307
lambda: self.grid,
294-
traversable_threshold=30,
308+
traversable_threshold=self.TRAVERSABLE_THRESHOLD,
295309
unmapped_value=-1,
296310
wp_publish=self._send_way_point,
297311
update_requested=self._map_update_requested,

src/simulator/views/map/display/online_lstm_map_display.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, services: Services, ray_colour: Optional[DynamicColour] = Non
2525
self.bearing_colour = self._services.state.add_colour("bearing", Colour(1, 0, 1)) if bearing_colour is None else bearing_colour
2626

2727
def render(self, *discarded) -> None:
28-
self._services.graphics.renderer.push_line_thickness(8)
28+
self._services.graphics.renderer.push_line_thickness(50)
2929

3030
features = MapProcessing.extract_features(self._map, [
3131
"distance_to_goal_normalized",

src/simulator/views/map/map_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def __take_hd_screenshot(self):
465465

466466
def cube_center(self, p: Point) -> Point:
467467
x, y, z = self.to_point3(p)
468-
return Point(x + 0.5, y + 0.5, z - 0.5 if self.map.dim == 3 else z)
468+
return Point(x + 0.5, y + 0.5, z - 0.5 if self.map.dim == 3 else z + 0.15)
469469

470470
def push_root(self, np: Optional[NodePath] = None) -> NodePath:
471471
if np is None:

0 commit comments

Comments
 (0)