Skip to content

[Feature] Allow customized, fixed viewer bound in interactive mode #92

@Jianye-Xu

Description

@Jianye-Xu

Current, VMAS seemly does not support a customized, fixed viewer bound in interactive mode. This feature would be useful if the origin $(0,0)$ of a user's map is not centered. In my case, the origin of my map is located at the lower left corner, meaning that the $x$-range of my map is [0, world_x_dim], and the $y$-range of my map is [0, world_y_dim], instead of [-world_x_dim/2, world_x_dim/2] and [-world_y_dim/2, world_y_dim/2]. In addition, I do not want to shift my map since I am using an HD map with dense data.

My current workaround is to add an attribute viewer_bound in my Scenario class's make_world function:

self.viewer_bound = torch.tensor(
    [0, world_x_dim, 0, world_y_dim],
    device=device,
    dtype=torch.float32,
)

and then modify the source code of file /vmas/simulator/environment/environment.py around this line from

self.viewer.set_bounds(
    -cam_range[X],
    cam_range[X],
    -cam_range[Y],
    cam_range[Y],
)

to

if hasattr(self.scenario, "viewer_bound"):
    self.viewer.set_bounds(
        self.scenario.viewer_bound[0], # left boundary
        self.scenario.viewer_bound[1], # right boundary
        self.scenario.viewer_bound[2], # bottom boundary
        self.scenario.viewer_bound[3], # top boundary
    )
else:
    self.viewer.set_bounds(
        -cam_range[X],
        cam_range[X],
        -cam_range[Y],
        cam_range[Y],
    )

This way, if self.scenario contains the user-given attibute viewer_bound, the viewer bound will be set accordingly; otherwise, the funtionality is untouched.

I would appreciate it if anyone could point out if there is an easier way to achieve this. If not, I think it would be nice if the developer would add such a feature to VMAS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions