Instant on PC

Do you ever wonder why booting up a computer takes soo long? Why doesn’t it turn on instantly like a TV or DVD player? As it turns out, engineers at MontaVista Software thought the same thing, and have finally figured out how to tweak Linux to boot in under 1 second … yes, that’s “1″ as in “Done!”

Although they achieved this amazing feat on a specific embedded processor, MontaVista claims that the same techniques can be applied to standard Linux software. Here is a summary of their technique:

1.  Optimize the bootloader by omitting unneeded drivers, etc. (boot time now down to 7s)
2.  Use DMA to copy some boot code into the main memory cache, to execute tasks in parallel (now down to 4s)
3.  Do various tricks such as loading the customer’s app directly into the page cache (now down to 1s)

Simply amazing. I hope this idea catches on soon and gets folded into mainsteam OSes. In the meantime, I will stick with my usual routine. Turn on my computer, walk to the kitchen and brew coffee. By the time I’m back, my apps are happily waiting for me. On a good day, it feels like it’s instant on.  :-)

Porting OpenCV to the iGEPv2 : first steps

screenshot of "Lena" sample picture from OpenCV with edge detection

Over the last 3 weeks, I’ve been busy putting together my iGEPv2 embedded development system. Initially my goal was well defined: use the pre-built SDK Virtual Machine provided by ISEE as the cross-compiler, install Android OS on the iGEPv2 board, get the PS3 Eye webcam to work and install OpenCV. With this basic setup, I figured that I can begin experimenting with computer vision on an embedded device which ultimately will be folded into a bigger project, a personal robot.

However as I worked on the project, I learned two important things:

1. The pre-built SDK Virtual Machine is not suitable for everyone. Unless you have a powerful computer with plenty of RAM, the VM runs unbearably slow. I tried it on a Dell Precision 380 desktop (2.8GHz Pentium4 with 1GB RAM) and eventually gave up. Also, the VM uses the older Ubuntu 8.04 version and does not include the latest drivers; the PS3 Eye webcam didn’t work out of the box, and I couldn’t get kaswy’s PS3EyeMT driver patch to work.

2. Make the app work first on your development system before porting it to an embedded platform. Why? Because you’ll likely make significant code changes and run many tests before you get acceptable results, and repeating these tasks is far quicker and easier on a powerful machine. In the case of OpenCV, I’ve found out that much preparation is needed to built a vision system that recognizes objects and faces. You will need to collect hundreds if not thousands of samples of training and test images. (For example, see these Haartraining articles by Naotoshi Seo, Rhonda Ltd. and Florian Adolf). I find this surprising and disappointing, since we humans can learn to recognize with far fewer samples.

I am reminded of Scott Berkun’s words from his book The Myths of Innovation — that innovation is messy, making lots of unexpected twists and turns. I have underestimated the amount of effort needed to build the vision system. This is now obvious in hindsight. But when I started, I was so enamored by the idea of having object recognition working on the iGEPv2 that I jumped right ahead into the embedded development stuff.

Sigh.

On with Plan B. So I decided to develop the object and face recognition app on the PC first. I installed Ubuntu 9.10 on my old Dell PC, then got the PS3 Eye webcam and OpenCV 1.1 running with very little effort.

Here’s what I did:

1. Download the latest Ubuntu and burn it on a CD.

2. Insert the CD on a dedicated PC and install Ubuntu.

3. Install OpenCV 1.1; I chose this over the newer 2.0 because there are more tutorials available. I used The NUI Group’s simple guide.

4. Verify the OpenCV installation. To do this, open a Terminal console and type:

$ cp /usr/share/doc/opencv-doc/examples <your-work-dir>
$ cd <your-work-dir>/c
$ ./edge  lena.jpg

5. Plug in the PS3 Eye. It worked out of the box for me.
6. Check that the PS3 Eye work. I used Guvcview for testing

$ sudo apt-get install guvcview
$ guvcview

Build your own iGEPv2 enclosure for under $5 (Part 2)

In Part 1, I described my reason for building my own iGEPv2 enclosure. Now the fun begins.

Hacking the Soap Box

Here is how I modified the soap box. The tools I used are:

  • a hobby drill
  • utility knife
  • small metal file
  • fine (200 or higher) grit sandpaper
  • gray Sharpie permanent marker (for making drill marks)
  • screwdriver
  • hex nut driver or long-nose pliers
