Toni-SM / skrl

Modular reinforcement learning library (on PyTorch and JAX) with support for NVIDIA Isaac Gym, Omniverse Isaac Gym and Isaac Lab
https://skrl.readthedocs.io/
MIT License
443 stars 43 forks source link

Random action only samples from the first action space dimension #158

Open nikolaradulov opened 2 weeks ago

nikolaradulov commented 2 weeks ago

Description

Random actions are done by taking the low and high values of the first dimension on the action space a,d then uniformly sampling from [low, high] for each dimension of an action.

   self._random_distribution = torch.distributions.uniform.Uniform(
                    low=torch.tensor(self.action_space.low[0], device=self.device, dtype=torch.float32),
                    high=torch.tensor(self.action_space.high[0], device=self.device, dtype=torch.float32))

The issue is that if i have the following action space for example gym.Box(low=[-5, -3], high=[5,3]) any sampled action[1] will be in [-5,5] instead of [-3,3]

SOLUTION IS:

  self._random_distribution = torch.distributions.uniform.Uniform(
                    low=torch.tensor(self.action_space.low, device=self.device, dtype=torch.float32),
                    high=torch.tensor(self.action_space.high, device=self.device, dtype=torch.float32))

What skrl version are you using?

1.0.0

What ML framework/library version are you using?

pytorch

Additional system information

No response