Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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;
Ejemplo n.º 3
0
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;
Ejemplo n.º 4
0
from nengoros.modules.impl import DefaultNeuralModule as NeuralModule
from nengoros.comm.nodeFactory import NodeGroup as NodeGroup
from nengoros.comm.rosutils import RosUtils as RosUtils

#####################################################################
# setup the ROS utils (optional, takes effect only if ROS found) 
RosUtils.setAutorun(True)
RosUtils.prefferJroscore(False)

# define nodes I want to use 
turtlesim = "../testnodes/turtlesim/turtlesim_node"  # turtle under this project
act =   "resender.turtle.Controller";
sense = "resender.turtle.PositionSensor";

# create group for turtle
g = NodeGroup("zelvicka", True);    # True menas that group is independent, can be pushed into namespace 
g.addNC(turtlesim, "zelva", "native");  
g.addNC(act, "actuators", "java");      
g.addNC(sense, "sensors", "java");
 
# create identical group for another turtle
g2 = NodeGroup("zelvicka", True);
g2.addNC(turtlesim, "zelva", "native");  
g2.addNC(act, "actuators", "java");      
g2.addNC(sense, "sensors", "java");

# start them
g.startGroup();
g2.startGroup();

# that is it, this will run forever.. 
Ejemplo n.º 5
0
################################## 
################# setup the ROS utils (optional) 
#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
RosUtils.prefferJroscore(False) # Turlte prefers roscore before jroscore (don't know why..) 

################################## 
################# 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')
Ejemplo n.º 6
0
##################################
################# setup the ROS utils (optional)
# RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
RosUtils.prefferJroscore(False)  # Turlte prefers roscore before jroscore (don't know why..)

##################################
################# 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)
Ejemplo n.º 7
0
################################## 
################# setup the ROS utils (optional) 
#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
RosUtils.prefferJroscore(False) # Turlte prefers roscore before jroscore (don't know why..) 

################################## 
################# 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
Ejemplo n.º 8
0
# creates nef network and adds it to nengo (this must be first in the script) 
net=nef.Network('Testing synchronous communication with ROS')
net.add_to_nengo()  # here: delete old (toplevel) network and replace it with the newly CREATED one

################################## 
################# setup the ROS utils (optional) 
#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
#RosUtils.prefferJroscore(True)  # preffer jroscore before the roscore? 

################################## 
################# define the group and start it
finder = "resender.mpt.F2FPubSub";      # 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", "float",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
Ejemplo n.º 9
0
#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
RosUtils.prefferJroscore(False) # Turlte prefers roscore before jroscore (don't know why..) 

################################## 
################# define the group and start it
modemCl  = "nengoros.comm.nodeFactory.modem.impl.DefaultModem"; # custom modem here
vv = "vivae.ros.simulatorControlsServer.ControlsServer"       # actual Vivae simulator, provies services

# create group of nodes
"""
note that each agent does not have own Nengo node, rather NeuralModule corresponding
to vivae simultor will have methods addAgent and removeAgent.
Each call of AddAgent method adds origin and termination to this main modem.
Each call of RemoveAgent should remove corresponding origin and termination from the neuron.  
""" 
g = NodeGroup("vivae", True);           # create default group of nodes
g.addNC(vv, "vivaeSimulator", "java");  # add vivae ControlsServer (node that handles simulation)
g.addNC(modemCl,"modem","modem")          # add default modem..
g.startGroup()                          # start group normally

################################## 
################# get modem, create smart neuron with inputs/outputs

modem = g.getModem()                    
simulator = NeuralModule('VivaeTest',modem)  # create NeuralModule which is able to add/remove agents

Controls = simulator.getControls();     # this starts the control services..
many=net.add(simulator)                 # add it to the Nengo network

time.sleep(2)    # give it some time to init services
Ejemplo n.º 10
0
from ca.nengo.model import Units
from nengoros.modules.impl import DefaultNeuralModule as NeuralModule
from nengoros.comm.nodeFactory import NodeGroup as NodeGroup
from nengoros.comm.rosutils import RosUtils as RosUtils

# creates nef network and adds it to nengo (this must be first in the script)
net = nef.Network("Testing synchronous communication with ROS - Decoder is asynchronous")
net.add_to_nengo()  # here: delete old (toplevel) network and replace it with the newly CREATED one

##################################
################# 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
Ejemplo n.º 11
0
from ca.nengo.model import Units
from nengoros.modules.impl.vivae import VivaeNeuralModule as VivaeNeuron
from nengoros.modules.impl import DefaultNeuralModule as NeuralModule
from nengoros.comm.nodeFactory import NodeGroup as NodeGroup
from nengoros.comm.rosutils import RosUtils as RosUtils
from nengoros.modules.impl.vivae.impl import SimulationControls as Controls

net=nef.Network('Vivae tests')
net.add_to_nengo()  # here: delete old (toplevel) network and replace it with the newly CREATED one

modemCl  = "nengoros.comm.nodeFactory.modem.impl.DefaultModem"; # commands to launch default modem, vivae simulator, minmax
vv = ["./sb/../../../../simulators/vivae/build/install/vivae/bin/vivae","vivae.ros.simulatorControlsServer.ControlsServer"]
minmax = "resender.mpt.F2FPubSub";

# run vivae
g = NodeGroup("vivae", True);           # create default independent group of nodes
g.addNC(vv, "vivaeSimulator", "native");# add vivae ControlsServer (node which handles the simulation)
g.addNC(modemCl,"modem","modem")        # add a default modem..
g.startGroup()                          # start group normally

time.sleep(2)                           # give it some time to init services
modem = g.getModem()                    
simulator = VivaeNeuron('VivaeTest',modem)  # create NeuralModule which is able to add/remove agents

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()
Ejemplo n.º 12
0
################################## 
################# setup the ROS utils (optional) 
#RosUtils.setAutorun(False)     # Do we want to autorun roscore and rxgraph? (tru by default)
RosUtils.prefferJroscore(False) # Turlte prefers roscore before jroscore (don't know why..) 

################################## 
################# define the group and start it

###############################3 tady tady: 
rosnodetester = "rosnode info zelvicka/zelva";   # nengoros should execute "whic rosnode", then "rosnode turt..  [some trash..]"
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.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