Esempio n. 1
0
subsystem=net.add(module)


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

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

# make neural network and connect it to the smart neuron 
A=net.make('PositionData',neurons=10,dimensions=5,radius=20)
net.connect(module.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(module.getOrigin('turtle1/color_sensor'),B)


# in order to stop all nodes in the group you can either:
#   -delete the main network from nengo (roscore and graph stay running)
#   -rerun the script  (all nodes will shutdown and start again)
#   -close nengo (everything shuts down)
print "OK, configuration done."
Esempio n. 2
0
# creates nef network and adds it to nengo (this must be first in the script) 
net=nef.Network('Two Neural modules containing ROS nodes with communication shielded from each other')
net.add_to_nengo()  # here: delete old (toplevel) network and replace it with the newly CREATED one
					# any poteintial running ROS nodes are sopped here

################ Run two groups of nodes (conenct them in nengo)
g = NodeGroup("Publisher", True);        			
g.addNode(pub, "Publisher", "java");     	# add the publisher node
module = NeuralModule("Publisher", g)    		
module.createDecoder("org/hanns/demonodes/pubsub", "float", 7) 
net.add(module)	

g2 = NodeGroup("Subbscriber", True);        			
g2.addNode(sub, "Subbscriber", "java");     	# add the publisher node
module2 = NeuralModule("Subscriber", g2)    		
module2.createEncoder("org/hanns/demonodes/pubsub", "float", 7)
net.add(module2)	

net.connect(module.getOrigin('org/hanns/demonodes/pubsub'),module2.getTermination('org/hanns/demonodes/pubsub'))						

print 'Configuration complete - communication between ROS nodes is handled by the Nengo now'
print 'Note that both nodes are running:'
print '-Publisher periodically publishes data'
print '-Subscriber does not receive any data, because Nengo simulation is not running and data are not sent'
print 'Try to start the simulation'
print ''
print 'Note that due to asynchornous communication, the sample rate of Nengo is faster than publishing rate of Publisher'