Archive for the ‘microsoft’ Tag

RoboChamps World Finals

About a month ago now I happened to receive a rather surprising email from Microsoft. Having read that I was invited to the Microsoft RoboChamps World Finals in Barcelona, I quite nearly dismissed it as spam until I read a bit further. It soon became obvious that it was in fact a real event for four “world finalists” to compete by programming robots to fight in a “Sumo ring” (essentially a physical version of the online Sumo challenge from the same competition). My disbelief was mainly due to the fact that RoboChamps wasn’t something I had devoted a huge amount of time to before then. I had watched some videos on MSDN Channel 9 and played around with a couple of the challenges downloaded from the website, but that was about it. Not before long I had encountered various bugs and issues in the SDK/challenges, quickly making me lose interest and move on to something completely new, as is often my tendency. (I might have anticipated the problems given that it was Microsoft beta software). Admittedly, the idea of programming robots in a simulated environment using the .NET framework sounded pretty cool, but I was busy enough at the time to (temporarily) forget about it. Back to my point: I soon found out that I had gained a wildcard place by my (comparatively) active participation in the forums, which at least clarified matters. So it came down to a free week-long holiday in the middle of the university term, simply to play around with robots (and win a guaranteed prize!) – how could I not accept such an opportunity?

I arrived in Spain late on Sunday after far too many hours travelling by aeroplane/train (and then getting lost and having to rely on my paltry knowledge of Spanish for directions to the hotel in the dark). Still, I did manage to arrive at the conference centre on time for the keynote (opening) speech of the yearly EMEA TechEd developer conference, which was acting as host to the RoboChamps finals. Unfortunately I wasn’t able to attend any of the other talks given at the conference during the week. (The ones on the new F# language [see this post] and the future of C# looked reasonably interesting, but as contestants we were coding and testing literally from sunrise to sunset some days!) The keynote itself was all about the next version of Visual Studio (VS 2010), including a few live demos, which overall looked very promising. I haven’t actually downloaded the CTP for it yet, so I won’t go into the details here. I may however wait for the next release, given that the IDE crashed within about 30 seconds after startup on the first demo – quite unsurprising really, but still rather amusing in what was essentially a big promotional talk.

The competition proper started that afternoon, when I met the three other contestants as well as the guy from Microsoft who was organising everything for us. They were Jackson, a professor of robotics from Brazil, David, and Doug, both two American engineers with many years of experience… I thought it would be difficult simply not to embarrass myself, but contrary to expectations the contest turned out to be surprisingly close (possibly due to the severe time constraints). We were firstly given our individual robots, two shared practice rings on which to test, a reference book for Microsoft Robotics Studio, and a brief explanation of how the event would be run before we then set to work. The robots were in fact just iRobot Create models (very similar to do the Roomba vacuum cleaner) with an embedded box running Windows CE and a webcam attached. In addition, since I was without a laptop, I was kindly given one to use throughout the course of the event, with nothing less than a pre-released version of Windows 7 installed. This ought to be the topic of another (short) post, but suffice to say now that I was quite impressed with some of the updates from Vista. I even hear that a slimmed-down version is being developed, which means people may have rather more luck running it on EEE PCs and other less powerful machines.

There were initially (that is the whole of the first two days) some horrible issues trying to run even the sample program on the robots. To start I had the bad fortune of being unable to deploy my program to the embedded box (which took rather long to realise and resolve with Visual Studio displaying a “Deploy Successful” message, despite my wondering why my program was still behaving like the sample one). Still, it seemed that everyone had their fair share of problems over the week, both hardware and software related. The fact that half of the robots were originally broken in some way (and some never fixed), together with the low charge on all the battery packs meant that I spent the first two days doing all too little. I should however mention that we did have plenty of assistance in trying to fix everything as soon as possible. (Microsoft did want a good contest after all, especially since the fight on Thursday was being publicised to any conference-goer who walked near.)

Eventually when I did get my program running, things turned out to be a lot of fun and it the challenge became one of strategy rather than debugging. I started by tweaking the code for the sample program and improving upon the vision processing, with a limited degree of success. My hopes to use the SIFT algorithm (its virtues preached to me by David [my aforementioned friend, not opponent]) for feature detection and estimating the location of the robot’s self/opponent immediately vanished once I had run a few speed tests on the embedded device, showing about a 100x slowdown compared to my moderately fast desktop. Noticing that my opponents were using relatively straightforward algorithms for machine vision was however a big relief. (SIFT was largely magic to me anyway, having tried to learn it only the previous week from Wikipedia and some of David’s old lecture notes.) I ended up taking the general structure and motor-control code from the sample program (as I believe the others did too) and using my own code for handling the sensor data, in particular the camera frames. The essence of my vision processing algorithm was some fine-tuned colour segmentation (using a flood fill function I ported from a previous project). I also updated the motor control code to use proportional feedback. Most else was quite trivial.

We finally came to the afternoon of the competition, with barely a day and a half of serious development behind me (and little more, if any, for the others). Despite the evidently enormous amount of work everyone put into the competition, it was great to be with such casual, open, and friendly competitors, and we were sharing ideas even until the last few hours. The format of the rounds was very simple: the winners of the two semi-finals progressed to the finals, and the losers played for 3rd place, where each round was the best of three 60 second bouts. The first semi-final between Jackson and Doug began at 1:00pm (see the video recording of it here) and I was beginning to panic slightly, realising that the recent versions of my program were strangely intent on running the robot out of the ring by itself and not easily resolvable. (I had recently done some 3 or 4 hours coding without any testing, which would explain…) A bit foolishly, I also had no sort of version control on my code (unless you count the poor man’s version control of copying/pasting the source directory every so often). When it came to my semi-final round against David, his robot needed only to watch mine drive full speed out of the ring after about 15 seconds. Fail, indeed. Crucially I had a couple of hours before the 3rd place play-off, which meant I could at least revert to a backed-up version (of unknown behaviour in the ring) and do some tweaking/testing. This somehow won me the round against Doug (though my robot only succeeded in avoiding being pushed off) to finish 3rd overall. I did get the feeling that perhaps I would have faired rather much better on first round had I only been less intent on using my latest version, but I was nonetheless happy to settle for 3rd given the overall situation.

We had all agreed earlier in week that we would let the winner choose first whichever prize he wishes, followed by the others in rank order. (This was mainly due to the lack of fondness for the RoboDog, which was originally going to be the 1st place prize.) When it came to decision time Jackson was very generous in deferring his choice to the rest of us, which means I was lucky enough to receive one of the two laptops. I still am not aware of its precise specs, but hearing that it was a high-end Alienware gaming laptop was enough to sell me. The Corobot ended up going to Jackson and the RoboDog to Doug, but everyone seemed reasonably pleased (the robots were . In the end I don’t think I could have hoped for a better experience (minus the hardware issues perhaps). Now that it’s apparent this was both the first and last RoboChamps competition (it has already been merged with the Imagine Cup), I feel particularly fortunate to have been invited. (The Imagine Cup, inspite of being for students, seems to attract far too many Eastern European hackers to give many people a chance.)

On a final note to this absurdly long post, Microsoft Robotics Developer Studio 2008 has just been released. You can download the Express version here for free, but there’s now also a commercial Standard version. I suppose the focus on hobbyists had to come to an end at some point, although the free version still looks quite capable. Also, I should point out that the release of the Mars Rover challenge (an especially interesting one) is now imminent in case anyone fancies giving RoboChamps a go – there will most likely be some pretty nice prizes for the winner/runners-up too, as with the previous challenges.

Learning F#

My being a long-time C# coder, I finally decided to take a break from imperative programming and try something new. To be honest, I’ve quite often reached the point with my projects where I wonder: Couldn’t this be written so much more concisely and elegantly in another way? This thought occurs especially frequently in the context of mathematical and scientific coding. In response to this question, there have been suggestions (on more than one occasion) by David to try F# (specifically this functional language as he knew he couldn’t get me totally away from .NET yet). In case you’re not aware of it, it’s Microsft’s attempt at bringing functional programming to .NET, and has proven very successful so far.

It turned out that F# was surprisingly straightforward to learn, even for a language still in the beta stage (albeit the end thereof). Three or four days of regular coding gave me a pretty good idea of how it can be used for all sorts of purposes. Most likely my familiarity with lambda functions and LINQ in .NET 3.5/C# 3.0 made the task a lot easier. Even so, Microsoft have put together a number of helpful resources/links for getting started. The online documentation is especially useful given the (current) lack of XML intellisense comments inside Visual Studio. The Microsoft Research F# page and the F# Developer Center should be your first stops when learning the language. In addition, there is a pretty active community at hubFS and a host of blogs dedicated to F# out there. It seems like only a matter of time before there’s a multitude of forums and an IRC channel. I get the feeling that due to the ability to use the .NET framework from a functional language (and the fact that Microsoft will soon be making it a first-class language alongside C# and VB.NET), F# could have unprecented popularity.

After reading a few of the guides and beginner tutorials, I came across Project Euler, a series of mathematical/programming challenges that are particularly suited to the functional programming style. This website was really all I needed to get a solid grasp of the language, and was pretty fun aside from that. After trying some of the problems I finally had to admit that functional languages have their place in the programming world alongside imperative ones such as C# and C++. If you’re interested in some of my solutions to the first 23 problems, you can download the zipped project here. (Most solutions are under 5 lines in length, not including helper functions or input data.) I’ve had fair success optimising most of the algorithms, though in one or two cases you’ll find clearly more efficient solutions elsewhere. However, they’re not all terribly well commented, so feel free to question me about any of the algorithms.

Unfortunately I have quickly been forced back into the realm of imperative languages due to my project commitments (posts to come soon). Do however expect some upcoming posts and projects to feature F#, or at the least functional techniques.