Author Jaroslav Vitku [vitkujar@fel.cvut.cz]
This repository contains set of nodes for purposes of demonstration of NengoROS integration. It also contains projectTemplate which can serve as a starting point for creating new (Nengo)ROS nodes in Java.
This is a part of NengoRos multi-project build, so there is no need to install any of the demo nodes.
In the complete installation of Nengoros, all demo scripts from this repository are symlinked into the folder nengo/simulator-ui/nr-demo
. To run these nodes, run Nengo
(or nengo-cl
):
cd nengo/simulator-ui/
./nengo
and open the demo script by writing the command into the Nengo console:
run nr-demo/minmaxint.py
The script helper
is able to initialize new Nengoros project for you. Running the script:
./demonodes/helper -i
will copy the proejctTemplate
into the nengo/
workspace. Feel free to rename it. You can now edit the example ROS nodes under src/main/java
.
In order to build your project run from the root of your project:
./gradlew build
To refresh (e.g. after renaming the folder) the eclipse project:
./gradlew eclipse
To install the project into the local maven repository:
./gradlew install
There are several possibilities how to run your newly created nodes:
Each ROSjava node produced in this way is 100% compatible with ROS infrastructure and can be launched either under roscore from ROS installation or jroscore from the nengoros project. To launch the node it is necessary to:
Create the runnable application by launching from the project root:
./gradlew installApp
Run the core, e.g. for jroscore:
cd nengoros/jroscore && ./jroscore
Launch the generated script with the full node name in a new terminal:
cd nengoros/projectTemplate
./build/install/projectTemplate/bin/projectTemplate org.hanns.myPackage.DemoPublisher
Launch subscriber to receive messages in a new terminal:
cd nengoros/projectTemplate
./build/install/projectTemplate/bin/projectTemplate org.hanns.myPackage.DemoSubscriber
Now, there should be two independently running ROSjava nodes which communicate over the TCP/IP via the ROS network. Note that you can change some properties of nodes by adding optional command line arguments, for more information, see remapping arguments.
In order to use this collection of nodes in Nengoros, you have to add a dependency of nengo/simulator-ui
sub-project on your project. To do this, you have to:
-
Edit the
settings.gradle
file and add the name of your new project there. So the result could be:// howto: '[folderName]:[subFolderName]:[projectName==folderName]' (no package names here) include 'logic:gates', 'projectTemplate'
-
add the dependency to the
nengo/simulator-ui
project by editing thenengo/simulator-ui/rosjava.build.gradle
, so the result could be:dependencies { compile project(':nengo:simulator') compile fileTree(dir: 'lib', include: '**/*.jar') compile 'ros.rosjava_core:rosjava:0.0.0-SNAPSHOT' compile 'org.hanns.logic:gates:0.0.1-SNAPSHOT' // // howto: '[projectFolder]:[projectName]' compile project('projectTemplate') }
-
Recompile and reinstall the Nengoros project by running:
./tool -nf
-
If you want to launch Nengo from class files, add new dependency to the
simulator-ui/nengo
(andnengo-cl
) scripts. That is e.g. to the local folder which is auto-generated by the command./gradlew install
:NODES=$NODES:$N_HOME/../../projectTemplate/build/libs/projectTemplate-0.0.1-SNAPSHOT.jar
In order to copy (or symlink) additional scripts and GUI data (described below) the script called demonodes/linkdata
can be used. This script deploys/links the following files into the Nengo simulator:
- RosNode helper scripts from:
[YourProjectFolder]/python/rosnodes/*
- Drag&Drop GUI images from:
[YourProjectFolder]/images/nengoIcons/*
- Drag&drop scripts from:
[YourProjectFolder]/python/nef/templates/*
- Other scripts from:
[YourProjectFolder]/python/scripts/*
- Nengoros demo scripts from:
[YourProjectFolder]/python/nr-demo/*
For more information about script usage, run:
./linkdata -h
From now, you can create simple python script which creates representation of your ROS nodes in the Nengo. Example of simple script, which:
- creates network
- for each ROS node creates NeuralModule
- places these new neural modules into the network
- connect them with other components
is contained under projectTemplate/python/myNetwork.py
, and after use of linkdata
script, this file should be linked under nengoros/nengo/simulator-ui/nr-demo/projectTemplate
.
Then, the script can be launched, simply run the ./nengo
and then write into the command-line interface: run
with relative path to your script, so e.g.:
run nr-demo/projectTemplate/myNetwork.py
This is not mandatory, but allows user to easily add nodes into the simulation in the GUI and to simplify use of new components in jython scripts. For more information about how to add a GUI template into the Nengo simulator, see the tutorial from the authors of Nengo on: http://nengo.ca/docs/html/advanced/dragndrop.html .
Basically, you have to:
- Add image of each node (group of nodes)under:
projectTemplate/images/nengoIcons
- For each new node (group of nodes), add an initialization script under:
projectTemplate/python/nef/templates
. - Link these files into the Nengo simulator (./linkdata -h)
- Add these new templates into the
nengo/simulator-ui/python/nef/templates/__init__.py
file - Restart Nengo, you should see your nodes in the left panel
- Update scirpts under
projectTemplate/python
to match information in thisREADME.md
- The tool should generate also files for ROS meta-package (for catkin support (package.xml et al)).