Skip to content

Commit 32e4295

Browse files
committed
[BugFix] Action clamping for communication actions
1 parent 54c4d1e commit 32e4295

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

vmas/simulator/environment/environment.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,17 @@ def _set_action(self, action, agent):
381381
f"expected {self.get_agent_action_size(agent)}"
382382
)
383383
if self.clamp_action and self.continuous_actions:
384-
action = action.clamp(-agent.action.u_range, agent.action.u_range)
384+
physical_action = action[..., : agent.action_size]
385+
a_range = agent.action.u_range_tensor.unsqueeze(0).expand(
386+
physical_action.shape
387+
)
388+
physical_action = physical_action.clamp(-a_range, a_range)
389+
390+
if self.world.dim_c > 0 and not agent.silent: # If comms
391+
comm_action = action[..., agent.action_size :]
392+
action = torch.cat([physical_action, comm_action.clamp(0, 1)], dim=-1)
393+
else:
394+
action = physical_action
385395

386396
action_index = 0
387397

0 commit comments

Comments
 (0)