Sunday, February 10, 2013

MVC in Matlab

Some time ago I started to make use of Matlab's object oriented capabilities.  (In true Matlab style, inheritance is notated with a 'less than' sign:  dog < animal)  The application I refactored has a GUIDE front end.  I had used GUIDE to make user interfaces before; and forged ahead using what I had learned from the user's guide.  While I have been really pleased with the benefits of OO, I was struggling to figure out how to apply patterns to my program, specifically MVC.  Well, last weekend I cracked that nut; and moreover, while watching the Grammys I made a little demo app to share.

Model View Controller (MVC) is a compound pattern whose goal is to separate responsibilities into modular pieces that can be interchanged relatively easily.  If you didn't need a user interface, all you'd have to worry about is the model.  Why should you have to burden the model with user interface code?  Obviously you shouldn't, thus the model view separation.  Introduction of a controller loosens the coupling between the model and the view and, if done well, allows the behavior of the system to be modified by replacing the controller with a different one.  After the jump, I'll show you how to apply the pattern to a traditional Matlab GUI.

Model View Controller

Thursday, September 27, 2012

Udacity CS373: A Review

Whew, it's been a looong haul.  I finally finished up CS373 on Udacity, Sebastian Thrun's class on programming a robotic car.  I think I started in the second session; and they removed all time limits on the class shortly thereafter.  Udacity realized that they had a lot of busy people, a lot of professionals, people already in the workforce, people like me taking their courses; and they wanted to make it easier for us to progress at a sustainable pace.  Good thing too because real life has a way of intruding when you least expect it.  So, kudos for that.  I finished and got this spiffy certificate for my efforts!


CS373 is different than the Stanford AI course mainly in that it introduces programming assignments in Python.  So, in addition to the videos and the interactive quizzes, they put up an interactive Python session with partial programs.  Once you complete the program you can run it, view the results, and submit it for grading.  It's really pretty slick.  Later on, when the programs got more complex, I preferred to copy it into my own editor, then copy the final code back into the webpage; and that worked out fine.

The course starts with localization and tracking using histogram filters, particle filters, and Kalman filters.  This section of the course is just a beautiful overview of the different filtering methods.  You really come away with a nice perspective on the benefits and tradeoffs of each approach.  Normally Sebastian presents topics with great intuition and a clear approach; and this course is no exception.  Kalman filters can be particularly tricky to understand, but by focusing on the one dimensional case he was able to explain the intuition behind them too.  The much more complicated equations of the two dimensional case were presented without really much justification and the programming assignment only tested that we were able to use them.  It may have struck some folks as curious that he said we had just done the hardest bit of the whole course; and by doing so he kind of betrayed the underlying, hidden complexities of the subject.  As presented, it definitely wasn't the hardest part of the course.

The session on search covered A* and dynamic programming with value policies and optimal policies.  I thought the A* programming assignments were some of the hardest in the course, because of a trick that I won't reveal here.  I will say that sometimes I felt like you had to be a mind reader to figure out what you were supposed to do.  More than once I had to resort to advancing to the answer, then going back and submitting a program after seeing his solution.  If you find that you have to do the same, don't feel bad.  You won't be penalized for it.

The overall goal of the course was to teach all the main aspects of programming a robotic car.  I think the course actually delivers on this promise by teaching on topics in localization, tracking, search, PID control, and SLAM.  Of course there are many areas that were not covered, like vision, classification, LIDAR, and many other potential topics.  The thing is, the devil is always in the details.  I hope everyone realizes that you don't take a course like this and then go build the Google Car.  But the core concepts are there!

The last section on SLAM is actually bonus material, and offers some of the most challenging programming assignments of the whole course.  In teaching us graph SLAM, Thrun takes us beyond the scope of anything he taught in a single course at Stanford.  I really enjoyed the course.  Even though most people who take it won't actually be building robotic cars, there are lots of way to use these algorithms.  Go and play, learn, and  create.

Saturday, June 30, 2012

Just Keep Learning

