Ubuntu 16.04 NFD Development Machine

I shared how I setup my NFD development machine in 2017. Back then, NFD's minimum system requirement is Ubuntu 14.04 so my virtual machine is 14.04 as well. In May 2018, ndn-cxx started requiring Ubuntu 16.04, so it's time for a rebuild.

Vagrantfile for NFD Development in Ubuntu 16.04

Here's my new Vagrantfile:

$vmname = "devbox"
$sshhostport = 2222

$deps = <<SCRIPT
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get dist-upgrade -yq
apt-get install -yq git build-essential gdb valgrind libssl-dev libsqlite3-dev libboost-all-dev pkg-config libpcap-dev doxygen graphviz python-sphinx python-pip
pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics
SCRIPT

Vagrant.configure(2) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.network :forwarded_port, guest: 22, host: $sshhostport, id: "ssh"
  config.vm.provider "virtualbox" do |vb|
    vb.name = $vmname
    vb.memory = 6144
    vb.cpus = 8
  end
  config.vm.provision "deps", type: "shell", inline: $deps
  config.vm.provision "hostname", type: "shell", inline: "echo " + $vmname + " > /etc/hostname; hostname " + $vmname
  config.vm.provision "sshpvtkey", type: "file", source: "~/.ssh/id_rsa", destination: ".ssh/id_rsa"
  config.vm.provision "sshpubkey", type: "file", source: "~/.ssh/id_rsa.pub", destination: ".ssh/id_rsa.pub"
  config.vm.provision "sshauth", type: "shell", inline: "cd .ssh; cat id_rsa.pub >> authorized_keys"
  config.vm.provision "gitconfig", type: "file", source: "~/.gitconfig", destination: ".gitconfig"
end

Differences from 2017

Yuma Mega

Since my spontaneous visit of Pima Air & Space Museum on my 2015 birthday, I started a tradition of having a little road trip for every birthday. I rode a bike to Sweetwater Wetlands Park to see some birds with Tucson Audubon Society on my 2016 birthday. When my 2017 birthday came close, I planned something big: I wanted to attend the Yuma Mega, the biggest geocaching event in the Southwest region.

Finding the Event

I started geocaching as a hobby in 2013. Geocaching for me is mostly an individual sport: I rode bikes all over Tucson metro area, lift up lamp post covers and poke my hand into guardrails to find mint containers hidden within. Event Caches, on the other hand, are special geocaches that allow geocachers to gather and socialize. I browse Geocaching.com's event listing from time to time, and attend those events regularly. Normally, 15~30 people would show up in a local restaurant or city park. People would tell their stories, and plan out-of-state trips to search for large number of geocaches.

Yuma Mega is not just any event, but a "Mega-Event Cache". Geocaching HQ awards Mega status to events attracting more than 500 geocachers. I heard about Yuma Mega in 2015, but the date was adjacent to a conference trip so I wasn't able to arrange it. 2017's Yuma Mega event falls on Sunday Feb 12, which happens to be my birthday. 2017 is also my last year living in Arizona. It was "now or never", so I have to attend Yuma Mega!

I made up my mind on Nov 24, 2016, and booked a rental car and a motel room for the trip. Both reservations were cancelable in case there's a paper deadline on that weekend, but thankfully there wasn't one, so I'm greenlighted for the trip.

GPU Accelerated Contour Detection on PiCamera

Earlier this month, I spent a week building OpenCV 3.2.0, with the intention to reproduce the contour detection demo I witnessed at MoCoMakers meetup. I successfully made contour detection working on PiCamera through MJPEG streaming. P.S. Can you tell the Hack Arizona 2016 shirt?

contour on PiCamera

How MocoMakers's Demo Works

def makeContour(image):
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    gray = cv2.GaussianBlur(gray, (3, 3), 0)
    edged = auto_canny(gray)

def auto_canny(image, sigma=0.33):
    v = np.median(image)
    lower = int(max(0, (1.0 - sigma) * v))
    upper = int(min(255, (1.0 + sigma) * v))
    edged = cv2.Canny(image, lower, upper)
    return edged

Their code works with a MJPEG stream from an Android phone. It extracts a JPEG frame from the video stream, processes the image through makeContour function, and displays the result. The makeContour function converts the RGB image to grayscale, blurs the grayscale image, and runs the Canny Edge Detection algorithm.

Install OpenCV 3.2.0 on Raspberry Pi Zero W in 15 Minutes

OpenCV, or Open Source Computer Vision Library, is an open source computer vision and machine learning software. It works on Raspberry Pi computers, and can process photos captured by the Raspberry Pi Camera Module.