To mount the PCB board on the case, I used these additional hardware parts:the 1/4" height metal standoff, a plastic nut and bolt
  • 4-40 hex metal standoff, 1/4″ height  (4 pcs)
  • 4-40 plastic nut  (3 pcs)
  • 4-40 plastic bolt  (4 pcs)

Construction Steps

  1. First, note that the iGEPv2 board has only 3 mounting holes. A combo Wifi/Bluetooth antenna sits on the area where the 4th hole would have been.
  2. Attach the three metal standoffs on the board temporarily so that you can guage how high to drill the holes for the two audio jacks. To do this, screw in the plastic nuts midway into each bolt. Then insert each bolt from the top of the board and screw in the metal standoff from the underside of the board. iGEPv2 board with temporary legs fastened
  3. Put the board inside the case and mark where the two audio jacks will come out. Take the board out and drill the holes. Be sure to make the holes wide enough so the lip of the two jacks potrude out of the holes, as shown below. By doing so, the audio side of the board will sit flush against the case. (In the pic below, the SDcard slot is already etched out. This is because I took the picture after the fact.)audio jack and SDcard holes
  4. Remove the metal standoffs and put the board back into the case. Mark the three holes where the metal standoffs will be mounted. You’ll just have to eyeball where the 4th hole needs to be. Remove the board and drill the mounting holes.iGEPv2 board with 3 yellow arrows showing where to mark and drill
  5. Cut one of the plastics bolts to approx 5/16″ length (just a little higher than the 1/4″ metal standoff).
  6. Turn the case upside down. Insert the bolts into the four holes you drilled and fasten them from inside the case with the metal standoffs. Make sure to put the shorter bolt (the one you just cut) into the 4th hole where. Then turn the case right side up.the soap box case with mountings on
  7. Put the board back inside the case. The 3 bolts should nicely come through the PCB holes. If not, loosen the metal standoffs and readjust.
  8. With the board in place, mark the slots for the power jack and 2 USB slots in front (I did not bother with the RS485 port), the SDcard on the side, the LAN and HDMI ports in the rear. Now go at it. Bore a hole (or series of small holes) on the area to be routed out then carve out the desired shape with a utility knife. Smooth out the edges with a metal file and a fine-grit sandpaper.soap box with all slots cut out
  9. After all the sweat and labor, here is the final product. Not bad, eh?iGEPv2 homebrew case

iGEPv2 case opened, showing board inside

Note: I used plastic screws instead of metal ones for two reasons: (1) to protect the iGEPv2 board from accidental electrical contact, (2) the head of the plastic bolts serve as “rubber feet”.

Back to Part 1

Build your own iGEPv2 enclosure for under $5 (Part 1)

The iGEPv2 is a great hardware to develop your next whiz bang embedded project. Whether you are making a media player, robot controller or wearable PC, this powerful and versatile single-board computer will likely do what you need. It supports stereo sound, streams HD video and can includes Ethernet, Wifi, Bluetooth, USB, serial, I2C, etc. for connecting with other devices. For these reasons, I and my fellow founders at AndroidMakers chose the iGEPv2 as the hardware brains for APEX (Android Platform for Experimenters), a platform we’re building to simplify using the Android OS beyond the mobile phone.

When you buy an iGEPv2 kit, you get a circuit board roughly the size of a deck of cards and a universal 5V power supply. Here’s a pic of the board:

iGEPv2 PCB board

A Case in Point

While you can get by with this spartan setup, you will probably want to put the board inside a plastic or metal enclosure if you plan to carry it around. In fact, even if your device is not portable it is still a good idea to encase it to protect against damage from static, coffee spills and other nasty elements. So now you are faced with a choice: buy the case or make one?

The fast route would be to buy a ready-made acrylic case from the ISEE Shop. It looks professional and well-built, but I cringe at the thought of paying USD$30 + S&H for what is really just pieces of plastic. To be fair, most of that cost pays for the expensive laser-cutting. But I’d rather save my money for something else.

So I decided to build my own enclosure. I started by looking for a plain plastic case that I can retool. First I searched the Web, then visited a Standard 5 & 10 ACE variety store on the way to work where a friendly manager named Josh helped me land on this great idea:

black travel soap box on top of table, lid partially open

Yep, you guessed it … a travel soap box. (NOTE: I’m really glad that these mom-and-pop variety stores still exist. They are a treasure trove  for hard-to-find project parts.)

Part 2: Hacking the Soap Box

TidyBot makes way for Android

