A few weeks ago i posted the video about my demo of the LEGO Mindstorms robot, controlled by a Runbook inside the Service Management Automation section of Windows Azure Pack
The video has been seen by many people and i have gotten so much great feedback!
Multiple people have asked me of “How did you do that?”
I have decided to do a multi part post, first posting the details, then more guides to how to do the different setup tasks
Part 1 – SMA Runbook, Overview + Setup
Part 2 – How to setup a variable asset in SMA (Robot Com port value)
Part 3 – How to setup a connection asset in SMA (Robot Server conneciton)
First the Video:
URL: http://youtu.be/1Al-dY-DHlw
Blog post: https://blog.ctglobalservices.com/?p=7308
and here is how to do it!
Setup Robot connection and asssemblies
- Build the LEGO Robot using the build manual!
- Pair the robot to a computer which has PowerShell Remoting enabled.
- Open Bluetooth settings and check the com port number of which is the outgoing port to EV3. (COM10 in this example)
- Download the LEGO Mindstorms EV3 .net library from CodePlex here
- Place the Desktop assembly, Lego.Ev3.Desktop.dll, on the computer. Note the location for use later.
Setup Service Management Automation Runbook
- Logon to Windows Azure Pack administration site
- Create a mgmt server connection asset called RobotServer (How to, will be explained in Part 3)
- Create a setting asset, called RobotPort. This is a string asset with the value of the COM port of which the robot is connected via bluetooth (COM10 etc.) (will be explained in Part 2)
- Edit the New-Robotnotification workflow to make sure the Path to the Lego.Ev3.Desktop.dll assembly is correct.
- Import the New-RobotNotification runbook/workflow to SMA.
- Publish the runbook.
- Start the runbook and provide directory (Left/Right)
- Wait for the magic to happen!
Download the workflow here:
[download id=”200″]
or copy paste the code from below:
workflow New-RobotNotification { <# .SYNOPSIS A workflow developed for demo'ing a LEGO Mindsstorms EV3 robot via Windows Azure Pack - Service Management Automation .DESCRIPTION This workflow was originally developed by Jakob Gottlieb Svendsen, Datacenter MVP, Coretech, Denmark .LINK#> # Specify input parameters here param ( [parameter(Mandatory=$true)] [string]$Direction ) $comPort = Get-AutomationVariable -Name 'RobotComPort' $Connection = Get-AutomationConnection -Name 'RobotServer' $Password = ConvertTo-SecureString -AsPlainText ` -String $Connection.Password -Force $Cred = New-Object -TypeName System.Management.Automation.PSCredential ` -ArgumentList $Connection.Username, $Password $result = InlineScript { $ErrorActionPreference = "stop" [System.Reflection.Assembly]::LoadFrom("E:\Data\System Center\WAP\SMA\Workflows\LEGO Mindstorms\Lego.Ev3.1.0.0\Desktop\Lego.Ev3.Desktop.dll") $com = new-object Lego.Ev3.Desktop.BluetoothCommunication -ArgumentList $Using:comPort $brick = new-object Lego.Ev3.Core.Brick -ArgumentList $com, $true $result = $brick.ConnectAsync() Start-Sleep -Seconds 1 if($result.Status -eq "Faulted") { throw "cannot connect to robot $($result.Exception)" } #help #$brick.DirectCommand | gm #Go Forward $brick.DirectCommand.TurnMotorAtPowerForTimeAsync("B",100, 0, 5 * 1000, 0, $false) $brick.DirectCommand.TurnMotorAtPowerForTimeAsync("C",100, 0, 5 * 1000, 0, $false) Start-Sleep -Seconds 5 if ($Using:Direction -eq "Left") { #Turn 90 degrees Left $brick.DirectCommand.StepMotorAtPowerAsync("B", -100, 0, 400, 0, $false); $brick.DirectCommand.StepMotorAtPowerAsync("C", 100, 0, 400, 0, $false); } else { #Turn 90 degrees Right $brick.DirectCommand.StepMotorAtPowerAsync("B", 100, 0, 400, 0, $false); $brick.DirectCommand.StepMotorAtPowerAsync("C", -100, 0, 400, 0, $false); } Start-Sleep -Seconds 1 #wave flag for($i=0;$i -lt 5;$i++) { $brick.DirectCommand.TurnMotorAtPowerForTimeAsync("B",-100, 0, 0.5 * 1000, 0, $false) $brick.DirectCommand.TurnMotorAtPowerForTimeAsync("C",100, 0, 0.5 * 1000, 0, $false) Start-Sleep -Milliseconds 500 $brick.DirectCommand.TurnMotorAtPowerForTimeAsync("B",100, 0, 0.5 * 1000, 0, $false) $brick.DirectCommand.TurnMotorAtPowerForTimeAsync("C",-100, 0, 0.5 * 1000, 0, $false) Start-Sleep -Milliseconds 500 } } –PSComputer $Connection.ComputerName –PSCredential $Cred write-debug ($result | Out-String) }
Have fun!
and please dont hesistate to comment or contact me about ideas/fixes/anything related to system center or Windows Azure Pack
Hi,
How will Azure Automation knows that from where it should pickup the .dll. I have to load CloudStorageClient.dll. Please advice. Many thanks!
Regards,
Viswanatha Swamy
Hello Viswanatha
In this demo i am using Service Management Automation which means i have control of the servers executing the code and can place the DLL on them locally before it run it.
You dont have that control in Microsoft Azure Automation.
Maybe you can reach your goal by creating a module, and then making it portable:
http://blogs.technet.com/b/orchestrator/archive/2013/11/04/service-management-automation-portable-modules-what-why-and-how.aspx
Lego rocks!
get social signals
wpccqdlpp cdgso cquvhwu lows fgeamhrwxciybbv