Skip to content

Commit

Permalink
[Feature] Enable to set the number of lidar rays in navigation, disco…
Browse files Browse the repository at this point in the history
…very and flocking scenarios (#141)

* introduce "n_lidar_rays_entities" and "n_lidar_rays_agents"

* introduce "n_lidar_rays"

* introduce "n_lidar_rays"

* Update vmas/scenarios/discovery.py

Co-authored-by: Matteo Bettini <[email protected]>

* Update vmas/scenarios/flocking.py

Co-authored-by: Matteo Bettini <[email protected]>

* Update vmas/scenarios/navigation.py

Co-authored-by: Matteo Bettini <[email protected]>

---------

Co-authored-by: Matteo Bettini <[email protected]>
  • Loading branch information
Giovannibriglia and matteobettini authored Sep 17, 2024
1 parent 89882a6 commit 26ceb42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions vmas/scenarios/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs):
self._min_dist_between_entities = kwargs.pop("min_dist_between_entities", 0.2)
self._lidar_range = kwargs.pop("lidar_range", 0.35)
self._covering_range = kwargs.pop("covering_range", 0.25)

self.use_agent_lidar = kwargs.pop("use_agent_lidar", False)
self.n_lidar_rays_entities = kwargs.pop("n_lidar_rays_entities", 15)
self.n_lidar_rays_agents = kwargs.pop("n_lidar_rays_agents", 12)

self._agents_per_target = kwargs.pop("agents_per_target", 2)
self.targets_respawn = kwargs.pop("targets_respawn", True)
self.shared_reward = kwargs.pop("shared_reward", False)
Expand Down Expand Up @@ -74,7 +78,7 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs):
[
Lidar(
world,
n_rays=15,
n_rays=self.n_lidar_rays_entities,
max_range=self._lidar_range,
entity_filter=entity_filter_targets,
render_color=Color.GREEN,
Expand All @@ -86,7 +90,7 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs):
world,
angle_start=0.05,
angle_end=2 * torch.pi + 0.05,
n_rays=12,
n_rays=self.n_lidar_rays_agents,
max_range=self._lidar_range,
entity_filter=entity_filter_agents,
render_color=Color.BLUE,
Expand Down
4 changes: 3 additions & 1 deletion vmas/scenarios/flocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs):
n_obstacles = kwargs.pop("n_obstacles", 5)
self._min_dist_between_entities = kwargs.pop("min_dist_between_entities", 0.15)

self.n_lidar_rays = kwargs.pop("n_lidar_rays", 12)

self.collision_reward = kwargs.pop("collision_reward", -0.1)
self.dist_shaping_factor = kwargs.pop("dist_shaping_factor", 1)
ScenarioUtils.check_kwargs_consumed(kwargs)
Expand Down Expand Up @@ -51,7 +53,7 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs):
sensors=[
Lidar(
world,
n_rays=12,
n_rays=self.n_lidar_rays,
max_range=0.2,
entity_filter=goal_entity_filter,
)
Expand Down
3 changes: 2 additions & 1 deletion vmas/scenarios/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs):
self.lidar_range = kwargs.pop("lidar_range", 0.35)
self.agent_radius = kwargs.pop("agent_radius", 0.1)
self.comms_range = kwargs.pop("comms_range", 0)
self.n_lidar_rays = kwargs.pop("n_lidar_rays", 12)

self.shared_rew = kwargs.pop("shared_rew", True)
self.pos_shaping_factor = kwargs.pop("pos_shaping_factor", 1)
Expand Down Expand Up @@ -115,7 +116,7 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs):
[
Lidar(
world,
n_rays=12,
n_rays=self.n_lidar_rays,
max_range=self.lidar_range,
entity_filter=entity_filter_agents,
),
Expand Down

0 comments on commit 26ceb42

Please sign in to comment.