OpenCV has two supported versions: 2.4.x and 3.x. New features are being added to 3.x branch, while 2.4.x only receives bug fixes and efficiency fixes. It is recommended that new developments should use OpenCV 3.x, to take advantage of new features. However, the official operating system for the Raspberry Pi, Raspbian Stretch, comes with OpenCV 2.4.9. While I am not yet familiar with OpenCV algorithms, one thing notably missing from OpenCV 2.4.9 is a Python 3 binding.

I wanted to have OpenCV 3 running in Raspbian Stretch on a Raspberry Pi Zero W. Unable to find existing packages for Pi Zero and Stretch, I had no choice but to compile my own OpenCV 3. I decided to do it the proper way: build a backported Debian package. This method is superior to installing from the source code, because the packages can easily be deployed to other Raspberry Pi Zero W computers. I followed the Simple Backport Creation instruction, and spent a week building the packages. Now I'm sharing my compiled packages, so that you can use them if you dare.

What You Need

The Quest of Building OpenCV 3.2.0 Debian Packages on Raspberry Pi Zero W

The newest members in my toy collection are a Raspberry Pi Zero W (paid link) and a NoIR Camera Module (paid link), purchased in Dec 2017. Recently, I witnessed an impressive Contour Detection demo at MoCoMakers meetup. I read their source code, and it has a dependency on cv2 Python package. Therefore, the first step to get it working on my RPi Zero would be installing OpenCV that provides cv2 package.

While Raspbian Stretch offers a python-opencv package, it is version 2.4.9 released in 2014, and it only works with Python 2 but not Python 3. Since I'm starting from scratch, I wanted to develop on newer platforms: OpenCV 3.x and Python 3.

Many online tutorials suggest compiling OpenCV from source code. There are also a few sites offering pre-compiled tarballs, but these are either compiled for the Raspberry Pi 3, or built for Raspbian Jessie; neither would be compatible with my Raspberry Pi Zero W running Raspbian Stretch. Therefore, I started my quest to build OpenCV 3 for Pi Zero.

Debian Package > Source Code

When I first learned Linux, the standard process of installing software is wget, tar xzvf, ./configure, make, make install. Today, this is no longer recommended because software installed this way is difficult to remove and could cause conflicts. Instead, it is recommended to install everything from Debian packages.

PO Box 3943

PO Box, or post-office box, is a uniquely addressable lockable box located on the premises of a post office station. There is a wall of PO Boxes in the University of Arizona's Student Union Memorial Center, where it costs $25 to rent one for a semester. I found them interesting, although I didn't use one because I could receive mail in my apartment, and the Tucson heat did a good job to keep the grounds dry so I didn't have to worry about packages.

When I first came to Maryland, I rented a room in Orchard Place neighborhood. It rains often, and the house does not have a porch. Seeing the post office right outside the neighborhood, I thought it would be the perfect chance to try a PO Box.

Opening My PO Box

Rental fee for a small PO Box at Diamond Farms post office is $54 for six months, or $30 for three month. I would live at Orchard Place for two or three months, so the 3-month option seems more reasonable. However, it is cheaper to choose the 6-month option, because the post office offers a ½ refund if I close the PO Box within three months, so the final price is only $27.

PO Boxes at this location include "premium service": every PO Box comes with a street address, and can accept deliveries from non-postal carriers. This is an important factor for me, because most items I buy online are not shipped via USPS, and having a street address allows me to receive them at the PO Box.

NFD on Windows 10 WSL

The NDN Forwarding Daemon (NFD) connects every Ubuntu and Mac OS machine to the Named Data Networking (NDN) testbed network. While it's awesome to get your NFD connected from a Linux server or a Macbook, 82.56% of the desktop users running Windows are out of luck. Compiling NFD for Windows is possible, but the amount of patches needed is astonishing.

Then the good news came: Microsoft announced Windows Subsystem for Linux (WSL), which lets developers run Linux environments directly on Windows, unmodified, without the overhead of a virtual machine. Ubuntu is the first Linux distribution supported by WSL. This means, we can now run NFD natively on Windows!

How to Install NFD on WSL

This section outlines how to install NDN Forwarding Daemon (NFD) on Windows Subsystem for Linux (WSL). As of this writing, I have Windows 10 version 1709 (Fall Creators Update), and the latest NFD release is version 0.6.1.

The steps to install NFD on Windows are:

How to Flash C.H.I.P Offline

Next Thing Co (NTC), the company that made the $9 C.H.I.P computer, is not doing well: orders are not shipping on time, and support is not answering emails. While the little CHIPs would still work even if NTC no longer exists, same cannot be said for firmware flashing: the recommended method for flashing firmware is through Chrome App developed by NTC, which in turn downloads from NTC's file servers. If Next Thing Co evaporates and their file servers go offline, the Chrome App would not be able to download the firmware, and therefore I cannot re-flash my CHIPs if I ever mess up their operating system.

