コード例 #1
0
modemCls = "nengoros.comm.nodeFactory.modem.impl.DefaultModem"
# custom modem here

##################################
################# turtle 1
g = NodeGroup("zelvicka", True)
g.addNC(turtlesim, "zelva", "native")
# start native node called zelva
g.addNC(modemCls, "turtlemodem", "modem")
g.startGroup()

modem = g.getModem()
bigneuron = NeuralModule("TurtleController", modem)
bigneuron.createDecoder("turtle1/pose", "pose")  # origin
bigneuron.createDecoder("turtle1/color_sensor", "color")  # origin
bigneuron.createEncoder("turtle1/command_velocity", "velocity")  # termination
many = net.add(bigneuron)
# Create a white noise input function with parameters: baseFreq, maxFreq (rad/s), RMS, Seed
input = FunctionInput("Randomized input", [FourierFunction(0.5, 10, 6, 12), FourierFunction(2, 11, 5, 17)], Units.UNK)
# Add the input node to the network and connect it to the smart enuron
net.add(input)
net.connect(input, many.getTermination("turtle1/command_velocity"))
# make neural network and connect it to the smart neuron
A = net.make("PositionData", neurons=10, dimensions=5, radius=20)
net.connect(many.getOrigin("turtle1/pose"), A)
# make neural network and connect it to the smart neuron
B = net.make("ColorData", neurons=10, dimensions=3, radius=120)  # RGB values observed in range of 100
net.connect(many.getOrigin("turtle1/color_sensor"), B)


##################################
コード例 #2
0
ファイル: 04floatToInt.py プロジェクト: jvitku/nengo_1.4
################# define the group and start it
finder = "resender.mpt.F2IPubSub";      # Jva (ROS) node that does this job
modem  = "nengoros.comm.nodeFactory.modem.impl.DefaultModem"; # custom modem here

# create group with a name
g = NodeGroup("MinMaxFinder", True);    # create independent group called..
g.addNC(finder, "Finder", "java");      # start java node and name it finder
g.addNC(modem,"Modem","modem")     	# add modem to the group
g.startGroup()

################################## 
################# setup the smart neuron and add it to the Nengo network
modem = g.getModem()
neuron = NeuralModule('MinMaxFinder', modem) # construct the smart neuron 

neuron.createEncoder("ann2rosFloatArr", "float",4)  # termination = input of neuron (4xfloat)
neuron.createDecoder("ros2annFloatArr", "int",2)    # origin = output of neuron (min and max)

many=net.add(neuron)                    # add it into the network

#Create a white noise input function with params: baseFreq, maxFreq [rad/s], RMS, seed
input=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) 

net.add(input) # Add to the network and connect to neuron
net.connect(input,neuron.getTermination('ann2rosFloatArr'))


print 'Configuration complete.'
コード例 #3
0
ファイル: 02modemOneTurtle.py プロジェクト: jvitku/nengo_1.4
# create group with a name
g = NodeGroup("zelvicka", True);
g.addNC(turtlesim, "zelva", "native");  # start native node called zelva
g.addNC(modem,"turtlemodem","modem")  
g.startGroup()

################################## 
################# get modem, create smart neuron with inputs/outputs

modem = g.getModem()
bigneuron = NeuralModule('TurtleController',modem)

bigneuron.createDecoder("turtle1/pose", "pose")                 # origin
bigneuron.createDecoder("turtle1/color_sensor", "color")        # origin
bigneuron.createEncoder("turtle1/command_velocity", "velocity") # termination

# create nef.SimpleNode
many=net.add(bigneuron)

#Create a white noise input function with parameters: baseFreq, maxFreq (rad/s), RMS, Seed
input=FunctionInput('Randomized input', [FourierFunction(.5, 10, 6, 12),
    FourierFunction(2, 11, 5, 17)],
    Units.UNK) 

# Add the input node to the network and connect it to the smart enuron
net.add(input)  
net.connect(input,many.getTermination('turtle1/command_velocity'))

# make neural network and connect it to the smart neuron 
A=net.make('PositionData',neurons=10,dimensions=5,radius=20)
コード例 #4
0
ファイル: 02FloatToIntAsync.py プロジェクト: jvitku/nengo_1.4
################# define the group and start it
finder = "resender.mpt.F2IPubSub"
# Jva (ROS) node that does this job
modem = "nengoros.comm.nodeFactory.modem.impl.DefaultModem"

g = NodeGroup("MinMaxFinder", True)
g.addNC(finder, "Finder", "java")
g.addNC(modem, "Modem", "modem")
g.startGroup()

##################################
################# setup the smart neuron and add it to the Nengo network
modem = g.getModem()
neuron = NeuralModule("MinMaxFinder", modem)

neuron.createEncoder("ann2rosFloatArr", "float", 4)
neuron.createDecoder("ros2annFloatArr", "int", 2, False)  # HERE: decorer is asynchronous

many = net.add(neuron)

# Create a white noise input function with params: baseFreq, maxFreq [rad/s], RMS, seed
input = FunctionInput(
    "Randomized input",
    [
        FourierFunction(0.1, 10, 1, 12),
        FourierFunction(0.4, 20, 1.5, 11),
        FourierFunction(0.1, 10, 0.9, 10),
        FourierFunction(0.5, 11, 1.6, 17),
    ],
    Units.UNK,
)
コード例 #5
0
ファイル: 002rosTurtle.py プロジェクト: jvitku/nengo_1.4
################################## 
################# get modem, create neural subsystem with inputs/outputs

modem = g.getModem()                                        # get neuron  
module = NeuralModule('TurtleController',modem)              # create a module in Nengo with turtle modem

# 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
module.createDecoder("turtle1/color_sensor", "color")        # origin
module.createEncoder("turtle1/command_velocity", "velocity") # termination

# build the subsystem in Nengo, thats it
subsystem=net.add(module)


################################## 
################# create other ANN components (in Nengo)

# Create a white noise generator with parameters: baseFreq, maxFreq (rad/s), RMS, Seed
input=FunctionInput('Randomized input', [FourierFunction(.5, 10, 6, 12),
    FourierFunction(2, 11, 5, 17)],
    Units.UNK) 
net.add(input)  # add to Nengi gui

# make two neural networks which approximate its inputs