def handle_client_join(self, name, data):
     pos = self.clientinfo.position
     x, y, z = mvu.get_nearest_position(pos.x, pos.y, pos.z)
     self.state.pos = Vector3(x, y, z)
     facing = mvu.get_nearest_direction(pos.yaw)
     self.state.dir = facing
     logger.info("Initializing agent's internal state of motion")
 def percept_to_relative(self, percept):
     pos = self.clientinfo.position
     pos_coords = mov.get_nearest_position(pos.x, pos.y, pos.z)
     rel_percept = dict()
     for xyz in percept:
         rel_coords = tuple([p1 - p0 for p0, p1 in zip(pos_coords, xyz)])
         rel_percept[rel_coords] = percept[xyz]
     return rel_percept
Esempio n. 3
0
 def operator_move(self):
     print("calling operator move")
     # forward one unit/block, direction agent is facing
     pos = self.clientinfo.position
     facing = mvu.get_nearest_direction(pos.yaw)
     x, y, z = mvu.get_nearest_position(pos.x, pos.y, pos.z)
     x, y, z = move_deltas[facing](x, y, z)
     self.movement.move_to(x, y, z)
Esempio n. 4
0
 def operator_break_obstacle(self):
     print("calling operator break obstacle")
     pos = copy.deepcopy(self.clientinfo.position)
     facing = mvu.get_nearest_direction(pos.yaw)
     x, y, z = mvu.get_nearest_position(pos.x, pos.y, pos.z)
     target_block_coords = move_deltas[facing](x, y, z)
     #print("target block integer coords: {}".format(target_block_coords))
     target_block_center = tuple([cb + 0.5 for cb in target_block_coords])
     #print("target block center coords: {}".format(target_block_center))
     pos.yaw = facing
     pos.pitch = 0.0
     pos.x, pos.y, pos.z = target_block_coords
     self.interact.dig_block(pos)
     self.interact.look(yaw=facing, pitch=0.0)
 def update_sensors(self):
     pos = self.clientinfo.position
     # discretize the absolute position and direction
     x, y, z = mvu.get_nearest_position(pos.x, pos.y, pos.z)
     cur_pos = Vector3(x, y, z)
     cur_dir = mvu.get_nearest_direction(pos.yaw)
     # update absolute state and current movement primitive
     delta_pos = mvu.get_nearest_delta_pos(self.state.pos, cur_pos)
     self.motion.delta_pos = motion_labels[delta_pos]
     delta_dir = mvu.get_nearest_delta_dir(self.state.dir, cur_dir)
     self.motion.delta_dir = motion_labels[delta_dir]
     self.state.pos = cur_pos
     self.state.dir = cur_dir
     #print("delta pos: {}, delta dir: {}".format(delta_pos, delta_dir))
     mvu.log_agent_motion(self.motion)
     mvu.log_agent_state(self.state)
Esempio n. 6
0
 def handle_block_update(self, name, data):
     # gold block spawned in world. call the planner
     if data['block_data'] >> 4 == 41:
         pos = self.clientinfo.position
         self.state.agent['start_xyz'] = mvu.get_nearest_position(
             pos.x, pos.y, pos.z)
         self.state.agent['cur_xyz'] = self.state.agent['start_xyz']
         self.state.agent['start_theta'] = mvu.get_nearest_direction(
             pos.yaw)
         self.state.agent['cur_theta'] = self.state.agent['start_theta']
         block_pos = data['location']
         # self.perceive()
         # for block in self.visual_percept['blocks']:
         #     print([block," ",self.visual_percept['blocks'][block]])
         # self.state.targets['gold']['location'] = (
         #     block_pos['x'],
         #     block_pos['y'],
         #     block_pos['z'])
         self.continual_planner()
    def handle_block_update(self, name, data):
        # gold block spawned in world. call the planner
        if data['block_data'] >> 4 == 41:
            pos = self.clientinfo.position
            self.state.start_loc = mvu.get_nearest_position(pos.x, pos.y, pos.z)
            self.state.current_position = self.state.start_loc
            self.state.current_orientation = mvu.get_nearest_direction(pos.yaw)

            block_pos = data['location']
            self.state.targets['gold']['location'] = (
                block_pos['x'],
                block_pos['y'],
                block_pos['z'])

            self.solve()
            if self.room_plan is not None and len(self.room_plan) > 0:
                logger.info("plan succeeded")
                logger.info("total room plan: {}".format(self.room_plan))
                self.event.emit("agent_planning_complete")
                self.plan_idx = 0
            else:
                logger.info("plan failed")
                self.event.emit("agent_planning_failed")
Esempio n. 8
0
 def perceive(self):
     pos = self.clientinfo.position
     x, y, z = mvu.get_nearest_position(pos.x, pos.y, pos.z)
     orientation = mvu.get_nearest_direction(pos.yaw)
     self.request_visual_percept(x, z, orientation)
Esempio n. 9
0
 def update_pose(self, pose):
     self.pos = mov.get_nearest_position(pose['x'], pose['y'], pose['z'])
     self.dir = mov.get_nearest_direction(pose['yaw'])
Esempio n. 10
0
 def operator_move_reset(self):
     # simply centers the agent and sets look direction to NORTH
     pos = self.clientinfo.position
     x, y, z = mvu.get_nearest_position(pos.x, pos.y, pos.z)
     self.interact.look(yaw=DIR_NORTH, pitch=0.0)
     self.movement.move_to(x, y, z)