(Ken Struys' Blog)

web-developer, serious schemer

Projects

Just Let Me In: Hacking with the Twilio API

My apartment has a fairly standard phone system. You dial an extension, my cell is called and I can allow the caller to enter the building by dialing nine.

To let myself in I have a dongle that it's hooked into the system and to let you in. Unfortunately, when my girlfriend and I moved into the apartment, we were only given one dongle and were told we we're not able to get a second one.

For three months I've been using the system to call my own cellphone and letting myself in. The biggest problem with this solution is my android phone dies all the time and I've been left a couple times stuck outside.

I decided I needed a better system to just let me in my own building. Twilio provides the perfect service to solve the problem. Twilio is a web service API for building Voice and SMS based applications. When you signup, you get a San Francisco phone number for development and you can code simple XML documents to automate Dialing other numbers, Messaging, Playing audio, etc for basically pennies. Once you've coded you application you can pay around $1/month for a local number.

When I dial into my front door, audio is played asking whether you want to speak to myself (press one) or my girlfriend (press two). When you press either key, one of our two numbers are dialled and the system works as normal. Since I don't want to dial myself anymore, I also added a pin (some other combination of keys) that just opens the door by fooling the system into thinking I've dialed nine.

The Twilio code was really simple (it was about 20 lines of PHP). The only difficultly I had was getting the dialling 9 to work. Twilio does support dialling keys, but only after Dialing out to another number. I emailed the Twilio team and they said the easiest way to get it working was to use a program called audacity to record a 9 key tone. Playing this tone tricked the door system into thinking I had actually pressed the key. I was a little surprised to find out such a hacky solution would actually work, but then again a lot software solutions are hacks :P.

In the future I think I'll try to port my PHP solution over to a more Rackety approach. You could very easily use send/suspend provided by the web server to make the script even shorter/more clear.

Overall my experience with the Twilio API was fantastic, it's probably the easiest API I've ever had the pleasure of using and it's really impressive in it's simplicity.

Robocup Client

My last project at U of T was with Jonathan Doda, Daniel Lister and Philip Patchin. In 3 months we were given the task of making a reasonable soccer client (in fact an entire team of clients) for the Robocup Simulation League. Most clients in the league are developed by MSc/Phd students and are ready for competition within 2 years. The course was setup to get some ground work done and allow future students to fork our work.

Our first task was actually interfacing with the soccer server. The server would send data to the clients concerning what the client could see (field markers, relative positions of other players) and our clients physical state (neck angle, fatigue, speed). Our client was responsible for sending command like kick, turn head x-degrees, run x-speed. After about of week of work we were really pleased to see our client move a single pixel across the screen. Once we had a communication interface working we started converting our relative distance to fixed field markers into absolute field positions. Luckily, with the help of spinning our heads around, 90% of the time we could see enough of the field markers to actually determine our position aswell as other players positions on the field.

We eventually setup actions to kick the ball towards the net, communicate with other players on our team, pass the ball to the others and chase the ball. Once we had all the key actions down, we created defensive, offense and goalie behaviors. Every week we competed against other groups in the class. Unfortunately half of the students decided to fork existing robocup clients who already completed a lot of the leg (and advanced) work done. Generally we failed completely to defeat these teams but by the last week of development we managed to steal the ball and even saved the ball against their offense.

Below find a video of our completed client playing against itself. I spend up the video to make the length of a game a little more bearable and to hide the odd time when our client would do something dumb :P.

Note:
  • - The coloured half of the player is the front half of their body
  • - The green outlined semi-circle is the field of view/neck angle of the client.

Processing Raytracer

For a final project in a university course I completed a simple raytracer in C++. The raytracer included a couple different objects (Planes, Spheres and Cylinders), anti-aliasing, shadows, reflection and motion blur.

Over the summer I decided to wanted to hack with Processing and I partially re-implemented the project. I have posted my processing version here.

Simple Compiler

Compilers was a course I had been looking forward to for a very long time. During my fourth year I finally got the chance and had the pleasure of working with Nicole Allard, Aran Donohue and Ian Strachan. The course was only a very brief overview of classical compiler theory but still was very enjoyable. After finishing the course I decided to make an applet to show off our work. You can find the compiler here.