public interface NeuralModule extends PeripheralsRegisteringNode, Node, Probeable
NeuralModule is similar to SimpleNode, but adds the support for ROS communication.
Each Module has own ROS modem. The Modem is a ROS node which provides access to the ROS Publisher/Subscriber to the Nengo simulator.
Each Module has own set of Encoders for encoding received data (on Termination(s)) into ROS messages and set of Decoders for decoding data from received ROS messages and setting them on the corresponding Origin.
Encoder has own ROS Publisher which publishes messages to given ROS topic. Decoder has own ROS Subscriber which is subscribed to (receives) selected ROS messages.
VisiblyMutable.Event, VisiblyMutable.Listener, VisiblyMutable.NameChangeEvent, VisiblyMutable.NodeRemovedEvent
Modifier and Type | Method and Description |
---|---|
void |
createDecoder(java.lang.String topicName,
java.lang.String dataType) |
void |
createDecoder(java.lang.String topicName,
java.lang.String dataType,
boolean synchronous) |
void |
createDecoder(java.lang.String topicName,
java.lang.String dataType,
int dimensionSize) |
void |
createDecoder(java.lang.String topicName,
java.lang.String dataType,
int[] dimensionSizes)
Add the Decoder to the Module, that is:
Subscribe to given ROS topic with expected type of data and expected dimensionality.
Add Decoder to Node in the Nengo with corresponding dimensionality.
|
void |
createDecoder(java.lang.String topicName,
java.lang.String dataType,
int[] dimensionSizes,
boolean synchronous)
The same as createDecoder, but the parameter synchronous tells whether
the created Decoder will be synchronous.
|
void |
createDecoder(java.lang.String topicName,
java.lang.String dataType,
int dimensionSize,
boolean synchronous) |
void |
createEncoder(java.lang.String topicName,
java.lang.String dataType) |
void |
createEncoder(java.lang.String topicName,
java.lang.String dataType,
int dimensionSize) |
void |
createEncoder(java.lang.String topicName,
java.lang.String dataType,
int[] dimensionSizes)
Add the Encoder to the neural module, that is:
Encoder is allowed to register own (potentially multiple) Termination(s) to the Node
Encoder encodes data received on own Termination(s) into the ROS
message according to the specified dataType and dimensionality
Encoder then publishes ROS message to given topicName each
simulation step.
Note: name of ROS node is specified by the Modem instance.
|
MultiTermination |
getMultiTermination(java.lang.String name)
This NeuralModule supports connecting multiple "inputs" to one Encoder.
|
Termination |
newTerminationFor(java.lang.String name)
In order to simplify connecting new inputs to the Encoder (MultiTermination in general),
this method can be use to create new Terminations.
|
Termination |
newTerminationFor(java.lang.String name,
float weight)
The same as the
newTerminationFor(String) ,
but here the weight can be specified. |
Termination |
newTerminationFor(java.lang.String name,
java.lang.Float[] weights)
The same as the
newTerminationFor(String) ,
but here the weight for each dimension can be specified. |
void |
setSynchronous(boolean synchronous)
Turn synchronous communication on/off.
|
addOrigin, addTermination, printOriginNames, printTerminationNames
clone, getChildren, getDocumentation, getName, getOrigin, getOrigins, getTermination, getTerminations, notifyAboutDeletion, run, setDocumentation, setName, toScript
reset
getMode, setMode
addChangeListener, removeChangeListener
getHistory, listStates
MultiTermination getMultiTermination(java.lang.String name) throws StructuralException
This NeuralModule supports connecting multiple "inputs" to one Encoder. It is accomplished by the fact that each Encoder has MultiTermination, where the MultiTermination can have several own Terminations, whose values are combined into one value.
The user is allowed to create new Terminations for Encoder. In order to do this, the Encoders MultiTermination has to be available. The MultiTermination is generated with identical name as the Encoder. This method provides access to the Encoders MultiTermination by its name.
name
- name of the Encoder==MultiTerminationStructuralException
- if no Encoder of such name foundTermination newTerminationFor(java.lang.String name) throws StructuralException
In order to simplify connecting new inputs to the Encoder (MultiTermination in general), this method can be use to create new Terminations. It receives name of the Encoded ROS topic (name of MultiTermination), crates new Termination with default weight (1), registers it to own MultiTermination and this NauralModule.
The MultiTermination in DefaultNeuralModule computes weighted sum of all its Terminations. The resulting value is then encoded and sent as a ROS message on the topic which corresponds to the Encoders name.
name
- name of MultiTermination to connect newly created Termination (this equals
to the name of ROS topic used by Encoder)StructuralException
- if the Termination could not be created (e.g. Encoder not found,
name is used etc.)
Encoder.getMultiTermination()
MultiTermination.addTermination()
Termination newTerminationFor(java.lang.String name, float weight) throws StructuralException
newTerminationFor(String)
,
but here the weight can be specified.name
- name of the ROS topic == name of the Encoder == name of the parent MultiTerminationweight
- terminations input is weightedStructuralException
- if the Termination could not be created{@link ctu.nengoros.comm.rosBackend.encoders.multiTermination.MultiTermination#addTermination(float)}
Termination newTerminationFor(java.lang.String name, java.lang.Float[] weights) throws StructuralException
newTerminationFor(String)
,
but here the weight for each dimension can be specified.name
- name of the Encoderweights
- array of weights, for each dimension one weightStructuralException
- exception if the Termination could not be created (e.g. dimension
of weight array provided is incorrect){@link ctu.nengoros.comm.rosBackend.encoders.multiTermination.MultiTermination#addTermination(Float[])}
void setSynchronous(boolean synchronous)
Turn synchronous communication on/off. Node is synchronous by default. If the synchronous communication is turned on, the Nengo simulator waits for messages from all synchronous Decoders of the Module each simulation step.
If the Module is set to asynchronous mode: the simulation does not wait for any of its childs. In the synchronous mode, only synchronous Decoders can block the simulation
.synchronous
- void createDecoder(java.lang.String topicName, java.lang.String dataType, int[] dimensionSizes)
topicName
- name of the ROS topicdataType
- type of datadimensionSizes
- list of dimension sizes (best support only for 1D vectors)void createDecoder(java.lang.String topicName, java.lang.String dataType, int dimensionSize)
void createDecoder(java.lang.String topicName, java.lang.String dataType)
void createEncoder(java.lang.String topicName, java.lang.String dataType, int[] dimensionSizes)
topicName
- name of the ROS topicdataType
- type of datadimensionSizes
- list of dimension sizes (best support only for 1D vectors)void createEncoder(java.lang.String topicName, java.lang.String dataType, int dimensionSize)
void createEncoder(java.lang.String topicName, java.lang.String dataType)
void createDecoder(java.lang.String topicName, java.lang.String dataType, int[] dimensionSizes, boolean synchronous)
The same as createDecoder, but the parameter synchronous tells whether the created Decoder will be synchronous. Nengo simulator will wait for all SynchedUnits each simulation step until they are ready.
In other words: synchronous Decoders block the Nengo simulation each time step until they receive ROS message on own ROS topic.
topicName
- name of the ROS topicdataType
- type of datadimensionSizes
- list of dimension sizes (best support only for 1D vectors)synchronous
- wait for incoming message after corresponding sent message?void createDecoder(java.lang.String topicName, java.lang.String dataType, int dimensionSize, boolean synchronous)
void createDecoder(java.lang.String topicName, java.lang.String dataType, boolean synchronous)