Ejemplo n.º 1
0
 def teleport(self,
              pose: Dict[str, float],
              rotation: Dict[str, float],
              horizon: float = 0.0):
     self.agent_position = pos_to_str_for_cache(pose)
     self.agent_rotation = (math.floor(rotation["y"] / 90.0) * 90
                            )  # round to nearest 90 degree angle
     return True
Ejemplo n.º 2
0
 def step(
     self, action_dict: Dict[str, Union[str, int,
                                        float]]) -> ai2thor.server.Event:
     """Take a step in the ai2thor environment."""
     self._last_action = action_dict["action"]
     if action_dict["action"] == "RotateLeft":
         self.agent_rotation = (self.agent_rotation - 90.0) % 360.0
     elif action_dict["action"] == "RotateRight":
         self.agent_rotation = (self.agent_rotation + 90.0) % 360.0
     elif action_dict["action"] == "MoveAhead":
         pos = str_to_pos_for_cache(self.agent_position)
         if self.agent_rotation == 0.0:
             pos["x"] += 0.25
         elif self.agent_rotation == 90.0:
             pos["z"] += 0.25
         elif self.agent_rotation == 180.0:
             pos["x"] -= 0.25
         elif self.agent_rotation == 270.0:
             pos["z"] -= 0.25
         pos_string = pos_to_str_for_cache(pos)
         if pos_string in self.view_cache:
             self.agent_position = pos_to_str_for_cache(pos)
     return self.last_event