def initVivae(numsensors): modem = "nengoros.comm.nodeFactory.modem.impl.DefaultModem"; # custom modem here server = "vivae.ros.simulatorControlsServer.ControlsServer" # call Vivae as a thread in Java from this process # Call Vivae as an external process #server = ["./sb/../../../../simulators/vivae/build/install/vivae/bin/vivae","vivae.ros.simulatorControlsServer.ControlsServer"] # create group of nodes g = NodeGroup("vivae", True); # create default group of nodes g.addNC(server, "vivaeSimulator", "java"); # run the simulator.. g.addNC(modem,"modem","modem") # add default modem.. g.startGroup() # start group normally modem = g.getModem() #time.sleep(3) # if the process is native, it takes longer time to init the services !! simulator = NeuralModule('VivaeSimulator',modem) # create NeuralModule which is able to add/remove agents vivae = simulator.getControls(); # this starts the control services.. vivae.setVisible(True); # make simulation window visible.. many=net.add(simulator) # add it to the Nengo network vivae.loadMap('data/scenarios/test/wallsII.svg') #addAgent(name,numSensors, maxDistance, frictionSensor) (note that you will actually get numSensors+1 floats +(speed)) vivae.addAgent('a',2*numsensors, 120 ,0) vivae.start() return simulator;
def initVivae(numsensors): modem = "nengoros.comm.nodeFactory.modem.impl.DefaultModem" # custom modem here server = "vivae.ros.simulatorControlsServer.ControlsServer" # call Vivae as a thread in Java from this process # Call Vivae as an external process #server = ["./sb/../../../../simulators/vivae/build/install/vivae/bin/vivae","vivae.ros.simulatorControlsServer.ControlsServer"] # create group of nodes g = NodeGroup("vivae", True) # create default group of nodes g.addNC(server, "vivaeSimulator", "java") # run the simulator.. g.addNC(modem, "modem", "modem") # add default modem.. g.startGroup() # start group normally modem = g.getModem() #time.sleep(3) # if the process is native, it takes longer time to init the services !! simulator = NeuralModule( 'VivaeSimulator', modem) # create NeuralModule which is able to add/remove agents vivae = simulator.getControls() # this starts the control services.. vivae.setVisible(True) # make simulation window visible.. many = net.add(simulator) # add it to the Nengo network vivae.loadMap('data/scenarios/test/wallsII.svg') #addAgent(name,numSensors, maxDistance, frictionSensor) (note that you will actually get numSensors+1 floats +(speed)) vivae.addAgent('a', 2 * numsensors, 120, 0) vivae.start() return simulator
def initVivae(modem,server): # create group of nodes g = NodeGroup("vivae", True); # create default group of nodes g.addNC(server, "vivaeSimulator", "java"); # run the simulator.. g.addNC(modem,"modem","modem") # add default modem.. g.startGroup() # start group normally modem = g.getModem() #time.sleep(3) # if the process is native, it takes longer time to init the services !! simulator = NeuralModule('VivaeTest',modem) # create NeuralModule which is able to add/remove agents vivae = simulator.getControls(); # this starts the control services.. vivae.setVisible(True); # make simulation window visible.. many=net.add(simulator) # add it to the Nengo network vivae.loadMap('data/scenarios/test/walls.svg') #addAgent(name,numSensors, maxDistance, frictionSensor) vivae.addAgent('a',8, 120 ,0) vivae.start() return simulator;
################# define the group and start it modem = "nengoros.comm.nodeFactory.modem.impl.DefaultModem"; # custom modem here # this is launch command which calls the RosRun with name of ControlsServer as parameter #vvv = ["./sb/../../../../simulators/vivae/build/install/vivae/bin/vivae","vivae.ros.simulatorControlsServer.ControlsServer"] vvv = "vivae.ros.simulatorControlsServer.ControlsServer" # actual Vivae simulator, provies services # create group of nodes g = NodeGroup("vivae", True); # create default group of nodes g.addNC(vvv, "vivaeSimulator", "java"); # run the simulator.. g.addNC(modem,"modem","modem") # add default modem.. g.startGroup() # start group normally ################################## modem = g.getModem() time.sleep(3) # if the process is native, it takes longer time to init the services !! simulator = NeuralModule('VivaeTest',modem) # create NeuralModule which is able to add/remove agents Controls = simulator.getControls(); # this starts the control services.. Controls.setVisible(False); many=net.add(simulator) # add it to the Nengo network #Controls.loadMap('data/scenarios/arena2.svg') #Controls.loadMap('data/scenarios/ushape.svg') Controls.loadMap('data/scenarios/arena1.svg') #Controls.loadMap('data/scenarios/manyAgents.svg') Controls.addAgent('a',4) Controls.addAgent('b',18) Controls.addAgent('c',18,30,50)
################# define the group and start it 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
################################## ################# define the group and start it 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(.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)
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.addNC(rosnodetester,"rosnodetest","native") # teeeeeeeeeeeeeeeeest g.startGroup() # start all nodes in the group ################################## ################# get modem, create neural subsystem with inputs/outputs modem = g.getModem() # get neuron module = SmartNeuron('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)