This first demo shows how to run very simple Nengoros simulation. It incorporates two ROS nodes in the Nengo simulation:
- MinMaxFloat – finds minimum and maximum from vector of 4 numbers and publishes the result
- MinMaxInt – does the same, but publisher she result as integers
The source java files for this demo are under the project ‘demonodes/basic‘, Jython scripts and GUI data for Nengo can be found mainly under ‘demonodes/basic/python‘ (these are copied to the simulator-ui project).
Loading the Script
The script can be found under the folder ‘nengo/simulator-ui/nr-demo/basic/minmax.py‘. In order to run it, open the Nengo GUI by running the script:
cd nengo/simulator-ui/ ./nengo
Then, write into the Nengo command line the following command:
This will launch the Jython script and do the following:
- Creates top-level network in the Nengo simulator (GUI)
- Creates two Neural Modules, each representing one ROS node
- Creates generator of vector of 4 numbers
- Connects the generator to the Neural Modules
- For each module creates Network of spiking neurons implementing identity transformation of 2D data sent by the module.
- Connects each module to its own network.
The representation of the resulting modular hybrid network in the Nengo GUI looks as follows. On the left, there is a data generator and on the right there are two neural ensembles. Each Neural Module is represented as a white dot with several terminations/origins, each for one topic received/sent by the corresponding ROS node.
- In the script, you can notice the following important details:
- ROS nodes are started immediately after adding them into the network
- Inputs/outputs of Neural Modules are named after “their” ROS topics
- The script uses another script, called `python/rosnodes/basic_nodes`for simplifying use of these nodes.
Helper Jython Scripts for Loading ROS Nodes
In the script basic_nodes, it can be seen how the Neural Modules are defined in Jython:
- First, a group of nodes is initialized
- Arbitrary number of ROS nodes is added (types can be: java, native and ros-based)
- Neural Module containing the group if created
- Necessary inputs/outputs are added
Note that encoder encodes ROS messages and therefore refers to termination (input of Neural Module) in the Nengo simulator. Each encoder/decoder is named after topic it received/sends and expect/produces specified type and size of data.
Ros Graph Visualisation
In case of you have ROS installed (e.g. Ubuntu), you can use the tool rqt to visualize the generated ROS network. To do this, run the rqt from new terminal (after the script is loaded in Nengo) and in the new GUI select: plugins/ROS Graph. The following visualization of ROS network should appear:
We can see the ROS network with two namespaces corresponding to our Neural Modules: AsynMinMaxFloat and AsynMinMaxInt. Each ROS namespace contains one ROS node and one corresponding Modem, depicted in ellipses. Rectangles represent communication topics, we can see that each modem publishes on and subscribes to one topic. SInce these topics are pushed into own namespaces (e.g. AsynMinMaxInt), both ROS nodes cannot communicate directly with each other.
Running the Simulation
In order to run the simulation in GUI, there are two main methods, the one with interactive plots is obtained by clicking on a button in the upper-right corner and then the “play” button. The resulting window should look as follows:
On the left there are controls and graph showing values generated by the generator. In the center there are values published by MinMaxInt and MinMaxFloat ROS nodes (their Neural Modules). And on the right there are values represented by neural ensembles together with their spike-trains.
This demo showed integration of ROS nodes into the simulation of a simple hybrid network.