Sunday, November 30, 2008

F# LegoNxt Robot


I am learning F# since 07/2007 and looked always for an opportunity to put my F# coding skills in to practice. I grabbed my son’s Lego Nxt and wrote a library in F# to communicate with Lego Nxt Brick via Blue Tooth . I have added support for two moving motors (Port B and C) , touch sensor (Port 1) and sonar sensor(Port4). Joe Armstrong (Erlang Programming Language) told in an interview something like this :
In a real world, people also act concurrently from one another and this all works fine and we don’t need to be Siamese twins with conjoined brains(hint :shared memory). I am using Erlang style Message Passing Style using F# MailboxProcessor for collecting data and to control nxt robot.
In source code , I have written an example AutonomousNxtBrick which will drive autonomic and avoid collision.

Enjoy