Esempio n. 1
0
def buildExperiment(net,wa,wb,wc,visibility=False):
    simName = util.randomString(20);
    net.add_to_nengo()  

    numsensors=4                                # number of agents sensors (if changed, need to read correct values in the Controller)

    simulator = oneAgent(net,agentName='a',numSensors=numsensors,maxDistance=120, frictionDistance=0,nameSpace=simName,visible=visibility);
    vivae = simulator.getControls();

    # Input->LI
    controller = net.add(EventGenerator('Agent controller',numsensors*2+1,2,1));            # event generator
    input = net.make_input('bias1',[1])                                                     # should result in 0, 0, .33
    net.connect(input, controller.getTermination('params'))
    net.connect(simulator.getAgent('a').getOrigin(),controller.getTermination('inputs'))    # connect agent with controller

    # LII->LIII->Output
    input2 = net.make_input('bias2',[1])
    summer = net.add(Summer('Summator'));
    net.connect(input2,summer.getTermination('inputBias'));
    net.connect(controller.getOrigin('outputs'),summer.getTermination('inputData'))
    net.connect(summer.getOrigin('outputs'),simulator.getAgent('a').getTermination())

    saver = net.add(SpeedSaver('avg'))
    net.connect(simulator.getAgent('a').getOrigin(),saver.getTermination('data'));
    #saver = net.add(DataSaver('saver')) # save data ??
    return simulator
Esempio n. 2
0
def buildExperiment(net, wa, wb, wc, visibility=False):

    numsensors = 4  # number of agents sensors (if changed, need to read correct values in the Controller)

    simulator = oneAgent(net,
                         agentName='a',
                         numSensors=numsensors,
                         maxDistance=120,
                         frictionDistance=0,
                         nameSpace=simName,
                         visible=visibility,
                         mapName='data/scenarios/test/wallsIII.svg')
    vivae = simulator.getControls()

    # Input->LI
    controller = net.add(
        EventGenerator('Agent controller', numsensors * 2 + 1, 2, 1))
    # event generator
    input = net.make_input('bias1', [1])  # should result in 0, 0, .33
    net.connect(input, controller.getTermination('params'))
    net.connect(
        simulator.getAgent('a').getOrigin(),
        controller.getTermination('inputs'))  # connect agent with controller

    # LII->LIII->Output
    input2 = net.make_input('bias2', [1])
    summer = net.add(Summer('Summator'))
    net.connect(input2, summer.getTermination('inputBias'))
    net.connect(controller.getOrigin('outputs'),
                summer.getTermination('inputData'))
    net.connect(summer.getOrigin('outputs'),
                simulator.getAgent('a').getTermination())

    saver = net.add(SpeedSaver('avg'))
    net.connect(
        simulator.getAgent('a').getOrigin(), saver.getTermination('data'))
    #saver = net.add(DataSaver('saver')) # save data ??
    return simulator
Esempio n. 3
0
def buildExperiment(net, wa, wb, wc, visibility=False):

    numsensors = 4  # number of agents sensors (if changed, need to read correct values in the Controller)

    simulator = oneAgent(
        net,
        agentName="a",
        numSensors=numsensors,
        maxDistance=120,
        frictionDistance=0,
        nameSpace=simName,
        visible=visibility,
        mapName="data/scenarios/test/wallsIII.svg",
    )
    vivae = simulator.getControls()

    # Input->LI
    controller = net.add(EventGenerator("Agent controller", numsensors * 2 + 1, 2, 1))
    # event generator
    input = net.make_input("bias1", [1])  # should result in 0, 0, .33
    net.connect(input, controller.getTermination("params"))
    net.connect(
        simulator.getAgent("a").getOrigin(), controller.getTermination("inputs")
    )  # connect agent with controller

    # LII->LIII->Output
    input2 = net.make_input("bias2", [1])
    summer = net.add(Summer("Summator"))
    net.connect(input2, summer.getTermination("inputBias"))
    net.connect(controller.getOrigin("outputs"), summer.getTermination("inputData"))
    net.connect(summer.getOrigin("outputs"), simulator.getAgent("a").getTermination())

    saver = net.add(SpeedSaver("avg"))
    net.connect(simulator.getAgent("a").getOrigin(), saver.getTermination("data"))
    # saver = net.add(DataSaver('saver')) # save data ??
    return simulator
Esempio n. 4
0
        sensorydata = simulator.getAgent('a').getOrigin().getValues().getValues(); # columns: time, [distance sensors from the left, friction sensors from the left]
        actuatordata = controller.getOrigin('outputs').getValues().getValues();    # columns: time, left_wheel, right_wheel

        i.write('%1.3f,%s\n'%(self.t,list(sensorydata)))
        o.write('%1.3f,%s\n'%(self.t,list(actuatordata)))
        i.close()
        o.close()
        
#################################################################################
simName = util.randomString(20);
net=nef.Network('Vivae - Turning controller for agent')
net.add_to_nengo()  

numsensors=4                                # number of agents sensors (if changed, need to read correct values in the Controller)

simulator = oneAgent(net,agentName='a',numSensors=numsensors,maxDistance=120, frictionDistance=0,nameSpace=simName);
vivae = simulator.getControls();

#controller = net.add(Controller('Agent controller',2*numsensors+1,2,0)); # build controller
controller = net.add(TurnGenerator('Agent controller',2*numsensors+1,2,3)); # build explicit controller
input=net.make_input('input',[20, 0.0, 0.33])
net.connect(input,controller.getTermination('params'))
net.connect(simulator.getAgent('a').getOrigin(),controller.getTermination('inputs'))    # connect agent with controller
net.connect(controller.getOrigin('outputs'), simulator.getAgent('a').getTermination())  # connect controller to the agent


#saver = net.add(DataSaver('saver')) # save data ??

t=2;
dt=0.001;
print "OK, configuration done. Simulating network for "+repr(t)+" seconds"