Obj-C Object Mapping

Just recently found this gem that significantly improves my life as an iOS developer. If you ever find yourself manually mapping a JSON NSDictionary to an NSObject try this:

[userDictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop){
    // Add a try/catch to skip any keys that don't match the NSObject
    @try {
        [myObject setValue:obj forKey:(NSString *)key];
    }
    @catch (NSException *exception) {
        // Ignore
    }
}];

Need a New Frame

I finally got the quad off the ground after shorting and repairing 2 speed controllers. I did have one incident though when I was trying to calibrate the rotors and didn’t realize how sharp the plastic blades were. I now have a nice scar on my hand. Unfortuantly I didn’t put enough time into calibrating it and the flight was short lived. Check out the video:

The cheap wood frame fully broke after the second flight. I need a good carbon fiber frame.

Some things I should have done:

  • Balanced the props
  • Glued the cheap wood frame to be a little stronger
  • More screws holding the motors to the frame (I think there was some vibration)
  • Controlled test flights until it was fully calibrated

Here was the latest HobbyKing parts list:

Code            Description                                     Quantity
TX-9X-M1        Turnigy 9X 9Ch Transmitter w/ Module & 8ch R    1
Quadcopter      HobbyKing Quadcopter Frame V1                   1
T2200.3S.30     Turnigy 2200mAh 3S 30C Lipo Pack                1
QUAD-CON16K     HobbyKing Multi-Rotor Control Board V2.1 (At    1
KDA20-22L       hacker Style Brushless Outrunner 20-22L         5
HK-SS20A        Hobbyking SS Series 18-20A ESC                  8

317MPRPSVR      3.17mm Prop Saver w/ Adapter & 3 bands          2
XT60            Nylon XT60 Connectors Male/Female (5 pairs)     2
601B-12-10cm    XT60 Female w/ 12AWG Silicon Wire 10cm (5pcs    2
601A-12-10cm    XT60 Male w/ 12AWG Silicon Wire 10cm (5pcs/b    1
ACC6            Turnigy Accucel-6 50W 6A Balancer/Charger w/    1
HS -250C        Cable Ties HS4.8x250mm 100pc (Natural White)    1
OR017-01005-M3  Hex locknuts M3 10pc                            3
R12A1062-06     Turnigy Pure-Silicone Wire 12AWG (1mtr) RED     1
B12A1062-06     Turnigy Pure-Silicone Wire 12AWG (1mtr) BLAC    1
WHS-5MM-RED     Turnigy 5mm Heat Shrink Tube - RED (1           1
WH-5MM-BLACK    Turnigy 5mm Heat Shrink Tube - BLACK (1mtr)     1
WH-6MM-BLACK    Turnigy 6mm Heat Shrink Tube - BLACK (1mtr)     1
WHS-6MM-RED     Turnigy 6mm Heat Shrink Tube - RED (1           1
258000012       20CM Male to Male Servo Lead (JR) 26AWG (10p    1
HA0509          Hex Screw M3x10 (20pcs)                         1
HS -160A        Cable Ties HS2.5x60mm 100pc (Natural White)     1

Propellers at ACPProp.com:
LP10047SFP      10x4.7SFP                                       8
LP10047SF       10x4.7SF                                        8

Quadcopter

Been wanting to build one of these for a while now. Its actually the reason I bought the BeagleBoard-xM to write a custom quadcopter controller which I still hope to pursue in the future:

IMG_3270

It took a few hours to solder the motor cables to the bullet connectors and then to the Electronic Speed Controllers (ESC).
IMG_3276

I used the ‘Western Union’ soldering style to make the 12 gauge power harness.
IMG_3275

I’m initially using a super cheap KK Control Board knock-off called the HobbyKing Multi-Rotor Control Board V2.1 just to get it up in the air before spending more.

Still needs some configuring but I’m looking forward to flying it

New Camera

I picked up a Canon EOS Rebel T2i. Its a lot of bang for your buck. I shot these unmodified pictures using the standard kit lens, 100 ISO, tripod, and a long exposure

IMG_1245_small IMG_1239_small IMG_1221_small

BlackJack II Phone Finder

A couple years ago I wrote a fun program for my BlackJack II phone. I was really interested in the phones built-in GPS and wanted to play around with it by making a program that would intercept received SMS text messages that contained a special keyword, turn on its GPS and respond back with an SMS text containing its coordinates.

Two and a half weeks later I hacked together something that works. The program runs completely in the background on the phone and doesn’t display or inbox the received SMS text messages containing the key. In order to use the GPS hardware on the phone I did have to install MoDaCo’s GPS Hack.

An example situation would be I would send the following SMS message from a different phone to my phone:

1234 gps

My program would intercept that message since it contained the key, read the keyword “gps”, attempt to retrieve its location and send back to the original sender the message:

http://maps.google.com/maps?q=32.856064,-96.964706 Alt126.00 Speed33.3 Heading85.40 H-Quality2.7 V-Quality1.4 Satel6

It shows its speed, direction, altitude, quality and satellite count of the GPS coordinate read.

To enable/disable and change the special key (In this case “1234″) the user runs the SMSIntercepterSettings exe which brings up the screen:

BlackJack II Phone Finder

I also added a few extra features to the program:

  • alert – Plays audio file and displays a “lost phone” message on the phone
  • status – Sends back SMS with current battery and signal reception info
  • callmeback – Calls back the senders phone number
  • restart – Restarts Phone

Check out the code on my GitHub (Still needs some cleanup) http://github.com/kevinejohn/BlackJack2-Phone-Finder

Semi-Streaming Webcam Video on BeagleBoard-xM

Found my old Creative Labs Notebook webcam and plugged it into the beagleboard. Surprisingly the distribution of Ubuntu already had drivers for it. All I had to do to stream the video to my laptop was “sudo apt-get install vlc” and run the command:

cvlc v4l2:///dev/video0 —sout \ ‘#standard{access=http,mux=ts,dst=192.168.2.108:8080}’

I used “cvlc” instead of “vlc” because vlc expects an X server to be running and quits if it isn’t. cvlc is command line only compatible. The v4l2 is “Video4Linux” version 2 video capture API. /dev/video0 is the video device linux assigned the webcam. It outputs a stream on the http protocol packaged in mpeg format (mux=ts) and bound to the beagleboard’s own ip address which was 192.168.2.108 on port 8080.

Back on my laptop I fired up VLC, selected “Open network…”, typed in the address http://192.168.2.108:8080 and I was viewing the feed.

The video was its usual poor quality webcam video but what did bother me was the ~2 second delay in the video stream. I ran “top” back on the beagleboard and the video stream used less than 1% of the CPU and there was plenty of memory free so it wasn’t like it was limited by the beagleboard hardware.

I tried a few other streaming options with VLC like RTP instead of HTTP but I couldn’t get them to work on first try. Maybe I’ll put more time into it later.

BeagleBoard-xM

BeagleBoard-xM

Just received my BeagleBoard-xM.

Had some difficulty using the built-in SD card reader in my Macbook Pro formatting the beagleboard’s MicroSD card with Ubuntu 10.10. I ended up having to run Ubuntu in Virtualbox on my Mac and connect a USB printer w/SD card reader (I didn’t have Linux installed naively). Using this setup I was able to format it correctly following the Maverick 10.10 instructions here: http://elinux.org/BeagleBoardUbuntu

Now to try to make it do something useful…

Weekend Fun

Taped a camera onto a Firebird Commander 2 RC plane and flew it around the back yard.

I was surprised with the video quality considering it was $7. Check out the video below.

RCFlight1 from Kevin Johnson on Vimeo.