Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Rendering boundaries in dimension-limited environments #135

Closed
wants to merge 0 commits into from

Conversation

Giovannibriglia
Copy link
Contributor

Description:

  • Issue Reference: #134
  • Summary: Introduced a feature to visualize boundaries in dimension-limited environments by displaying a rectangle. This visualization is triggered when both x_semidim and y_semidim parameters are defined and have non-None values.
  • This addition enhances the usability of the simulator in dimension-limited scenarios by providing a clear visual cue for the environment's boundaries.

Changes Made:

  • [environment.py]: added code to render a rectangle based on the x_semidim and y_semidim parameters. The visualization will only appear when both parameters are defined and set to specific values.

Copy link
Member

@matteobettini matteobettini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! I left comments

Could you test this (even just by yourself visually) with many different values and combinations of:

  • viewer_zoom
  • viewer_size
  • render_origin

These should not affect the boundaries but better to make sure

@@ -740,6 +740,51 @@ def render(
pos[Y] + cam_range[Y],
)

# Include boundaries in the rendering
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a subfunction for this

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we handle also when only one is defined?

Copy link
Contributor Author

@Giovannibriglia Giovannibriglia Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don't see any issues with that approach.

However, my main concern lies in how to structure the if-condition for enabling boundary visualization.

  • Currently, boundary visualization is triggered by checking whether the x_semidim and y_semidim variables are defined:
    if self.world.x_semidim is not None and self.world.y_semidim is not None:
        view bounds...
  • Should we standardize this by ensuring that every scenario includes x_semidim and y_semidim to ensure consistent boundary visualization?
  • Are there any alternative methods or conditions you would suggest for enabling boundary visualization more effectively?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if x_semidim is enabled we visualize x. If y semidin is enabled we visualize y

# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite brittle as agents may have different sizes. How should we handle?

  1. do not add radiuses
  2. add the max radius

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which scenario are you referring to? Just to have a concrete example, thanks.

This is purely a visualization issue, not something more, since I believe that (center + half_radius) should never exceed the boundary limits. Right?

The safest approach would be to use the max_radius (where can I get it?), but this could cause some visualization issues, such as smaller agents not reaching the visualized boundary.

Suggestions? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly,

with 2 you have smaller agents not reaching the boundary, with 1 the boundary is always for the center of agents

this is partly what concerns me about this PR: it is impossible to have a boundary that fits all agents


# Define the corner points of the boundary
corners = [
(origin_x - x_semi, origin_y + y_semi), # top_left
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this? the origin of the rendering is where the camera is, but the boundaries are always from the physical origin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've conducted some tests, and it turns out that the choice of

origin_x, origin_y = (0, 0)

would be the correct approach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaning we can remove the origin from there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, anyway we could left them as variables initialized to (0, 0), which might be useful for future enhancements. Do you agree?

@matteobettini matteobettini added the enhancement New feature or request label Aug 30, 2024
@matteobettini matteobettini changed the title Implementing boundaries visualization in dimension-limited environments [Feature] Rendering boundaries in dimension-limited environments Aug 30, 2024
@Giovannibriglia
Copy link
Contributor Author

I reforked the repo, therefore the pull request has been closed :/.
I will reopen it once I’m ready to continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants