Skip to content

Commit 12de00d

Browse files
[environment rendering] implementing boundary visualization for limited environments
1 parent b209739 commit 12de00d

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

vmas/simulator/environment/environment.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -740,51 +740,6 @@ def render(
740740
pos[Y] + cam_range[Y],
741741
)
742742

743-
# Include boundaries in the rendering
744-
from vmas.simulator import rendering
745-
from vmas.simulator.rendering import Line
746-
from vmas.simulator.utils import Color
747-
748-
# Check if the world dimensions are defined
749-
if self.world.x_semidim is not None and self.world.y_semidim is not None:
750-
# Get the radius of the agents
751-
radius = self.agents[0].shape.radius
752-
753-
# Get the origin coordinates and dimensions for rendering
754-
origin_x, origin_y = (
755-
self.scenario.render_origin[X],
756-
self.scenario.render_origin[Y],
757-
)
758-
# Extend the dimensions to account for the agent's radius
759-
x_semi, y_semi = (
760-
self.world.x_semidim + radius,
761-
self.world.y_semidim + radius,
762-
)
763-
764-
# Define the corner points of the boundary
765-
corners = [
766-
(origin_x - x_semi, origin_y + y_semi), # top_left
767-
(origin_x + x_semi, origin_y + y_semi), # top_right
768-
(origin_x + x_semi, origin_y - y_semi), # bottom_right
769-
(origin_x - x_semi, origin_y - y_semi), # bottom_left
770-
]
771-
772-
# Set the color for the boundary lines
773-
color = Color.BLACK.value
774-
# Initialize a transformation (if needed for rendering)
775-
xform = rendering.Transform()
776-
777-
# Create lines to form the boundary by connecting each corner to the next
778-
for i in range(len(corners)):
779-
start = corners[i] # Current corner point
780-
end = corners[
781-
(i + 1) % len(corners)
782-
] # Next corner point, wraps around to the first point
783-
line = Line(start, end, width=1) # Create a line between two corners
784-
line.add_attr(xform) # Apply transformation to the line
785-
line.set_color(*color) # Set the line color
786-
self.viewer.add_geom(line) # Add the line to the viewer for rendering
787-
788743
# Render
789744
self._set_agent_comm_messages(env_index)
790745

0 commit comments

Comments
 (0)