I've gotten through the first two units in my Udacity AI class.  Unit 1 was on localization using Histogram filters; and unit 2 was on tracking using Kalman filters.  It's an amazing class to me in much the same way that the Stanford AI class was.  It just cuts through all the BS and presents the core ideas, not dumbing them down, rather approaching the material using intuition first; and leaving mathematical formalism for later (another class perhaps), after the core ideas are absorbed.  I think I'll blog more about those methods in the future; but I wanted to go in a different direction today.

I thought I would take this opportunity to acknowledge two teachers who have contributed in no small part to my recent renaissance of learning.  I've always been a lifelong learner; but I would say I was getting a little down about not being able to keep up with the areas I'm interested in.  A great teacher can be such an inspiration in your life; but they also back it up by giving you the knowledge and tools to act on your dreams and ambitions.

So, click on my friends; and let me know about your favorite teachers.

Tuesday, June 12, 2012

The Uncanny Valley

The first authorized translation of this article is now available here, along with an interview with Masahiro Mori here.  It's fascinating how some ideas don't catch on for many years, then take off when the time is right.

The Uncanny Valley

Sunday, June 10, 2012

The Hackers, The Dreamers, and Me

The always informative and entertaining Scott Hanselman put out the call for stories on how we got started in computers and programming.  Well, I've never tried writing mine down, so I thought I'd try capturing some of the magic of my youth.  Click past the break if you'd like to join me on a stroll down memory lane.

Sunday, May 27, 2012

Powers of Ten


I've completed the first version of my first Python application, one that was started for me by my high school intern.  It's purpose is to read in data from a binary file into memory, and then promptly save it out to a Matlab mat file.  The data was recorded in real-time, frame-by-frame, and thus is read in the same way.  The interesting thing about this little application is that I have versions of it written in C++ (not by me) and Matlab (me).

So I thought I would share some timing information.

If this is the sort of thing that floats your boat, by all means click through the jump and share in the geekery.

Sunday, May 20, 2012

Living in the Crunch

I've had reason to think about crunch lately.  A week of late nights capped off by a 4am bedtime does make one think about such things.  The effects of crunch are many and varied.  You quickly dispense with the trappings of normal life:  dinner with family, doing the laundry, your favorite TV show, etc.  You start to feel disconnected, lose track of days.

Your work starts to take on a more frenzied pace.  Things you normally do to dot the i's and cross the t's get abandoned in order to achieve your goal.  You start to lose a healthy sense of perspective.  The thoughts that run through your mind at 2 am when you're amped up on caffeine and/or sugar are probably not well reasoned nuggets of analytical thought.  Speaking of which your productivity takes a dive and you have to make up for it with even more hours of staring blankly at a mocking screen.

So, maybe this is not how you have experienced crunch.  It comes in various forms, differing levels of severity.  A recent Gamasutra piece featured an interview with Blizzard's Jay Wilson, game director of Diablo III.  He said about crunch

"...while game development cycles have a tendency to crunch towards the end, usually for a few reasons, at Blizzard, it's actually driven by quality.  But most companies you work for, it's not actually quality that makes you crunch. It's usually bad planning, and a lack of focus."
while defining it as working 50 to 60 hours per week, or more than 40 for an extended period of time.  Now, game development crunches are some of the most well publicized (google "EA spouse"), but by no means the only examples.  Others that I can think of include defense contractors, research organizations, small businesses.  Almost no organization with a salaried workforce is immune.

My experience with crunch has not been driven by quality unfortunately.  How noble that sounds!  Mine falls squarely in the second camp.  I will grant that it is difficult to forecast projects when they are all so different.  It is downright hard to juggle a limited number of people's participation in a number of projects, ramping in and out, overlapping just enough to balance out the month.  The bottom line is that when you've signed a contract to deliver X to a sponsor at the end of Y months, you have to do your best to deliver if you hope to build a reputable name and win repeat business.

Nevertheless, it sometimes makes me want to go herd goats for a living.



Is there any industry, any company, where the grass truly is greener?  I suspect it depends more on the good fortune to work with an experienced project manager who knows how to estimate cost and calculate burndown rates.

In the meantime, I'll dutifully keep doing my crunches.  My abs should really be harder than this by now.

For more information about crunch, check out Crunch Mode: programming to the extreme.