I put the TidyBot development on hold to work on another project, for good reason. At the last Android Makers meetup, my good friend TrueDat lent me an iGEPv2 development board (a BeagleBoard clone with built-in Ethernet, WiFi and Bluetooth) for short-term evaluation. I just couldn’t pass up the opportunity.

I plan to install Android OS on the iGEPv2 and see how this kit can be used as an experimenter’s dream platform to implement cool stuff such as robot vision, wearable computer, media server, etc. In fact the AndroidMakers team is gearing up to build APEX (Android Platform for Experimenters).

So far, I have only done the basics which is: (1) Log in via the serial debug port using a hand assembled DB9-to-IDC10 (AT-EVEREX) cable, and (2) Log in via Ethernet LAN. I will first play around with the iGEP tools before diving into Android.

Here is my current setup. You can see two terminal consoles on my PC monitor, one connecting to the iGEPv2 board via serial port and the other via ssh over Ethernet.
igepv2 connected to laptop. PC monitor shows two console terminals.

This is the homebrew DB9-to-IDC10 cable (gray) I built to allow logging in through the serial port. Because my laptop lacks a serial port, I used a Keyspan USB-to-serial adapter.
homebrew serial debug cable connected to the iGEPv2 board

TidyBot: prototype 1

One of my dream goals is to build a robot that roams around the house and does something useful. That is how I came up with the idea for TidyBot, a home companion that collects small objects– such as toys that my kids leave on the floor. Because I have zero experience building robots before, I figured it would be best if I make it using parts that I can easily reconfigure… errr, just in case my “great” design idea doesn’t work out too well.

That’s where the Lego Mindstorms NXT comes in. Using this versatile kit, I can try out different designs and afford to make mistakes without spending a lot of extra money. Oh, that arm doesn’t pick up objects too well? Let’s just take it apart the pieces and start over again.

I also did my homework and read up on the how the iRobot Roomba works here and here. To learn how to program autonomous robots, I bought and read Joe Jones’ excellent Robot Programming book.

Now a well-trained Padawan, I set out on my mission. Here is a picture of my first prototype. (PICS to be added soon) It uses dual (Left and Right) motors for driving and steering, supported by a rear castor wheel. I added a third motor to control an arm that swings downwards to scoop objects into the robot’s belly. TidyBot uses an ultrasonic sensor to spot obstacles and a light sensor to detect candidate objects for collecting.

Cool design? maybe. Original? hardly not. I borrowed heavily from the design of this vision-guided autonomous robot that collects tennis balls made by engineering students at Ngee Ann Polytechnic Institution (Singapore), and used Castor Bot‘s wheel design.

The software, however, is another story. Because I want TidyBot to run autonomously but will respond to commands sent via Bluetooth, I wrote my own code. Interestingly, I also switched programming languages: from Lua (pbLua), to C (RobotC) and then to Java (Lejos). More details on my next post.

Borglabs goes live!

Sometimes the best way to start a major goal is to boldly take the plunge. I had originally intended to launch this Web site after completing the first of my projects but changed my mind. For I realized that it is more important to craft the first humble page, to put a stake in the ground and forge a path for other thoughts that will follow.

I plan to use this site as a venue to talk about my projects and independent research on several topics that have fascinated me for years. These include:
  • robotics, specifically personal robots and autonomous machines
  • insect cognition and biology-inspired adaptive behaviors
  • collective intelligence
  • machine learning and other adaptive methods
  • Artificial General Intelligence
  • tools that enhance how we sense and reason
While the list is admittedly broad in scope, I have a simple and effective rule of thumb to narrow my focus: Choose ideas or topics that are I can readily experiment with using readily available parts and software, prefering open-source items whenever possible. Thus my posts will slant towards projects and ideas that anyone can replicate with modest resources. Occassionally I may talk about some exciting work being done at research universities and R&D groups– but primarily to look for sources of inspiration.
My goal is to build, or buy when possible, machines that enhance how we sense our environnent, make decisions and do our tasks. These include personal robots, avatars and software agents, wearable computers and related technologies. I am interested in these things partly from a technical standpoint but more so to see how we can harness these innovations to improve our lives.
We are fortunate to live in an era where ideas that were once considered pipe dreams are now  achievable and– with some stretch– accessible to the common person, thanks to the rise of affordable hardware, open-source projects and a wealth of services in the Internet cloud. In upcoming posts, I will talk about my exploits in these areas…