Monday, 21 March 2011

On Arduino, Mindstorms and other Robotic stuff


Touch down!


In these months I gave some tech consults to a friend of mine whom is working on a university experiment. This experiment involve an autonomous probe sent 35 km in altitude with a baloon.
I was pretty surprised about how much funny is to work on real-time systems. Just for fun, I looked for some "robot hack", thinking how to realize a simple automatic rover. I'll talk about software details in another post: today I asked to myself what's best to use: homemade hardware with arduino board or a Lego Mindstorm kit. I think the answer is inside of you: are you able enough to drill and cut aluminum? Fix motors and actuators with bolts, taking measuring with minimum accuracy of one millimeter? If yes, Arduino is your choice.
If no, Mindstorms are better.


But wait: what about just prototyping your robot? Even if you're a master in smithing, it could be usefull to use Lego prefabricated components to realize a low-cost, reusable and easy-to-modify prototype. It will helps to test your software "on the road" without loosing your precious hardware if something going wrong. It's also useful to give a live demonstration of your robot. It could be more impressive to see something real (it's not important how ugly it looks) than looking something moving on a monitor.


Some links

Friday, 4 March 2011

Tutorial: iPad Should Rotate



The iPad is a wonderful device. It's really magic. Even if you dislike (or hate) Apple, you must admit it's a very funny gizmo.
My first iPad App was refused because iPad Guidelines are a bit different than iPhone's ones. iPad hasn't got a right way to be picked on, so you must manage rotations.
Well, if your App requires just a "portait" view (as mine), you have just to add this code to every ViewController in your app

- (BOOL) shouldAutorotateToInterfaceOrientation:
    (UIInterfaceOrientation)interfaceOrientation{
        return UIInterfaceOrientationIsPortait(interfaceOrientation);
}

Thursday, 3 March 2011

Never Reinvent the Wheel

In these days I'm writing a small roguelike. I started it in Java, but soon I moved to LÖVE, a framework for 2D games based on OpenGL and Lua. After some days I've got "something working" (moving camera, smooth characters, entities, doors, items) so I reflected about the "reinventing the wheel anti-pattern".
As a programmer, I enjoy to write code. I tried many times to write an OpenGL 3D engine; I tried many times to write a 2D platform game engine. But after all, is a good idea to write yourself all this code when somebody already did it?
Obviously no, but believe me: to reinvent the wheel is a strong temptation and, often, we follow it unconsciously.
Don't invent your own configuration language: there's already Lua.
Don't write your own 3D engine: there's Panda 3D, Crystal Space, Irrlicht Engine, Ogre 3D, the various ID Tech (now they're under GPL).
You'll earn time and you'll see result sooner then you think, allowing you to give more attention to the most important things of your program.

Wednesday, 2 March 2011

The endless VIM vs EMACS debate

Many programmers prefer using VIM instead of EMACS. They claims it's better because it's faster, smaller and easier to configure.
What to say about?
In these days I wrote a small iPhone framework in python. It requires a TAB-separated-Table as input. I used Aquamacs to write this input file and my program crashed. Why? Aquamans inserted some tab characters, I don't know why.
I rewrite that input with VIM and all worked well.
Another "life case": I tried to install lua-mode on a Windows 2000 workstation and on my MacBook Pro. I failed in both cases. I think after two tries, a system is not enough user friendly, so i give up.
Confused? It's normal. VIM has a easier learning curve. It's boring to write tons of code, but it could be more usefull than EMACS. EMACS is good if you accept an "evolutionary model", where you write day-by-day your .emacs file.

And if you are tired, there's always JEdit :)