Brick in the Cloud

The Lego Machine Cloud Project


2 Comments

First Robot Built

I’ve completed my first build and run a few programs from the standard Lego software to test the mechanics. Its a pretty impressive peace of kit! Here are a few pictures of the standard Alpha Rex robot. With one major enhancement, can you spot it? It is capable of communicating with the internet via its fetching Wifi back pack!

photo (2)  photo  photo (1)

After doing a few tests with the backpack idea, sadly it does effect the balance of the robot, so some tweaking might be required, I’m thinking tracks….


Leave a comment

NXC Programming

NXC (Not eXactly C) is an alternative way to program Lego Mindstorms. While the drag and drop interface is actually pretty good, I wanted the flexibility of a programming language. Having determined that HumaRobotics sensor has a NXC library I set about installing the necessary custom firmware and compiler on my Mac. It turns out the community tooling and IDE’s are much more advanced for Windows, however some support for Mac users does exist.

next_tools

Having installed the replacement firmware and thankfully avoided bricking my brick! The new firmware actually still permits the standard Lego software programs plus NXC programs to be downloaded. I set about trying a few NXC programs, they compile and downloaded to the robot in a few seconds. Here is my first program that reads the value of the colour sensor!

task main()
{
    SetSensorColorFull(S3);
    while(true)
    {
        ColorSensorReadType csr;
        csr.Port = S3;
        SysColorSensorRead(csr);
        if (csr.Result == NO_ERR) {
            NumOut(0, LCD_LINE1, csr.ColorValue);
        }
        Wait(1000);
    }
}

I was also able to get the sample WifiBlock NXC code working. It demonstrates the robot making some HTTP GET to some simple Web Services hosted on the HumaRobotics website. Displaying the results on its LCD display.

#define WB_PORT IN_4

byte humaroboticsip[]={88,190,16,18};

void getDateTime() {
  string date=quickGET(WB_PORT,humaroboticsip,"/wb/date.php");
  string time=quickGET(WB_PORT,humaroboticsip,"/wb/time.php");
  if (date!="" && time!="") {
    TextOut(0,LCD_LINE1,"Date: "+date+"      ");
    TextOut(0,LCD_LINE2,"Time: "+time+"      ");
  }
  else TextOut(0,LCD_LINE1,"GET ERROR");
}

void getCityFromZIP(string country,string zip) {
  string res=quickGET(WB_PORT,humaroboticsip,"/wb/cp.php?c="+country+"&z="+zip);
  if (res!="") {
    TextOut(0,LCD_LINE1,zip+", "+country+"         ");
    TextOut(0,LCD_LINE2,res+"          ");
  }
  else TextOut(0,LCD_LINE1,"GET ERROR");
}

task main()
{
  byte ip[]={192,168,0,222};
  byte mask[]={255,255,255,0};
  byte gw[]={192,168,0,1};
  if (quickConnect(WB_PORT,"myssid",WB_SECURITY_WPA2,"wifipass",ip,mask,gw)) {
    while (true) {
      getDateTime();
      getCityFromZIP("US","02101"); // Boston
    }
  }
  else {
    TextOut(0,LCD_LINE1,"CONNECT ERROR");
  }
  Wait(60000);
}

I’m quite pleased with this weekends work, in between fixing a family laptop with a corrupt master boot record, its been a tech heavy weekend! Fun!


Leave a comment

HumaRobotics Wifi Block

Key to this project is a means for the robot to communicate with the outside world on its own without the aid of a PC or MAC. Lego Mindstorms robots support Bluetooth and USB connections with a PC or Mac but lack the ability to use a Wifi network.

Enter the HumaRobotics Wifi Block! This plugs into an available sensor port on the NXT. HumaRobotics developers have also done an excellent job of integrating with the Mindstorms drag and drop programming tool, so I was able to get the Wifi Block configured to my Wifi network and thus to the internet pretty easily *.

Screen Shot 2013-02-24 at 12.25.23

There are 4 programming blocks provided in this environment, the WifiBlock Utils block allows the NXT to communicate with the Wifi Block. By dragging this onto the programming surface you can give it the usual Wifi connectivity details.

Screen Shot 2013-02-24 at 12.27.33

Once the indicator light on the block is a steady green, I was able to confirm the connection by pinging it!

photo

Screen Shot 2013-02-24 at 12.37.10

Now that I had made a connection, I was keen to start building. There are many robots that can be built with the kit. I am starting with one of the advanced ones, the Alpha Rex robot. I’ll be giving him a more appropriate name later!

* A lot easier in fact, than getting the Mindstorms software running on Mac OS 10.7. I was pleased to find a great Lego resource on the net, linked with another favourite pastime of mine, StackExchange! Lego Answers Beta.
 


2 Comments

The Lego Machine Cloud Project

I’ve always been a big fan of Lego, mainly Lego Technic. Since the introduction of Lego Mindstorms I’ve been exploring the possibilities of combining Lego Mindstorms with my current personal and professional interest in Cloud Computing.

I’m always looking for new ways to leverage Cloud based technologies, one such technology I’m working with in my professional life is Salesforce.com. This blog and project is purely recreational however. It will explore a new Cloud which Salesforce.com is inspiring…

The Machine Cloud

While attending last years Salesforce Dreamforce 2012 event in San Francisco. Marc Benioff (Salesforce.com, CEO) highlighted in his key note speech. A new form of Cloud that is taking shape around us. That of the Machine Cloud! This is the basic inspiration for this new blog!

We are all consuming Cloud services such as Twitter, Facebook, eBay, iCloud etc everyday. The Machine Cloud, expands this to the machines we use day to day. Allowing those machines to interact with Cloud services and in doing so the humans that use them as well. From jet engines to the cars we drive, machines are starting to adopt the Cloud! If at this point your maybe thinking Judgement Day. Worry not, its unlikely a Lego Robot talking to the Cloud will take over the world!

Project Aim

Fun demonstration of a Lego Robot interacting with humans via Cloud technologies, in this case the Salesforce.com Cloud.

The robot must be directly connected to the Internet and be able to transmit and receive messages over HTTP. Allowing it to communicate (or perhaps Salesforce Chatter) the status of its various sensors (and hence its environment). While also allowing me to chat with it to ask questions or give commands.

Since I will be using the Salesforce.com Force.com Cloud platform. I already have a number of Web based technologies and API’s at my disposal, as well as means to create my own if needed. As the legendary Sherlock Holmes once said, “The game is afoot!”

salesforcecoms-bold-vision robot