Eye-To-Eye Part 4: Moving the Servos

The four pieces required for the Eye-To-Eye project are in place now: A laptop running Ubuntu with Opengazer fully functional, router, Arduino with Ethernet Shield and two servos (for one eye). The glue for all the pieces — especially the opengazer-to-network part — have also all been figured out. However, putting the pieces together still required some work I didn’t anticipate, and provided some interesting challenges I have yet to solve.

But the good news is, it works! Here’s the video:

Continue reading

Installing Opengazer

For Eye-To-Eye, I decided to use Opengazer on Ubuntu. I had two laptops running Ubuntu 11.04: Acer Aspire One (slightly older netbook) and Toshiba Tecra. I eventually got both of them working, although there were a lot of tweaks. These are my notes to get it working on both of these machines, YMMV.

First, download opengazer and follow instructions in the README.

You’ll notice right away you need CMake. Thankfully, Ubuntu makes this easy:
sudo apt-get install cmake

Next, download and install VXL. Unfortunately, this has to be done from source. Because VXL is made for previous versions of linux, there are some headers which are outdated. I’ve compiled a list of problems and solutions.[see below for update]

These are all the problem areas, the rest is described well in the opengazer README.

Update: 2012-04-17

Some people were having problems installing opengazer, and I decided to put together a more comprehensive set of instructions

UINavigationController and Rotation

Recently working on a project that needs a video displayed from a table view inside of a UINavigationController stack. The video needs to be in Landscape mode, while the rest of the project can be in Portrait or Landscape. The view controllers are pushed onto the stack, and each of the view controllers overrode the shouldAutorotateToInterfaceOrientation: method. The landscape controller had return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);; the rest of the controllers simply returned YES. So far, so good.

Here’s the problem. The view controller that contained the video (aka VideoViewController) arranged its elements in landscape mode, but started in potrait mode. Rotating it to Landscape mode corrected the issue, then rotating it back to Portrait mode, it still looked ok:

I could not make this work using the pushViewController method on the root view controller’s navigationController. But, for some strange reason, presentModalViewController: presented this view in the correct orientation. So the table view gets pushed onto the NavigationController with pushViewController and the VideoViewController gets presented as a modal view. The interesting thing about it is if you specify YES for the animated parameter, it doesn’t look like a modal view controller — meaning that it doesn’t pop up from the bottom like normal modal VCs, but rather from the side, and doesn’t look unnatural.

This is only a workaround until I can figure out why a regular pushViewController call doesn’t rotate the view, and I was lucky enough that in this instance a modal controller worked out well.

Constants in Objective-C

If you’re a Java programmer developing on the iPhone platform, you’ve probably wondered about how to set constants in your programs. Undoubtedly, you have have come across the #define preprocessor macro, and maybe a few other methods, but I’m going to show you my approach to this problem using the singleton design pattern. Continue reading