def _build_entity_node(self, entity, map_handle): entity_node = self._atomspace.add_node(types.EntityNode, str(entity.eid)) updated_eval_links = [] at_location_link = add_location(self._atomspace, entity_node, map_handle, [entity.x, entity.y, entity.z]) updated_eval_links.append(at_location_link) type_node = self._atomspace.add_node(types.ConceptNode, str(entity.mob_type)) type_link = add_predicate(self._atomspace, "entitytype", entity_node, type_node) updated_eval_links.append(type_link) yaw_node = self._atomspace.add_node(types.NumberNode, str(entity.head_yaw)) pitch_node = self._atomspace.add_node(types.NumberNode, str(entity.head_pitch)) look_link = add_predicate(self._atomspace, "look", entity_node, yaw_node, pitch_node) updated_eval_links.append(look_link) length_node = self._atomspace.add_node(types.NumberNode, str(entity.length)) width_node = self._atomspace.add_node(types.NumberNode, str(entity.width)) height_node = self._atomspace.add_node(types.NumberNode, str(entity.height)) sizelink = add_predicate(self._atomspace, "size", entity_node, length_node, width_node, height_node) updated_eval_links.append(sizelink) v_x_node = self._atomspace.add_node(types.NumberNode, str(entity.velocity_x)) v_y_node = self._atomspace.add_node(types.NumberNode, str(entity.velocity_y)) v_z_node = self._atomspace.add_node(types.NumberNode, str(entity.velocity_z)) velocitylink = add_predicate(self._atomspace, "velocity", entity_node, v_x_node, v_y_node, v_z_node) updated_eval_links.append(velocitylink) return entity_node, updated_eval_links
def _build_block_nodes(self, block, map_handle): # hack to make static object No. variable in class method if not hasattr(self._build_block_nodes.__func__, "objNo"): self._build_block_nodes.__func__.objNo = 0 # Note: in 3DSpaceMap using structure node to represent block, # entity node to represent entity obj_node = self._atomspace.add_node(types.StructureNode, "obj%s" % (self._build_block_nodes.__func__.objNo)) self._build_block_nodes.__func__.objNo += 1 updated_eval_links = [] at_location_link = add_location(self._atomspace, obj_node, map_handle, [block.x, block.y, block.z]) updated_eval_links.append(at_location_link) type_node = self._atomspace.add_node( types.ConceptNode, blocks.get_block(block.blockid, block.metadata).display_name ) material_link = add_predicate(self._atomspace, "material", obj_node, type_node) updated_eval_links.append(material_link) new_appeared_link = add_predicate(self._atomspace, "new_block", obj_node) updated_eval_links.append(new_appeared_link) return obj_node, updated_eval_links
def _build_block_nodes(self, block, map_handle): # hack to make static object No. variable in class method if not hasattr(self._build_block_nodes.__func__, "objNo"): self._build_block_nodes.__func__.objNo = 0 # Note: in 3DSpaceMap using structure node to represent block, # entity node to represent entity obj_node = self._atomspace.add_node( types.StructureNode, "obj%s" % (self._build_block_nodes.__func__.objNo)) self._build_block_nodes.__func__.objNo += 1 updated_eval_links = [] at_location_link = add_location(self._atomspace, obj_node, map_handle, [block.x, block.y, block.z]) updated_eval_links.append(at_location_link) type_node = self._atomspace.add_node( types.ConceptNode, blocks.get_block(block.blockid, block.metadata).display_name) material_link = add_predicate(self._atomspace, "material", obj_node, type_node) updated_eval_links.append(material_link) new_appeared_link = add_predicate(self._atomspace, "new_block", obj_node) updated_eval_links.append(new_appeared_link) return obj_node, updated_eval_links
def _build_self_pos_node(self, client, map_handle): # TODO: for now because we only input self client so we define node name as "self" # but this should be included in the attribute client_node = self._atomspace.add_node(types.EntityNode, "self") updated_eval_links = [] at_location_link = add_location(self._atomspace, client_node, map_handle, [client.x, client.y, client.z]) updated_eval_links.append(at_location_link) type_node = self._atomspace.add_node(types.ConceptNode, "client") type_link = add_predicate(self._atomspace, "clienttype", client_node, type_node) updated_eval_links.append(type_link) yaw_node = self._atomspace.add_node(types.NumberNode, str(client.yaw)) pitch_node = self._atomspace.add_node(types.NumberNode, str(client.pitch)) look_link = add_predicate(self._atomspace, "look", client_node, yaw_node, pitch_node) updated_eval_links.append(look_link) return client_node, updated_eval_links