Robotics Tutorial Controlling a Robot with MSRS. Robotics Tutorial David Lee Sr. Software...

download Robotics Tutorial Controlling a Robot with MSRS. Robotics Tutorial David Lee Sr. Software Development Engineer Microsoft Corporation Controlling a Robot.

If you can't read please download the document

Transcript of Robotics Tutorial Controlling a Robot with MSRS. Robotics Tutorial David Lee Sr. Software...

  • Slide 1

Robotics Tutorial Controlling a Robot with MSRS Slide 2 Robotics Tutorial David Lee Sr. Software Development Engineer Microsoft Corporation Controlling a Robot with Microsoft Robotics Studio Slide 3 Overview The Idea Write an MSRS Application which will: Drive a LEGO NXT Tribot Open a Direction Dialog Wait for Button Press Send Commands to the Robot Stop when the button is released DialogDrive Application Slide 4 Overview The Idea Write an MSRS Application which will: Drive a LEGO NXT Tribot Open a Direction Dialog Wait for Button Press Send Commands to the Robot Stop when the button is released Direction Dialog State DialogDrive Generic Differential Drive State Slide 5 Robotics Tutorial Prerequisites A basic understanding of MSRS To create this demo yourself Visual Studio Pro or Express A basic knowledge of CSharp A LEGO NXT which has already been paired with your Bluetooth adapter Slide 6 Overview Direction Dialog MSRS Sample Service Five Buttons Two Notifications ButtonPressButtonReleaseName:LeftRightForwardsBackwards Stop Direction Dialog State Slide 7 Overview Generic Differential Drive Very simple drive system Controlled by applying power individually to the left and right motors SetDrivePower Action LeftWheelPower, RightWheelPower: values between -1.0 and 1.0 (double) Generic Differential Drive State Slide 8 Overview Generic Differential Drive Generic Contract Intended to be implemented by multiple services Describes the state and behavior of a service Identified by a unique contract Generic Differential Drive Contract: http://schemas.microsoft.com/robotics/2006/05/drive.html MSRS ships with several Differential Drive services: Lego NXT Generic Drive iRobot Generic Drive Simulated Generic Differential Drive Pioneer Arcos Drive Traxster Generic Drive Generic Differential Drive State Slide 9 Overview DialogDrive Create a Service DssNewService.exe Partner with the Generic Differential Drive Partner with the Direction Dialog sample Coordination Use direction buttons to drive the Robot Test the Service Generic contracts and switching hardware DialogDrive State Slide 10 Overview DialogDrive MethodsStart()InitializationSubscribeToDirectionDialog() Send Button Notifications to my Handlers DialogButtonPressHandler() Forwards, Backwards Left, Right, Stop DialogButtonReleaseHandler() Stop Driving DialogDrive State Slide 11 Dialog Drive Application Slide 12 Robotics Tutorial Creating a Service DssNewService.exe dssnewservice /service:DialogDrive Partner with your mobile Robot Add references: RoboticsCommon.Proxy.dllDirectionDialog.Y2006.M08.proxy.dll Add using with namespace prefix: using dialog = Microsoft.Robotics.Services.Sample.DirectionDialog.Proxy; using drive = Microsoft.Robotics.Services.Drive.Proxy; Slide 13 Robotics Tutorial Creating a Service Set up Operation Ports for the dialog and drive services. CreateAlways vs. UseExisting [Partner("dialog", Contract = dialog.Contract.Identifier, CreationPolicy = PartnerCreationPolicy.CreateAlways)] CreationPolicy = PartnerCreationPolicy.CreateAlways)] private dialog.DirectionDialogOperations _dialogPort = new dialog.DirectionDialogOperations(); [Partner("drive", Contract = drive.Contract.Identifier, CreationPolicy = PartnerCreationPolicy.UseExisting)] CreationPolicy = PartnerCreationPolicy.UseExisting)] private drive.DriveOperations _drivePort = new drive.DriveOperations(); Slide 14 Robotics Tutorial Creating a Service On Start, enable the drive and Subscribe to button Notifications protected override void Start() { base.Start(); base.Start(); _drivePort.EnableDrive( _drivePort.EnableDrive( new drive.EnableDriveRequest(true)); SubscribeToDirectionDialog(); SubscribeToDirectionDialog();} Slide 15 Robotics Tutorial Creating a Service Listen for button pressed and released and call the appropriate handler. private void SubscribeToDirectionDialog() { dialog.DirectionDialogOperations dialogNotifications = new dialog.DirectionDialogOperations(); _dialogPort.Subscribe(dialogNotifications); Activate( Arbiter.Receive ( true, Arbiter.Receive ( true, dialogNotifications, DialogButtonPressHandler), dialogNotifications, DialogButtonPressHandler), Arbiter.Receive ( true, Arbiter.Receive ( true, dialogNotifications, DialogButtonReleaseHandler)); dialogNotifications, DialogButtonReleaseHandler));} Slide 16 Robotics Tutorial Coordination Button Release Notifications Stop driving when a button is released private void DialogButtonReleaseHandler( dialog.ButtonRelease buttonRelease) dialog.ButtonRelease buttonRelease){ LogInfo(LogGroups.Console, LogInfo(LogGroups.Console, buttonRelease.Body.Name + " Released"); buttonRelease.Body.Name + " Released"); _drivePort.SetDrivePower( _drivePort.SetDrivePower( new drive.SetDrivePowerRequest(0, 0)); new drive.SetDrivePowerRequest(0, 0));}Compile! Slide 19 Robotics Tutorial Test the Service Manifests A Manifest contains a list of services to be started DssNewService created a default manifest: DialogDrive.manifest.xml The DirectionDialog service was marked CreateAlways It will be started automatically by our service. LEGO NXT Generic Drive is instantiated by: LEGO.NXT.Tribot.manifest.xml Direction Dialog State Dialog Drive State Generic Differential Drive State Slide 20 Robotics Tutorial Test the Service How did I find the LEGO manifest? Use VPL to look up Service to Manifest relationships Slide 21 Robotics Tutorial Test the Service Start a DSS Node with DssHost.exe Using two manifests: LEGO.NXT.TriBot.manifest.xmlDialogDrive.manifest.xml Slide 22 Robotics Tutorial Test the Service Inspect the running service with a browser Configure the LEGO Brick Presss [Connect] Press and hold an arrow on the direction dialog Slide 23 Summary Controlling a Robot with MSRS Create an orchestration service that: Drives a Robot Partners with a robotics service Connects to a Generic Contract Subscribes to Notifications Issues commands to the robotic service Slide 24 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.