Robotics Tutorial Controlling a Robot with MSRS .
-
Upload
ashlie-wilkinson -
Category
Documents
-
view
218 -
download
1
Transcript of Robotics Tutorial Controlling a Robot with MSRS .
Robotics TutorialRobotics Tutorial
Controlling a Robot with MSRSControlling a Robot with MSRS
http://msdn.microsoft.com/en-us/library/cc998559.aspx
Robotics TutorialRobotics Tutorial
David LeeDavid LeeSr. Software Development EngineerSr. Software Development EngineerMicrosoft CorporationMicrosoft Corporation
Controlling a Robot with Microsoft Robotics StudioControlling a Robot with Microsoft Robotics Studio
OverviewOverviewThe IdeaThe Idea
Write an MSRS Application which Write an MSRS Application which will:will:
Drive a LEGO NXT TribotDrive a LEGO NXT TribotOpen a Direction DialogOpen a Direction Dialog
Wait for Button PressWait for Button Press
Send Commands to the RobotSend Commands to the Robot
Stop when the button is releasedStop when the button is released
DialogDrive Application
OverviewOverviewThe IdeaThe Idea
Write an MSRS Application which Write an MSRS Application which will:will:
Drive a LEGO NXT TribotDrive a LEGO NXT TribotOpen a Direction DialogOpen a Direction Dialog
Wait for Button PressWait for Button Press
Send Commands to the RobotSend Commands to the Robot
Stop when the button is releasedStop when the button is released
Direction Direction DialogDialog
State
DialogDialogDriveDrive
State
Generic Generic Differential Differential
DriveDrive State
Robotics Tutorial Robotics Tutorial PrerequisitesPrerequisites
A basic understanding of MSRSA basic understanding of MSRS
To create this demo yourselfTo create this demo yourselfVisual Studio Pro or ExpressVisual Studio Pro or Express
A basic knowledge of CSharpA basic knowledge of CSharp
A LEGO NXT which has already been A LEGO NXT which has already been paired with your Bluetooth adapterpaired with your Bluetooth adapter
OverviewOverviewDirection DialogDirection Dialog
MSRS Sample ServiceMSRS Sample Service
Five ButtonsFive Buttons
Two NotificationsTwo NotificationsButtonPressButtonPress
ButtonReleaseButtonRelease
Name: Name: LeftLeft
RightRightForwardsForwards
BackwardBackwardss
StopStop
Direction Direction DialogDialog
State
OverviewOverviewGeneric Differential DriveGeneric Differential Drive
Very simple drive systemVery simple drive systemControlled by applying power Controlled by applying power individually to the left and right motorsindividually to the left and right motors
SetDrivePowerSetDrivePower Action ActionLeftWheelPower, RightWheelPower:LeftWheelPower, RightWheelPower:values between -1.0 and 1.0 (double)values between -1.0 and 1.0 (double)
Generic Generic Differential Differential
DriveDrive State
OverviewOverviewGeneric Differential DriveGeneric Differential Drive
Generic ContractGeneric ContractIntended to be implemented by multiple Intended to be implemented by multiple servicesservicesDescribes the state and behavior of a serviceDescribes the state and behavior of a serviceIdentified by a unique contractIdentified by a unique contract
Generic Differential DriveGeneric Differential DriveContract: Contract: http://schemas.microsoft.com/robotics/2006/05/drivhttp://schemas.microsoft.com/robotics/2006/05/drive.htmle.html
MSRS ships with several Differential Drive MSRS ships with several Differential Drive services:services:
Lego “NXT Generic Drive”Lego “NXT Generic Drive”““iRobot® Generic Drive”iRobot® Generic Drive”““Simulated Generic Differential Drive”Simulated Generic Differential Drive”Pioneer “Arcos Drive”Pioneer “Arcos Drive”““Traxster Generic Drive”Traxster Generic Drive”
Generic Generic Differential Differential
DriveDrive State
OverviewOverviewDialogDriveDialogDrive
Create a ServiceCreate a ServiceDssNewService.exeDssNewService.exe
Partner with the Partner with the Generic Generic Differential DriveDifferential Drive
Partner with the Partner with the Direction DialogDirection Dialog sample sample
CoordinationCoordinationUse direction buttons to drive the RobotUse direction buttons to drive the Robot
Test the ServiceTest the ServiceGeneric contracts and switching Generic contracts and switching hardwarehardware
DialogDialogDriveDrive
State
OverviewOverviewDialogDriveDialogDrive
MethodsMethodsStart()Start()
InitializationInitialization
SubscribeToDirectionDialog()SubscribeToDirectionDialog()Send Button Notifications to my HandlersSend Button Notifications to my Handlers
DialogButtonPressHandler()DialogButtonPressHandler()““Forwards”, “Backwards”Forwards”, “Backwards”
““Left”, “Right”, “Stop”Left”, “Right”, “Stop”
DialogButtonReleaseHandler()DialogButtonReleaseHandler()Stop DrivingStop Driving
DialogDialogDriveDrive
State
Dialog DriveDialog Drive
DialogDrive Application
Robotics TutorialRobotics TutorialCreating a ServiceCreating a Service
DssNewService.exeDssNewService.exedssnewservice /service:DialogDrivedssnewservice /service:DialogDrive
Partner with your mobile RobotPartner with your mobile RobotAdd references: Add references:
RoboticsCommon.Proxy.dllRoboticsCommon.Proxy.dll
DirectionDialog.Y2006.M08.proxy.dllDirectionDialog.Y2006.M08.proxy.dll
Add using … with namespace prefix:Add using … with namespace prefix:
using dialog = Microsoft.Robotics.Services.Sample.using dialog = Microsoft.Robotics.Services.Sample.DirectionDialog.ProxyDirectionDialog.Proxy;;
using drive = Microsoft.Robotics.Services.using drive = Microsoft.Robotics.Services.Drive.ProxyDrive.Proxy;;
Robotics TutorialRobotics TutorialCreating a ServiceCreating a Service
Set up Operation Ports for the dialog Set up Operation Ports for the dialog and drive services.and drive services.
CreateAlways vs. UseExistingCreateAlways vs. UseExisting
[[PartnerPartner("dialog", ("dialog", Contract = dialogContract = dialog.Contract.Identifier,.Contract.Identifier,
CreationPolicy = PartnerCreationPolicy.CreateAlways)]CreationPolicy = PartnerCreationPolicy.CreateAlways)]
private dialog.private dialog.DirectionDialogOperationsDirectionDialogOperations _dialogPort = new _dialogPort = new dialog.DirectionDialogOperations();dialog.DirectionDialogOperations();
[[PartnerPartner("drive", ("drive", Contract = driveContract = drive.Contract.Identifier,.Contract.Identifier,
CreationPolicy = PartnerCreationPolicy.UseExisting)]CreationPolicy = PartnerCreationPolicy.UseExisting)]
private drive.private drive.DriveOperationsDriveOperations _drivePort = new _drivePort = new drive.DriveOperations();drive.DriveOperations();
Robotics TutorialRobotics TutorialCreating a ServiceCreating a Service
On Start, enable the drive and On Start, enable the drive and Subscribe to “button” NotificationsSubscribe to “button” Notifications
protected override void protected override void StartStart()()
{{
base.Start();base.Start();
_drivePort.EnableDrive(_drivePort.EnableDrive(
new new drive.EnableDriveRequest(true));drive.EnableDriveRequest(true));
SubscribeToSubscribeToDirectionDialogDirectionDialog();();
}}
Robotics TutorialRobotics TutorialCreating a ServiceCreating a Service
Listen for button pressListen for button presseded and and releasereleasedd and call the appropriate and call the appropriate handlerhandler..
private void private void SubscribeToDirectionDialogSubscribeToDirectionDialog()()
{{
dialog.dialog.DirectionDialogOperationsDirectionDialogOperations dialogNotifications = dialogNotifications =
new dialog.DirectionDialogOperations();new dialog.DirectionDialogOperations();
_dialogPort._dialogPort.SubscribeSubscribe(dialogNotifications);(dialogNotifications);
Activate<ITask>(Activate<ITask>(
Arbiter.Arbiter.ReceiveReceive<dialog.<dialog.ButtonPressButtonPress>( true,>( true,
dialogNotifications, DialogButtonPressHandler), dialogNotifications, DialogButtonPressHandler),
Arbiter.Arbiter.ReceiveReceive<dialog.<dialog.ButtonReleaseButtonRelease>( true,>( true,
dialogNotifications, DialogButtonReleaseHandler));dialogNotifications, DialogButtonReleaseHandler));
}}
Robotics TutorialRobotics TutorialCoordinationCoordination
Dialog Button Press HandlerDialog Button Press Handler““Name” identifies which button was Name” identifies which button was pressed.pressed.
While the button is being pressed, start While the button is being pressed, start driving our robot in the specified driving our robot in the specified direction.direction.
private void private void DialogButtonPressHandlerDialogButtonPressHandler(dialog.ButtonPress buttonPress)(dialog.ButtonPress buttonPress) {{ LogInfo(LogGroups.Console, buttonPress.Body.Name + " Pressed");LogInfo(LogGroups.Console, buttonPress.Body.Name + " Pressed");
switch (switch (buttonPress.Body.NamebuttonPress.Body.Name)) {{
case "case "ForwardsForwards":":
_drivePort.SetDrivePower(new_drivePort.SetDrivePower(new
drive.drive.SetDrivePowerRequestSetDrivePowerRequest((1.0, 1.01.0, 1.0));));
break;break;
Robotics TutorialRobotics TutorialCoordinationCoordination
Dialog Button Press HandlerDialog Button Press Handlercase "case "ForwardsForwards":":
_drivePort.SetDrivePower(new drive._drivePort.SetDrivePower(new drive.SetDrivePowerRequestSetDrivePowerRequest(1.0, 1.0)(1.0, 1.0));); break;break;
case "case "LeftLeft":":
_drivePort.SetDrivePower(new drive._drivePort.SetDrivePower(new drive.SetDrivePowerRequestSetDrivePowerRequest(-1.0, 1.0)(-1.0, 1.0));); break;break;
case "case "RightRight":":
_drivePort.SetDrivePower(new drive._drivePort.SetDrivePower(new drive.SetDrivePowerRequestSetDrivePowerRequest(1.0, -1.0)(1.0, -1.0));); break;break;
case "case "BackwardsBackwards":":
_drivePort.SetDrivePower(new drive._drivePort.SetDrivePower(new drive.SetDrivePowerRequestSetDrivePowerRequest(-1.0, -1.0)(-1.0, -1.0));); break;break;
case "case "StopStop":":
_drivePort.SetDrivePower(new drive._drivePort.SetDrivePower(new drive.SetDrivePowerRequestSetDrivePowerRequest(0, 0)(0, 0));); break;break;
Robotics TutorialRobotics TutorialCoordinationCoordination
Button Release NotificationsButton Release NotificationsStop driving when a button is releasedStop driving when a button is released
private void private void DialogButtonReleaseHandlerDialogButtonReleaseHandler((
dialog.ButtonRelease buttonRelease)dialog.ButtonRelease buttonRelease)
{{
LogInfoLogInfo(LogGroups.Console, (LogGroups.Console,
buttonbuttonReleaseRelease.Body.Name + " Released");.Body.Name + " Released");
_drivePort._drivePort.SetDrivePowerSetDrivePower((
new drive.new drive.SetDrivePowerRequestSetDrivePowerRequest(0, 0));(0, 0));
}}
Compile!Compile!
Robotics TutorialRobotics TutorialTest the ServiceTest the Service
ManifestsManifestsA Manifest contains a list of services to A Manifest contains a list of services to be startedbe started
DssNewService created a default DssNewService created a default manifest:manifest:
DialogDrive.manifest.xmlDialogDrive.manifest.xml
The The DirectionDialogDirectionDialog service was marked service was marked “CreateAlways” “CreateAlways”
It will be started automatically by our It will be started automatically by our service. service.
LEGO “LEGO “NXT Generic DriveNXT Generic Drive” is ” is instantiated by:instantiated by:
LEGO.NXT.Tribot.manifest.xmlLEGO.NXT.Tribot.manifest.xml
Direction Direction DialogDialog
State
Dialog Dialog DriveDrive
State
Generic Generic DifferentialDifferential
DriveDriveState
Robotics TutorialRobotics TutorialTest the ServiceTest the Service
How did I find the LEGO manifest?How did I find the LEGO manifest?Use VPL to look up Service to Manifest Use VPL to look up Service to Manifest relationshipsrelationships
Robotics TutorialRobotics TutorialTest the ServiceTest the Service
Start a DSS Node with DssHost.exeStart a DSS Node with DssHost.exe
Using two manifests:Using two manifests:LEGO.NXT.TriBot.manifest.xmlLEGO.NXT.TriBot.manifest.xml
DialogDrive.manifest.xmlDialogDrive.manifest.xml
Robotics TutorialRobotics TutorialTest the ServiceTest the Service
Inspect the Inspect the running running service with service with a browsera browser
Configure the Configure the LEGO BrickLEGO Brick
Presss Presss [Connect][Connect]
Press and Press and hold an hold an arrow on the arrow on the direction direction dialogdialog
SummarySummaryControlling a Robot with MSRSControlling a Robot with MSRS
Create an orchestration service that:Create an orchestration service that:Drives a RobotDrives a Robot
Partners with a robotics servicePartners with a robotics service
Connects to a Generic ContractConnects to a Generic Contract
Subscribes to NotificationsSubscribes to Notifications
Issues commands to the robotic serviceIssues commands to the robotic service
© 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.