def step(self, action): utils.send_message(self.sock, gym_uds_pb2.Request(type=gym_uds_pb2.Request.STEP)) utils.send_message(self.sock, gym_uds_pb2.Action(value=action)) state_pb = utils.recv_message(self.sock, gym_uds_pb2.State) observation = np.asarray(state_pb.observation.data).reshape( state_pb.observation.shape) return observation, state_pb.reward, state_pb.done
def Sample(self, empty_request, context): action = self.env.action_space.sample() if (isinstance(action, (np.ndarray, np.generic))): act = action.tolist() elif (isinstance(action, tuple)): act = [x for x in action] elif (isinstance(action, int)): act = [float(action)] elif (isinstance(action, float)): act = [action] return gym_uds_pb2.Action(data=act)
def Sample(self, empty_request, context): action = self.env.action_space.sample() return gym_uds_pb2.Action(value=action)
def step(self, action): state_pb = self.stub.Step(gym_uds_pb2.Action(value=action)) observation = np.asarray(state_pb.observation.data).reshape( state_pb.observation.shape) return observation, state_pb.reward, state_pb.done
def sample(self): action = self.env.action_space.sample() utils.send_message(self.sock, gym_uds_pb2.Action(value=action))