Thursday, August 23, 2012

Cool tool for converting rst to html

This website will convert restructured text to html. I used it to convert a document I had written in rst to html for the last post on this blog.

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
  • 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

    sudo add-apt-repository ppa:astraw/ppa
    sudo wget --output-document=/etc/apt/sources.list.d/astraw.list$(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://
    cd remote_traits/
    sudo python install
    cd ..
    git clone git://
    cd strokelitude/
    sudo python 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 . Briefly, you need to do the following. In a terminal, type:

    sudo sh -c 'echo "deb lucid main" > /etc/apt/sources.list.d/ros-latest.list'
    wget -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 ). 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

    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 .

    To make this change permanent, assuming the file is in your home directory, add to the bottom of your .bashrc file:

    source  ~/src/ros_workspace/
  • 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://
    rospack profile
    rosmake strokelitude_ros
    rosdep install rxtools
    rosmake roscpp_tutorials rospy_tutorials rxtools

    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')
    for topic, msg, t in bag.read_messages():

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://
    cd strokelitude-jfi-emulator
    sudo python install

Good high power IR LED

This is a good high power infrared LED:

SFH 4230 Golden Dragon Package, half angle ±60°, 850nm, typ. 440 mW at 1A dc. 



Arduino control of LED

Here is code to control the intensity of an LED using Arduino.

Arduino control of polarization switcher

Here is the code that I used in the Arduino box to control the polarization rotator (switcher). (I think...)

Setting up Simple Step

These are my notes on setting up Simple Step, a program by Will Dickson for controlling stepper motors.

Using synaptic, install gcc-avr, avr-libc, and dfu-programmer.

cd src
mkdir MyUSB
cd MyUSB

Download MyUSB v 1.4.1 from and extract it to MyUSB

make all

cd ~/src
hg clone
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 ..
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>

Install pylibusb

cd simple_step/api/python
sudo python install

Setting up Python PControl

These are my notes on setting up Python PControl:

Install mercurial via synaptic

cd src
hg clone
cd panel_comm
sudo python install

Setting up Arduino in Ubuntu

These are my notes from setting up Arduino in Ubuntu Lucid 10.04:

sudo apt-get install gcc-avr avr-libc
Download newest release from 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)

Tuesday, August 21, 2012

test strokelitude and ROS

This is useful: rxplot /strokelitude/left_wing_angle_radians