Connecting Lego MindStorms to K2 Blackpearl

One of the tools that comes with K2 Blackpearl is Smartobjects and it has this brilliant feature of being able to talk to endpoint assemblies (.dlls). Which opens up K2 to  a whole world of possibilities.

So after an afternoon sat searching the internet on API’s and to make things easier started with researching .Net APIs. I came across this excellent community project on codeplex Lego Mindstorms .Net API. So with this in hand. I started to build a endpoint assembly that would allow K2 talk to Lego. How cool is that?

Creating these endpoint assemblies is easy enough. Your methods need need to be public and static.  (I will publish step by step guide on how to do this.)

Like in the example code below

public async static void MoveBackwards(int Power)
brick.BatchCommand.TurnMotorAtSpeedForTime(OutputPort.B, Power, 1000, false);
brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.C, Power, 1000, false);

brick.BatchCommand.PlayTone(50, 1000, 500);
await brick.BatchCommand.SendCommandAsync();
catch (Exception ex)
{ }

All you need to is the build the project and drop any third party dlls into service broker folder on your K2 server and then register the dll of your project with the ServiceObject Tester. This will then expose your  methods as objects which you can then use to build your Smartobjects which you can then use in Smartforms and in your workflows.


You can download the code for the endpoint assembly here K2 Lego Robot Source code

Here is a link of K2D2 in Action at DevWeek 2014

I will post the step by step instructions on how to set it up soon