MCPcopy Create free account
hub / github.com/InternRobotics/UniHSI / VecTaskPython

Class VecTaskPython

unihsi/env/tasks/vec_task.py:121–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119
120# Python CPU/GPU Class
121class VecTaskPython(VecTask):
122
123 def get_state(self):
124 return torch.clamp(self.task.states_buf, -self.clip_obs, self.clip_obs).to(self.rl_device)
125
126 def step(self, actions):
127 actions_tensor = torch.clamp(actions, -self.clip_actions, self.clip_actions)
128
129 self.task.step(actions_tensor)
130
131 return torch.clamp(self.task.obs_buf, -self.clip_obs, self.clip_obs).to(self.rl_device), self.task.rew_buf.to(self.rl_device), self.task.reset_buf.to(self.rl_device), self.task.extras
132
133 def reset(self):
134 actions = 0.01 * (1 - 2 * torch.rand([self.task.num_envs, self.task.num_actions], dtype=torch.float32, device=self.rl_device))
135
136 # step the simulator
137 self.task.step(actions)
138
139 return torch.clamp(self.task.obs_buf, -self.clip_obs, self.clip_obs).to(self.rl_device)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected