Example #1
0
from ca.nengo.math.impl import FourierFunction
from ca.nengo.model.impl import FunctionInput
from ca.nengo.model import Units
from ctu.nengoros.modules.impl.vivae import VivaeNeuralModule as NeuralModule
from ctu.nengoros.comm.nodeFactory import NodeGroup as NodeGroup
from ctu.nengoros.comm.rosutils import RosUtils as RosUtils
from ctu.nengoros.modules.impl.vivae.impl import SimulationControls as Controls
import simplemodule
import util
from vivaeLauncher import oneAgent

from design.ea.matrix.hnn.simple import HNNWMatrixEA as EA
from design.ea.matrix.hnn.simple import HNNInd as Ind
import os

RosUtils.setAutorun(False)    

# this generates signal which turns the agent left
class EventGenerator(simplemodule.SimpleModule):
    #  .......... 9         2          1    [all sensors, two speeds, turning duration]
    def init(self,inputdims,outputdims,numpars):
        self.inputdims = inputdims;
        self.outputdims = outputdims;
        self.numpars = numpars;
        self.lo = 0.1;       # original one
        self.ro = 0.38;      # original one
        self.duration = 0;
        self.maxdur = 30;    # original one
        self.started = False;
        self.threshold = 0; # if input value is under this threshold, launch the event!
        #self.straight = [0.47, 0.47];
Example #2
0
import nef
from ca.nengo.math.impl import FourierFunction
from ca.nengo.model.impl import FunctionInput
from ca.nengo.model import Units
from ctu.nengoros.modules.impl import DefaultNeuralModule as NeuralModule
from ctu.nengoros.modules.impl import DefaultAsynNeuralModule as AsynNeuralModule
from ctu.nengoros.comm.nodeFactory import NodeGroup as NodeGroup
from ctu.nengoros.comm.rosutils import RosUtils as RosUtils

# creates nef network and adds it to nengo (this must be first in the script) 
net=nef.Network('Random Turtle Control Demo')
net.add_to_nengo()  # here: delete old (toplevel) network and replace it with the newly CREATED one

################################## 
#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
RosUtils.prefferJroscore(False) # Turlte prefers roscore before jroscore (don't know why..) 

################################## 
turtlesim = "rosrun turtlesim turtlesim_node"   # command to start turtle installed in ROS
act = "resender.turtle.Controller";             
g = NodeGroup("Turtlesim", True);        # create group of ROS nodes (equals to one neural subsystem)
g.addNode(turtlesim, "Turtlesim", "native");  # add Node Configuration (turtle) to the group of nodes
module = NeuralModule('TurtleController', g)  

# configure modem, that is:
# -createDecoder = create origin (output) of Nengo module 
#   -what comes from ROS modules is decoded and passed to the output of subsystem in Nengo
# -createEncoder = create termination (input) of Nengo module
#   -what comes from ANN in Nengo is encoded into messages and sent to ROS modules
# modem should be able to encode/decode (all) messages used in own NodeGroup
module.createDecoder("turtle1/pose", "pose")                 # origin
Example #3
0
from design.ea.matrix.hnn import HNNWMatrixEA as EA
from design.ea.matrix.hnn.impl import HNNInd as Ind

from hanns import inFactory
import modules
from modules import mathNodes
from modules import routing
from hanns import spiketofloat
from hanns import floattospike
import inspect
import os
from ca.nengo.model.impl import NetworkImpl, NoiseFactory, FunctionInput, NetworkArrayImpl
from ctu.nengoros.comm.rosutils import RosUtils as RosUtils

RosUtils.prefferJroscore(False) 

actualIn=0;
actualOut=0;
# how to read input and output weights from individual in java
def setInW(w):
    useDesigned = False
    if (useDesigned):
        #w = ind.getMatrix().get2DInMatrixNo(actualIn);
        w = ind.m.getRange(0,16);
    else:
        for i in range(len(w)):
            for j in range(len(w[i])):
                w[i][j]=0.2
    return w;
def setOutW(w): # TODO: support for multidimensional outputs
Example #4
0
import simplemodule

# import util # error importing
import string
import random

import vivaeServer as vivae

# from vivaeLauncher import oneAgent

from design.ea.matrix.hnn.simple import HNNWMatrixEA as EA
from design.ea.matrix.hnn.simple import HNNInd as Ind
import os

RosUtils.setAutorun(True)

# this generates signal which turns the agent left
class EventGenerator(simplemodule.SimpleModule):
    #  .......... 9         2          1    [all sensors, two speeds, turning duration]
    def init(self, inputdims, outputdims, numpars):
        self.inputdims = inputdims
        self.outputdims = outputdims
        self.numpars = numpars
        self.lo = 0.1
        # original one
        self.ro = 0.38
        # original one
        self.duration = 0
        self.maxdur = 30
        # original one