To keep my C.H.I.Ps working for as long as possible, I have to plan for the inevitable and find out how to flash a CHIP without relying on the Internet, or at least, without relying on the opensource.nextthing.co file server. NTC has published some scripts, known as CHIP-tools, to work with CHIP computers. The chip-update-firmware.sh script is a command line tool to flash the device. While the content of this script is complicated, to make it work offline, I just need to figure out what it needs from NTC file servers, and download these files in advance.

A brief read and tests indicate that chip-update-firmware.sh has the following workflow:

  1. Verify all necessary programs are available.
  2. Select a flavor according to command line arguments. It is one of server, gui, pocketchip, and buildroot.
  3. Download a latest file that contains the latest firmware version number.
  4. Download SPL, sunxi, and U-Boot images.
  5. Connect to CHIP in FEL mode, and determine whether the CHIP has a Hynix or Toshiba NAND chip.
  6. Download CHIP operating system image that suitable for the NAND chip.
  7. Connect to CHIP in Fastboot mode, and send the operating system image to CHIP.

Files for each flavor is hosted in a different directory on the file server. For server flavor, the files are:

Orchard Place

I moved into Mr Argoti's house on the afternoon of Oct 29, 2017, and became a resident of Orchard Place neighborhood.

The Tiny Bedroom

My assigned bedroom is incredibly small. There are five pieces of furniture: a BED that later turns out to be a sofa, a four-drawer DRESSER, a big glass DESK, a nice office CHAIR, and a small wooden end TABLE. My room also includes a small FRIDGE and a MICROWave. The following diagram shows their placement.

+--------------------------------------E------------------+-------------------------+
| [HEAT]            +-----------------------------------+ |   =====   |             |
| +-------+         |                                   | |  | TOI |  |   SHOWER    |
| |       |         |                                   | |  | LET |  |             |
| |DRESSER|         |                BED                | |   \---/    \____________|
| |       |         |                                   | |                  |      M
| |       |         |                                   | |S                 | SINK I
E +-------+         +-----------------------------------+ | TC               |      R
|                                                         +D            /-+------E--+
W                                                                  /DOOR            |
I                                 |CHAIR|                      DOOR         CLOSET  |
N                                 \-----/                                           |
| +--------+ +-----+    +----------------------+                      DOOR+---------+
| | FRIDGE | |     |    |         DESK         |                          |
| | MICROW | |TABLE|    |                      |             DOOR         E
| +--------+ +-----+    +----------------------+                 \DOOR-\  |
+------------------------------------------------------S--D             \-+

<--- SOUTH            E=electric outlet  S=light switch

The existing furniture took up more than half of the floor space, so that everything I have must fit into the other half. When I moved from Arizona, I had four roller bags, two small bags, and a large box of cookware. Half of my clothes already filled the dresser and the space on top of it, so the other half had to stay in the luggage. The desk obviously belonged to my computers and other gadgets. I managed to squeeze the cookware box and a smaller roller bag into the tiny CLOSET. One of my roller bags could fit under the bed by opening it to two halves. The last two roller bags had to stay in the open in front of the WINdow. After settling all my belongings, I only have an open "hallway" between the desk and the bed, just enough for doing a few push-ups.

Settling in Gaithersburg

I moved to Gaithersburg Maryland to start a research job at National Institute of Standards and Technology (NIST). As I exited Washington Union Station on Oct 26, 2017 after enjoying an epic 4-day Amtrak train journey, I felt lost immediately: this is no longer Tucson, the toasty city that I know and love, but a completely different place. Nevertheless, Cortana's voice guided me along Interstate 270, and my rental car arrived at Extended Stay America Gaithersburg South, where I was greeted by James and received a spacious and comfortable room.

Apartment Search

Before I first came to Tucson, I signed up for a student housing apartment online. Unlike six years ago, I did not select an apartment before traveling to Maryland. Gaithersburg is not a college town, and I am no longer a student, so that I couldn't get a fairly straightforward "student housing" option. Instead, I am facing a much larger and complex apartment rental market. I want to see the apartments myself before committing to sign a lease.

Oct 26 is a Thursday, so there was only one weekday remaining before the weekend when most leasing offices would be closed. I browsed online apartment listings, and selected four apartment complexes to visit on Friday. I still wanted to avoid owning a vehicle, so location was the most important factor in my consideration. I also preferred a furnished apartment, to avoid the hassle of buying and selling furniture.

Spring Ridge apartments model room