示例#1
0
turtlesim = "../testnodes/turtlesim/turtlesim_node"  # turtle under this project
act = "resender.turtle.Controller"
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
################################## 
################# 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'))
示例#3
0
Controls = simulator.getControls();     # this starts the control services..
many=net.add(simulator)                 # add it to the Nengo network

Controls.loadMap('data/scenarios/arena2.svg') 
Controls.addAgent('a',4)
Controls.start()

# run minMax node
g = NodeGroup('minMaxFinder', True);# create independent group called..
g.addNC(minmax, "MinMax","java");       # start java node and name it finder
g.addNC(modemCl,"Modem", "modem")       # add modem to the group
g.startGroup()

modem = g.getModem()
neuron = NeuralModule('MinMaxFinder',    modem)      # construct the smart neuron 
neuron.createEncoder("ann2rosFloatArr", "float",4)  # termination = input of neuron (4xfloat)
neuron.createDecoder("ros2annFloatArr", "float",2)  # origin = output of neuron (min and max)
minmaxN=net.add(neuron)                    # add it into the network

# make neural ensemble 
A=net.make('Controls',neurons=50,dimensions=2,radius=2)

net.connect(simulator.getAgent('a').getOrigin(), minmaxN.getTermination('ann2rosFloatArr'))
net.connect(minmaxN.getOrigin('ros2annFloatArr'),A)
net.connect(A,simulator.getAgent('a').getTermination())

print "OK, configuration done.  -- Open the network in GUI to see hot the controls are wired."
print "-one agent created inside the vivae simulator. Agent holds his origins/terminations"
print "-agent publishes vector of 4 variables (each for one sensor) and subscribes to two values for motor velocities"
print "-smart neuron called MinMax finds the min and max value from sensory data, these values sends to neural ensemble" 
示例#4
0
##################################
################# 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),
    ],
示例#5
0
turtlesim = "rosrun turtlesim turtlesim_node"   # command to start turtle installed in ROS
act = "resender.turtle.Controller";             
modem  = "nengoros.comm.nodeFactory.modem.impl.DefaultModem"; # add a default model to the turtle

# create group with a name
g = NodeGroup("zelvicka", True);        # create group of ROS nodes (equals to one neural subsystem)
g.addNC(turtlesim, "zelva", "native");  # add Node Configuration (turtle) to the group of nodes
g.addNC(modem,"turtlemodem","modem")    # add modem configuration to the group
g.startGroup()                          # start all nodes in the group

################################## 
################# 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)