Example #5
0
from ca.nengo.math.impl import FourierFunction
from ca.nengo.model.impl import FunctionInput
from ca.nengo.model import Units
from ctu.nengoros.modules.impl import DefaultNeuralModule as NeuralModule
from ctu.nengoros.comm.nodeFactory import NodeGroup as NodeGroup
from ctu.nengoros.comm.rosutils import RosUtils as RosUtils

import basic_nodes

# creates nef network and adds it to nengo (this must be first in the script) 
net=nef.Network('Demo of simple Neural modules which find min and max, multiplies them by the current time and publishes')
net.add_to_nengo()  # here: delete old (toplevel) network and replace it with the newly CREATED one

################# setup the ROS utils (optional) 
#RosUtils.setTimeIgnore()
RosUtils.setTimeMaster()	# used by default
#RosUtils.setTimeSlave() 	# note: experimental, TODO

#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
#RosUtils.prefferJroscore(True)  # preffer jroscore before the roscore? 


################# add ROS nodes
finderA = basic_nodes.sync_timeaware_node("MinMax Synchronous Float Finder - Values multiplied by the current time") 	# build the neural module
many=net.add(finderA)                        							# add it into the network

#Create a white noise input function with params: baseFreq, maxFreq [rad/s], RMS, seed
generator=FunctionInput('Randomized input', [FourierFunction(.1, 10,1, 12),
    FourierFunction(.4, 20,1.5, 11),
    FourierFunction(.1, 10,0.9, 10),
    FourierFunction(.5, 11,1.6, 17)],Units.UNK) 
Example #6
0
from ca.nengo.model.impl import FunctionInput
from ca.nengo.model import Units
from ctu.nengoros.modules.impl import DefaultNeuralModule as NeuralModule
from ctu.nengoros.comm.nodeFactory import NodeGroup as NodeGroup
from ctu.nengoros.comm.rosutils import RosUtils as RosUtils

import basic_nodes

# creates nef network and adds it to nengo (this must be first in the script) 
net=nef.Network('Demo of simple Neural modules which find min and max, multiplies them by the current time and publishes')
net.add_to_nengo()  # here: delete old (toplevel) network and replace it with the newly CREATED one

################# setup the ROS utils (optional) 
#RosUtils.setTimeIgnore() 	
#RosUtils.setTimeMaster() 	# used by default
RosUtils.setTimeSlave() 	# note: experimental, TODO

#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
#RosUtils.prefferJroscore(True)  # preffer jroscore before the roscore? 


################# add ROS nodes
finderA = basic_nodes.sync_timeaware_node("MinMax Synchronous Float Finder - Values multiplied by the current time") 	# build the neural module
many=net.add(finderA)                        							# add it into the network

#Create a white noise input function with params: baseFreq, maxFreq [rad/s], RMS, seed
generator=FunctionInput('Randomized input', [FourierFunction(.1, 10,1, 12),
    FourierFunction(.4, 20,1.5, 11),
    FourierFunction(.1, 10,0.9, 10),
    FourierFunction(.5, 11,1.6, 17)],Units.UNK) 
Example #7
0
import nef
from ca.nengo.math.impl import FourierFunction
from ca.nengo.model.impl import FunctionInput
from ca.nengo.model import Units
from ctu.nengoros.modules.impl import DefaultNeuralModule as NeuralModule
from ctu.nengoros.comm.nodeFactory import NodeGroup as NodeGroup
from ctu.nengoros.comm.rosutils import RosUtils as RosUtils

import basic_nodes

# creates nef network and adds it to nengo (this must be first in the script) 
net=nef.Network('Demo of simple Neural modules which find min and max, multiplies them by the current time and publishes')
net.add_to_nengo()  # here: delete old (toplevel) network and replace it with the newly CREATED one

################# setup the ROS utils (optional) 
RosUtils.setTimeIgnore()
#RosUtils.setTimeMaster()	# used by default
#RosUtils.setTimeSlave() 	# note: experimental, TODO

#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
#RosUtils.prefferJroscore(True)  # preffer jroscore before the roscore? 


################# add ROS nodes
finderA = basic_nodes.sync_timeaware_node("MinMax Synchronous Float Finder - Values multiplied by the current time") 	# build the neural module
many=net.add(finderA)                        							# add it into the network

#Create a white noise input function with params: baseFreq, maxFreq [rad/s], RMS, seed
generator=FunctionInput('Randomized input', [FourierFunction(.1, 10,1, 12),
    FourierFunction(.4, 20,1.5, 11),
    FourierFunction(.1, 10,0.9, 10),