From 12de00d74877dd90706ea2782d496efbe03dc03d Mon Sep 17 00:00:00 2001 From: Giovanni Briglia <93917046+Giovannibriglia@users.noreply.github.com> Date: Sat, 31 Aug 2024 09:27:32 +0200 Subject: [PATCH] [environment rendering] implementing boundary visualization for limited environments --- vmas/simulator/environment/environment.py | 45 ----------------------- 1 file changed, 45 deletions(-) diff --git a/vmas/simulator/environment/environment.py b/vmas/simulator/environment/environment.py index c80eaf43..e96b1be4 100644 --- a/vmas/simulator/environment/environment.py +++ b/vmas/simulator/environment/environment.py @@ -740,51 +740,6 @@ def render( pos[Y] + cam_range[Y], ) - # Include boundaries in the rendering - from vmas.simulator import rendering - from vmas.simulator.rendering import Line - from vmas.simulator.utils import Color - - # Check if the world dimensions are defined - if self.world.x_semidim is not None and self.world.y_semidim is not None: - # Get the radius of the agents - radius = self.agents[0].shape.radius - - # Get the origin coordinates and dimensions for rendering - origin_x, origin_y = ( - self.scenario.render_origin[X], - self.scenario.render_origin[Y], - ) - # Extend the dimensions to account for the agent's radius - x_semi, y_semi = ( - self.world.x_semidim + radius, - self.world.y_semidim + radius, - ) - - # Define the corner points of the boundary - corners = [ - (origin_x - x_semi, origin_y + y_semi), # top_left - (origin_x + x_semi, origin_y + y_semi), # top_right - (origin_x + x_semi, origin_y - y_semi), # bottom_right - (origin_x - x_semi, origin_y - y_semi), # bottom_left - ] - - # Set the color for the boundary lines - color = Color.BLACK.value - # Initialize a transformation (if needed for rendering) - xform = rendering.Transform() - - # Create lines to form the boundary by connecting each corner to the next - for i in range(len(corners)): - start = corners[i] # Current corner point - end = corners[ - (i + 1) % len(corners) - ] # Next corner point, wraps around to the first point - line = Line(start, end, width=1) # Create a line between two corners - line.add_attr(xform) # Apply transformation to the line - line.set_color(*color) # Set the line color - self.viewer.add_geom(line) # Add the line to the viewer for rendering - # Render self._set_agent_comm_messages(env_index)