Neurorobotics Platform (NRP) experience code used in the SMI Project for the Telluride Neuromorphic Engineering Workshop 2021.
- Neurorobotics Platform 3
- Be sure to have the local NRP on Docker up and running.
- Warning: the Windows Version on WSL2 is quite slow. Running on Linux is recommended.
- For simplicity during development, attach your running NRP backend container on VSCode with the Remote Containers extension. See the tutorial of Antoine Detailler for more information.
- Download this repository as a ZIP file and import it in the NRP using the "Import Zip" button
This quick guide is here to help you install dependencies into separated virtualenvs. Here, we will install pytorch-cpu
(latest stable version) in a virtualenv
and build a Transfer Function to use it.
- Open an interactive terminal inside the Docker NRP (or in the attached Visual Studio Code window).
docker exec -it nrp bash
- Type the following instructions:
# create the virtual env named "pytorch"
virtualenv ~/.opt/pytorch
# activate it
source ~/.opt/pytorch/bin/activate
# install dependencies
pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
- Create a Transfer Function and copy the following code:
@nrp.Robot2Neuron()
def example_pytorch(t):
# make PyTorch available from home directory installation
import site, os
# WARNING: the path can change according to the python version you chose when initializing the virtualenv
site.addsitedir(os.path.expanduser('~/.opt/pytorch/lib/python3.8/site-packages'))
# output the time as a PyTorch tensor every 2s
import torch
tensor = torch.Tensor([t])
if t % 2 < 0.02:
clientLogger.info('Time: ', tensor)
- When you run a simulation, you will see the time printed every 2 secondes in the console logger inside the experiment.
You can also install a pip package without having to create a virtualenv. To do so, you have to use directly the experiment's virtualenv. Note that you may deal with conflicts in dependencies by doing so. Consequently, it is not recommended.
- Open an interactive terminal inside the Docker NRP (or in the attached Visual Studio Code window).
docker exec -it nrp bash
- Type de following commands :
# activate the 'platform_venv' virtualenv
source ~/.opt/platform_venv/bin/activate
# install dependencies
pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
- Create a Transfer Function and copy the following code:
import torch # we don't need to import it using site module
@nrp.Robot2Neuron()
def example_pytorch(t):
tensor = torch.Tensor([t])
if t % 2 < 0.02:
clientLogger.info('Time: ', tensor)
- When you run a simulation, you will see the time printed every 2 secondes in the console logger inside the experiment.
To facilitate the collaboration between all contributors during the project, try to commit and push changes directly inside the docker container when you're working on the NRP. If you installed the Experiment in the NRP as showed in the "Get Started" section, you can directly commit changes by using a docker interactive terminal.
- Open a docker interactive terminal and keep it during your work on the NRP:
# Open the docker terminal
docker exec -it nrp bash
# change directory to the experiment sources (this repository)
cd ~/.opt/nrpStorage/telluride_maze_husky_0_0_0
- Have fun playing with the sources!
- Now you can
git commit
orgit push
as you wish. - KEEP THE MAIN BRANCH CLEAN!. Creating branches is strongly recommended.