A digital lab notebook. Topics range from scientific computing using Python to neurobiology of Drosophila.
Thursday, August 23, 2012
Cool tool for converting rst to html
http://www.tele3.cz/jbar/rest/rest.html
Installing fview and Strokelitude from Scratch
Install Ubuntu
This step is not stictly necessary, but everything works in Lucid, so it may save time.
- Download and install Ubuntu 10.04 (Lucid) from http://www.ubuntu.com/download/ubuntu/download
- Often the display will be improved by looking under System>Administration>Hardware Drivers for video card drivers.
- Run the Update Manager (under System>Administration).
Install fview
Andrew Straw wrote fview, a general purpose video acquistion application. Strokelitude (also by Dr. Straw) is a plugin for fview.
Add the repositories, following the instructions at http://code.astraw.com/projects/motmot/download.html
sudo add-apt-repository ppa:astraw/ppa sudo wget --output-document=/etc/apt/sources.list.d/astraw.list http://debs.astraw.com/sources.list.d/astraw-$(lsb_release -cs).list sudo apt-get update && sudo apt-get install astraw-keyring && sudo apt-get update
From synaptic (System>Administration>Synaptic Package Manager) install the following packages with all their dependencies:
- camiface
- python-motmot-fview
- libhdf5-serial-1.8.4
- hdf5-tools
- python-tables
- python-enthought-traits
- python-enthought-traits-ui
- python-chaco
- python-pylibusb
- pyro
- python-motmot-fastimage
- python-motmot-realtimeimageanalysis
- python-motmot-fviewexttrig
- git-core
Test fview by typing fview at a terminal (Applications>Accessories>Terminal) or going to Applications>Sound & Video>fview don't worry about error message:
While attempting to open the plugin "fview_ext_trig", FView encountered an error. The error is: Cannot find device. (Perhaps run with environment variable REQUIRE_TRIGGER=0.)
Initialize the camera by going to Camera>initialize camera...
Note: If you are using a firewire (1394) camera and you cannot initialize it, try running sudo fview instead. Also, run the following command in a terminal:
sudo adduser $USER video sudo chown .video /dev/raw1394
then log out and log back in.
Install strokelitude
Now we are ready to install the plugin, "strokelitude," that actually tracks the wing positions.
In a terminal, type:
mkdir src cd src git clone git://github.com/astraw/remote_traits.git cd remote_traits/ sudo python setup.py install cd .. git clone git://github.com/motmot/strokelitude.git cd strokelitude/ sudo python setup.py install
Start fview, you should now see strokelitude as an option under Windows.
Install ROS (Electric)
The easiest way to save strokelitude data is to install ROS (Robot Operating System) and save the "topics" that strokelitude "publishes" in a .bag file. In order to do this, we install ROS, then start roscor before opening fview. We record using the rosbag record command.
Follow the instructions at http://www.ros.org/wiki/electric/Installation/Ubuntu . Briefly, you need to do the following. In a terminal, type:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu lucid main" > /etc/apt/sources.list.d/ros-latest.list' wget http://packages.ros.org/ros.key -O - | sudo apt-key add - sudo apt-get update sudo apt-get install ros-electric-desktop-full echo "source /opt/ros/electric/setup.bash" >> ~/.bashrc . ~/.bashrc
The fourth line will take some time -- you are installing all of ROS.
Now we'll need to create a directory in which we can place ROS scripts (see http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment ). In a terminal, type
cd ~/src mkdir ros_workspace cd ros_workspace
We want to tell ROS that this directory will contain ROS scripts. Create a file named setup.sh:
#!/bin/sh source /opt/ros/electric/setup.bash export ROS_ROOT=/opt/ros/electric/ros export PATH=$ROS_ROOT/bin:$PATH export PYTHONPATH=$ROS_ROOT/core/roslib/src:$PYTHONPATH export ROS_PACKAGE_PATH=~/src/ros_workspace:/opt/ros/electric/stacks:$ROS_PACKAGE_PATH
then run the file using the command . setup.sh
To make this change permanent, assuming the setup.sh file is in your home directory, add to the bottom of your .bashrc file:
source ~/src/ros_workspace/setup.sh
Now we are ready to install the package that defines the message type strokelitude will publish in ROS. In a terminal type:
git clone git://github.com/motmot/strokelitude_ros.git rospack profile rosmake strokelitude_ros rosdep install rxtools rosmake roscpp_tutorials rospy_tutorials rxtools roscore
then open fview by typing fview in a new terminal. Open the strokelitude window and click box next to 'Processing enabled'
In a new terminal type rxplot /strokelitude/left_wing_angle_radians /strokelitude/right_wing_angle_radians in order to view a realtime plot of the fview data
In new terminal, navigate to the directory where you want to record data, then type rosbag record -O data /strokelitude (this will save data in data.bag file)
To import your data into Python, do something like the following in a python script:
import roslib roslib.load_manifest('rosbag') import rosbag bag = rosbag.Bag('data.bag') leftWingRad=list() rightWingRad=list() for topic, msg, t in bag.read_messages(): leftWingRad.append(msg.left_wing_angle_radians) rightWingRad.append(msg.right_wing_angle_radians)
Install strokelitude-jfi-emulator
If you want to do closed-loop experiments using the Reiser panels, probably the simplest way is to use the mcc analog output board to output an analog voltage proportional to each wingstroke. In order to install this, follow these steps:
Using synaptic package manager, install libmcclibhid
Plug in the usb1208FS (this used to be called pmd1208FS and those work also) and test it by running the command sudo testusb1208FS in a terminal. Type 'b' to blink the LED.
Using synaptic, install python-wjul. This allows Python access to the usb1208FS.
install strokelitude-jfi-emulater by typing the following into a terminal:
cd src git clone git://github.com/motmot/strokelitude-jfi-emulator.git cd strokelitude-jfi-emulator sudo python setup.py install
Good high power IR LED
SFH 4230 Golden Dragon Package, half angle ±60°, 850nm, typ. 440 mW at 1A dc.
http://catalog.osram-os.com/catalogue/catalogue.do?favOid=00000000000207c000ed0023&act=showBookmark
Arduino control of polarization switcher
Setting up Simple Step
Using synaptic, install gcc-avr, avr-libc, and dfu-programmer.
cd src
mkdir MyUSB
cd MyUSB
Download MyUSB v 1.4.1 from http://www.fourwalledcubicle.com/LUFA.php and extract it to MyUSB
make all
cd ~/src
hg clone https://bitbucket.org/willdickson/simple_step
cd simple_step/firmware
gedit Makefile
Change line 24 to
MYUSB_SRC_DIR = /home/<username>/src/MyUSB/MyUSB
Exit gedit
cd src
gedit Makefile
Change line 53 to
MYUSB_SRC_DIR = /home/<username>/src/MyUSB/MyUSB
cd ..
make
cd ~/src/simple_step/firmware
Press the 'RST' and 'HWB' buttons on the atmel simultaneously, then release the 'RST' button, then the 'HWB' button.
sudo make program
cd ~/src/simple_step/firmware
sudo cp udev_rules/99-simple_step.rules /etc/udev/rules.d
sudo addgroup simple-step
sudo usermod -a -G simple-step <username>
Reboot
Install pylibusb
cd simple_step/api/python
sudo python setup.py install
Setting up Python PControl
Install mercurial via synaptic
cd src
hg clone https://bitbucket.org/willdickson/panel_comm
cd panel_comm
sudo python setup.py install
Setting up Arduino in Ubuntu
sudo apt-get install gcc-avr avr-libc
Download newest release from http://arduino.cc/en/Main/Software and extract it to a convenient location.
Double clicking on the arduino file should start the program.
sudo usermod -aG dialout <myuser>
BEWARE: Serial.println in a loop can cause entire Java Arduino program to lock up because it locks up the serial ports, which are scanned every time you click the tools menu (upload a different sketch using windows or mac to fix the problem)