def initVivae(numsensors): modem = "ctu.nengoros.comm.nodeFactory.modem.impl.DefaultModem"; server = "vivae.ros.simulator.server.SimulatorServer" # start the simulator server in own thread # Or it is possible to call the Vivae as a standalone application in the similar way: #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.addNode(server, "SimulatorServer", "java"); # run the simulator.. g.addNode(modem,"modem","modem") # add default modem.. g.startGroup() # start group normally #time.sleep(3) # if the process is native, it takes longer time to init the services !! TODO simulator = NeuralModule('VivaeSimulator', g) # create NeuralModule which is able to add/remove agents sc = simulator.getControls(); # this starts the control services.. sc.callSetVisibility(True); # make simulation window visible.. many=net.add(simulator) # add it to the Nengo network sc.callLoadMap('data/scenarios/test/walls.svg') #addAgent(name,numSensors, maxDistance, frictionSensor) sc.addAgent('a',2*numsensors, 120 ,0) sc.callStartSimulation() return simulator;
def initVivae(numsensors): modem = "ctu.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.addNode(server, "vivaeSimulator", "java"); # run the simulator.. g.addNode(modem,"modem","modem") # add default modem.. g.startGroup() # start group normally #time.sleep(3) # if the process is native, it takes longer time to init the services !! simulator = NeuralModule('VivaeSimulator', g) # 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',2*numsensors, 120 ,0) vivae.start() return simulator;
def make(net,name='Vivae Simulator', mapName='arena1.svg', numSensors=4,maxdist=30,frictdist=50,independent=True, useQuick=True): numSensors = numSensors*2 mn = 'data/scenarios/'+mapName # note that simulator is started externally, since SVG loaded in vivae hanged otherwise from unknown reason.. modem = "ctu.nengoros.comm.nodeFactory.modem.impl.DefaultModem"; # custom modem here server = "vivae.ros.simulatorControlsServer.ControlsServer" # call Vivae as a thread in Java from this process vv = ["./sb/../../../../simulators/vivae/build/install/vivae/bin/vivae","vivae.ros.simulatorControlsServer.ControlsServer"] vvj = ["vivae.ros.simulatorControlsServer.ControlsServer"] # create group of nodes g = NodeGroup("vivae", True); # if nameSpace not defined, create independent group #g.addNode(server,"vivaeSimulator", "java"); # run the simulator.. #g.addNode(vv, "vivaeSimulator", "native"); # run the simulator.. g.addNode(vvj, "vivaeSimulator", "java"); # run the simulator.. g.addNode(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',g) # 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',2*numsensors, 120 ,0) vivae.start() """ print 'loaigin' vivae.loadMap(mn) agentNames = ['a','b','c','d','e','f','g','h','i','j','k','l','m'] # run as many agents as map can hold (up to a-m) for i in range(0, len(agentNames)): vivae.addAgent(agentNames[i], numSensors, maxdist, frictdist) print 'starting' vivae.start() """ vivae.loadMap(mn) agentNames = ['a','b','c','d','e','f','g','h','i','j','k','l','m'] # run as many agents as map can hold (up to a-m) for i in range(0, len(agentNames)): Controls.addAgent(agentNames[i], numSensors, maxdist, frictdist) """ # vivae.start() print 'Vivae is ready.'
def init(net, mapName=Sim.Maps.DEFAULT, visible=False): # create group of nodes g = NodeGroup("vivae", True); # create default group of nodes g.addNode(server, "SimulatorServer", "java"); # run the simulator.. g.addNode(modem,"modem","modem") # add default modem.. g.startGroup() # start group normally simulator = NeuralModule('VivaeSimulator',g) # create NeuralModule which is able to add/remove agents vivae = simulator.getControls(); # this starts the control services.. vivae.callSetVisibility(visible); # make simulation window visible.. result=net.add(simulator) # add it to the Nengo network vivae.callLoadMap(mapName) # loads the map into the simulator and waits for start or agents return simulator;
def initVivae(numsensors, visible=False): modem = "ctu.nengoros.comm.nodeFactory.modem.impl.DefaultModem"; server = "vivae.ros.simulator.server.SimulatorServer" # start the simulator server in own thread # create group of nodes g = NodeGroup("vivae", True); # create default group of nodes g.addNode(server, "SimulatorServer", "java"); # run the simulator.. g.addNode(modem,"modem","modem") # add default modem.. g.startGroup() # start group normally simulator = NeuralModule('VivaeSimulator',g) # create NeuralModule which is able to add/remove agents vivae = simulator.getControls(); # this starts the control services.. vivae.callSetVisibility(visible); # make simulation window visible.. many=net.add(simulator) # add it to the Nengo network vivae.callLoadMap('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.callStartSimulation() return simulator;