(self, td_params)
| 402 | |
| 403 | |
| 404 | def _make_spec(self, td_params): |
| 405 | # Under the hood, this will populate self.output_spec["observation"] |
| 406 | self.observation_spec = CompositeSpec( |
| 407 | th=BoundedTensorSpec( |
| 408 | low=-torch.pi, |
| 409 | high=torch.pi, |
| 410 | shape=(), |
| 411 | dtype=torch.float32, |
| 412 | ), |
| 413 | thdot=BoundedTensorSpec( |
| 414 | low=-td_params["params", "max_speed"], |
| 415 | high=td_params["params", "max_speed"], |
| 416 | shape=(), |
| 417 | dtype=torch.float32, |
| 418 | ), |
| 419 | # we need to add the ``params`` to the observation specs, as we want |
| 420 | # to pass it at each step during a rollout |
| 421 | params=make_composite_from_td(td_params["params"]), |
| 422 | shape=(), |
| 423 | ) |
| 424 | # since the environment is stateless, we expect the previous output as input. |
| 425 | # For this, ``EnvBase`` expects some state_spec to be available |
| 426 | self.state_spec = self.observation_spec.clone() |
| 427 | # action-spec will be automatically wrapped in input_spec when |
| 428 | # `self.action_spec = spec` will be called supported |
| 429 | self.action_spec = BoundedTensorSpec( |
| 430 | low=-td_params["params", "max_torque"], |
| 431 | high=td_params["params", "max_torque"], |
| 432 | shape=(1,), |
| 433 | dtype=torch.float32, |
| 434 | ) |
| 435 | self.reward_spec = UnboundedContinuousTensorSpec(shape=(*td_params.shape, 1)) |
| 436 | |
| 437 | |
| 438 | def make_composite_from_td(td): |
nothing calls this directly
no test coverage detected