This emulator was developed for an altered version of Bpod in the Erlich Lab. It has not yet been tested with the official Bpod firmware.
- Clone this repository
- Run install script
cd bpod-emulator; ./install_emulator_mac(for Mac)
cd bpod-emulator; ./install_emulator_linux(for Debian/Ubuntu)
Or install it manually:
- socat: Use
brew install socaton Mac - zeroMQ: Use
brew install zmqon Mac - zeroMQ C++ binding: Put
zmq.hppin search path
On Mac: copyzmq.hppto/usr/local/include - kivy: Python GUI framework
(Trypip install cythonandpip install kivyfirst)
Try this first:
./start_emulator [path_for_pty] [port_number_for_matlab]
(e.g.,./start_emulator ~/Desktop/emulator 9000)
(might need to runchmod 744 ./start_emulatorfor the first time)- Inside matlab:
start_bpod localhost 9000
Or start it manually:
- Start a socat relay process (in a different terminal):
socat -d -d pty,echo=0,raw TCP-LISTEN:9000,fork
(See TCP over socat if you want to understand what we are doing) - It will return something like this:
socat[36146] N PTY is /dev/ttys001
socat[36146] N listening on LEN=16 AF=2 0.0.0.0:9000 ./bpod_em /dev/ttys001(change the serial port path accordingly)python kivy_gui.py- Inside matlab:
start_bpod localhost 9000(change port number accordingly)
If you have installed bpod in a sister directory to this repository then:
cd FirmwareWrapper/./convert_firmware.sh
The covert_firmware.sh file will look for a specific firmware (used in the ErlichLab) and copy it and make the following changes:
- Add headers
setup()takes an extra input- Add this line to
setup() setup()andloop()need to be moved to the end of the code- Add delay to prevent emulator taking up all CPU time
If you are using this tool with Sanworks Bpod you will need to change one line of the script to point to the correct firmware.
Q: When i try to restart the emulator it doesn't start / i get errors. How do I fix this?
A: If Bpod is still running, you need to shut it down first.
Just like with real hardware, you cannot "unplug" and "re-plug" the emulator and
expect everything to work. In general, you should close Bpod first and then close the emulator.
Q: Sometimes when I click a poke, it registers as two pokes.
A: When you move focus to another window, the events when you bring focus back
to the emulator window are not handled well. It is recommended to click in the
background (not on a poke) to get focus back to the emulator before poking.
Q: I can't successfully start emulator even if I successfully install it on mac
A: Change g++ -std=c++11 -pthread -lzmq ./Firmware_Wrapper/main.cpp -o ./Firmware_Wrapper/bpod_em
to g++ -std=c++11 -I /usr/local/include -L /usr/local/lib -pthread -lzmq ./Firmware_Wrapper/main.cpp -o
./Firmware_Wrapper/bpod_em in start_emulator. Your need to explicitly specify your linker if it's not working.
