from opencog.utilities import initialize_opencog from opencog.atomspace import types, get_refreshed_types from opencog.bindlink import execute_atom from opencog.type_constructors import * from opencog.atomspace import AtomSpace import numpy as np import random types=get_refreshed_types() atomspace = AtomSpace() initialize_opencog(atomspace) def simneu(X,Y): # change input dataset to matrix format print X,Y mat = [] row = [] atom = str(X.name) atom = atom.split(',') mat2 = [] row2 = [] atom2 = str(Y.name) atom2 = atom2.split(',') for i in range(0, len(atom)):
available class: AttentionController: used in the main loop to control av TODO: Integrated with the existing attention control code: For now we just use a simple way(see the doc in the class) to control the attention value of atom. In the long run, we may need a more clever and complicated way to do this. """ from opencog.type_constructors import * from opencog.bindlink import bindlink from opencog.atomspace import types,get_refreshed_types import opencog.spacetime #for import spacetime atom types from opencog.type_constructors import * from opencog.atomspace import Atom types = get_refreshed_types() #must do so or types will miss spacetime types class AttentionController: """Used for simply control the attention value of atoms control the av in control_av_in_atomspace method. Arg: atomspace(opencog.atomspace.AtomSpace): atomspace in the main loop """ def __init__(self, atomspace): self._atomspace = atomspace def control_av_in_atomspace(self): """Called in the main loop to update av For now we control av in this way: if new block appeared or old block disappeared: (e.g. finding such atom structures
# perception_module.py # ! /usr/bin/env python2.7 python2 python from opencog.atomspace import AtomSpace, Atom, TruthValue, types, get_refreshed_types from opencog.type_constructors import * from opencog.cogserver_type_constructors import * from opencog.spacetime import SpaceServer, TimeServer types = get_refreshed_types() # update spacetime types imported from opencog.atomspace import Atom from atomspace_util import add_predicate, add_location from atomspace_util import get_predicate, get_most_recent_pred_val from ros_perception import ROSPerceptionInterface from spockbot.mcdata import blocks default_map_timestamp = 0 default_map_name = "MCmap" default_map_resolution = 1 default_map_agent_height = 1 default_map_floor_height = -255 def swap_y_and_z(coord): temp_y = coord.y coord.y = coord.z coord.z = temp_y return coord class PerceptionManager: def __init__(self, atomspace, space_server, time_server):
from opencog.atomspace import types, get_refreshed_types from opencog.bindlink import bindlink from opencog.type_constructors import * types = get_refreshed_types() from opencog.atomspace import Atom def add_predicate(atomspace, predicatestr, *atoms): if len(atoms) == 1: target_atom = atoms[0] elif len(atoms) > 1: target_atom = atomspace.add_link(types.ListLink, atoms) else: raise RuntimeError('atomspace_util.add_predicate: atom list is empty!') return atomspace.add_link( types.EvaluationLink, [atomspace.add_node(types.PredicateNode, predicatestr), target_atom]) def add_location(atomspace, targetnode, maphandle, pos): return atomspace.add_link(types.AtLocationLink, [ targetnode, maphandle, atomspace.add_link(types.ListLink, [ atomspace.add_node(types.NumberNode, str(pos[0])), atomspace.add_node(types.NumberNode, str(pos[1])), atomspace.add_node(types.NumberNode, str(pos[2])) ]) ]) def get_predicate(atomspace, predicate_name, target_node, num_of_val):
# perception_module.py # ! /usr/bin/env python2.7 python2 python from opencog.atomspace import AtomSpace, Atom, TruthValue, types, \ get_refreshed_types from opencog.type_constructors import * from opencog.cogserver_type_constructors import * from opencog.spacetime import SpaceServer, TimeServer types = get_refreshed_types() # update spacetime types imported from opencog.atomspace import Atom from atomspace_util import add_predicate, add_location from atomspace_util import get_predicate, get_most_recent_pred_val from ros_perception import ROSPerceptionInterface from spockbot.mcdata import blocks default_map_timestamp = 0 default_map_name = "MCmap" default_map_resolution = 1 default_map_agent_height = 1 default_map_floor_height = -255 def swap_y_and_z(coord): temp_y = coord.y coord.y = coord.z coord.z = temp_y return coord class PerceptionManager: