Download presentation
Presentation is loading. Please wait.
Published byAshlie Wilkinson Modified over 9 years ago
1
Robotics Tutorial Controlling a Robot with MSRS http://msdn.microsoft.com/en-us/library/cc998559.aspx
2
Robotics Tutorial David Lee Sr. Software Development Engineer Microsoft Corporation Controlling a Robot with Microsoft Robotics Studio
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
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
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
6
Overview Direction Dialog MSRS Sample Service Five Buttons Two Notifications ButtonPressButtonReleaseName:LeftRightForwardsBackwards Stop Direction Dialog State
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
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
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
10
Overview DialogDrive MethodsStart()InitializationSubscribeToDirectionDialog() Send Button Notifications to my Handlers DialogButtonPressHandler() “Forwards”, “Backwards” “Left”, “Right”, “Stop” DialogButtonReleaseHandler() Stop Driving DialogDrive State
11
Dialog Drive Application
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;
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();
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();}
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<ITask>( Arbiter.Receive ( true, Arbiter.Receive ( true, dialogNotifications, DialogButtonPressHandler), dialogNotifications, DialogButtonPressHandler), Arbiter.Receive ( true, Arbiter.Receive ( true, dialogNotifications, DialogButtonReleaseHandler)); dialogNotifications, DialogButtonReleaseHandler));}
16
Robotics Tutorial Coordination Dialog Button Press Handler “Name” identifies which button was pressed. While the button is being pressed, start driving our robot in the specified direction. private void DialogButtonPressHandler (dialog.ButtonPress buttonPress) private void DialogButtonPressHandler (dialog.ButtonPress buttonPress) { LogInfo(LogGroups.Console, buttonPress.Body.Name + " Pressed"); LogInfo(LogGroups.Console, buttonPress.Body.Name + " Pressed"); switch (buttonPress.Body.Name) switch (buttonPress.Body.Name) { case "Forwards": _drivePort.SetDrivePower(new _drivePort.SetDrivePower(new drive.SetDrivePowerRequest(1.0, 1.0)); break; break;
17
Robotics Tutorial Coordination Dialog Button Press Handler case "Forwards": _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(1.0, 1.0) ); _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(1.0, 1.0) ); break; break; case "Left": _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(-1.0, 1.0) ); _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(-1.0, 1.0) ); break; break; case "Right": _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(1.0, -1.0) ); _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(1.0, -1.0) ); break; break; case "Backwards": _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(-1.0, -1.0) ); _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(-1.0, -1.0) ); break; break; case "Stop": _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(0, 0) ); _drivePort.SetDrivePower(new drive. SetDrivePowerRequest(0, 0) ); break; break;
18
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!
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
20
Robotics Tutorial Test the Service How did I find the LEGO manifest? Use VPL to look up Service to Manifest relationships
21
Robotics Tutorial Test the Service Start a DSS Node with DssHost.exe Using two manifests: LEGO.NXT.TriBot.manifest.xmlDialogDrive.manifest.xml
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
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
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.