Post on 12-Aug-2015
The Ongoing Democratization of Robotics Development
Paul Foster, Microsoft
Runtime
• CCR - Coordination and Concurrency library
• DSS - Distributed Services Framework
Authoring Tools• Visual Simulation
Runtime and Editor
• Visual Programming Language
Services
• Samples and tutorials
• Robot services
• Robot models
• Technology services
Concurrency And Coordination Runtime (CCR)
DispatcherDispatcherPort
DispatcherQueues
ThreadsArbiterArbiter
HandlerHandlerArbiter is attached to portArbiter is attached to port
Arbiter is activated on queueArbiter is activated on queue
Dispatcher schedules items from its queues round-robin to run in its threads
Dispatcher schedules items from its queues round-robin to run in its threadsPost places a message
on the portPost places a message on the port
Arbiter checks whether it can consume the messageArbiter checks whether it can consume the message
Creates work item frommessage and handlerCreates work item frommessage and handler
Enqueue work itemEnqueue work item
Thread calls handler with message as arg Thread calls handler with message as arg
Scheduler picks next work item to executeScheduler picks next work item to execute
Single-Port Single-Port PrimitivesPrimitives
Code-Code-SchedulingScheduling(non port-(non port-specific)specific)
Multi-Port Multi-Port PrimitivesPrimitives
var dispatcher = new Dispatcher(0,”default”);var queue = new DispatcherQueue(dispatcher);var port = new Port<string>(); port.Post("Hello, World!"); Arbiter.Activate(queue, port.Receive(message => Console.WriteLine(message) ));
Port: Building block for sending and receiving messages
Port: Building block for sending and receiving messages
Post: Queues a messagePost: Queues a message
Task: Delegate that handles the message (message is consumed)
Task: Delegate that handles the message (message is consumed)
Receive coordination primitiveReceive coordination primitive
Dispatcher uses fixed number of threads, schedules from queues in round-robin
Dispatcher uses fixed number of threads, schedules from queues in round-robin
Port on which to receive the messagePort on which to receive the message
void Start(){ var queue = new DispatcherQueue(); var port = new Port<string>(); port.Post("Hello"); port.Post(“World”); Arbiter.Activate(queue, new IterativeTask(() => Hello(port) ) );}IEnumerator<ITask> Hello(Port<string> port){ for(var i=0; i<5; i++) { yield return port.Receive(); var message = (string)port; Console.WriteLine(message); }
Schedule iterative taskSchedule iterative task
Lambda captures arguments for iteratorLambda captures arguments for iterator
Yield execution until receive is satisfiedYield execution until receive is satisfied
Item retrieved after yieldItem retrieved after yield
Loops around asynchronous operations are easy
Loops around asynchronous operations are easy
CCR Concurrent Processing
Decentralized Software Services (DSS)
Microsoft Open Specification PromiseMicrosoft Open Specification PromiseMicrosoft Open Specification PromiseMicrosoft Open Specification Promise
<DriveState <Connected>true</Connected> <DistanceBetweenWheels>0.112</DistanceBetweenWheels> <LeftWheel> … </LeftWheel> <RightWheel> … </RightWheel> <PollingFrequencyMs>80</PollingFrequencyMs> <TimeStamp>2007-10-10T13:07:45.5195866-07:00</TimeStamp></DriveState>
Flexible UI
Service Orchestration
[Contract(Contract.Identifier)]class RecordKeeperService : DsspServiceBase{ [Partner(“PeopleLookup”, Policy = PartnerCreationPolicy.UseExistingOrCreate, Optional = false)] peopleLookup.OperationsPort _peopleLookupPort = peopleLookup.OperationsPort();
[ServicePort(“/recordkeeper”,AllowMultipleInstances = true] OperationsPort _mainPort;
protected override void Start() { base.Start(); }}
Declarative, dynamic composition, annotations picked up by visual editor
Declarative, dynamic composition, annotations picked up by visual editor
Attach handlers to operation port, publish instance URI in service directory
Attach handlers to operation port, publish instance URI in service directory
[ServiceHandler(ServiceHandlerBehavior.Concurrent)] public IEnumerator<ITask> QueryHandler(Query queryOp) { var response = FindItem(queryOp.Body); queryOp.ResponsePort.Post(response); yield break; }
[ServiceHandler(ServiceHandlerBehavior.Exclusive)]public IEnumerator<ITask> UpdateHandler(Update updateOp) { QueryAge queryAgeOp; yield return _peopleLookupPort.Query(out queryAgeOp); int age = (int) queryAgeOp.ResponsePort; UpdateRecord(age, updateOp.Body.Name); updateOp.ResponsePort.Post(new UpdateResponse()); }
CCR Interleave is iterator-aware, guaranteeing atomicity across asynchronous steps
CCR Interleave is iterator-aware, guaranteeing atomicity across asynchronous steps
Create causality at root of execution graphCreate causality at root of execution graph
Failure occurs on one of the side branchesFailure occurs on one of the side branchesDeal with error as
message at origin of execution
Deal with error as message at origin of execution
DSS/CCRLogSync Sample
Building applications with Microsoft Robotics Developer Studio
Building a custom robot and environment
Available DSS servicesAvailable DSS services
RequestRequest
NotificationNotification
ResponseResponseService instanceService instance
VPL Explorer
MRDS 2008 Licensing
Academic Edition Researchers and Students. Free unlimited runtime distribution. Via Academic Portal.
Standard Edition Professional Developers. Free unlimited runtime distribution $499
Express Edition Hobbyists. Not permitted to distribute runtime $Free
More information at http://microsoft.com/robotics
• http://imaginecup.com/• Robotics and Algorithm challenge– Interpreting, solution design, best
algorithm– Robotics in a virtual environment
• 2009 Worldwide Finals: Egypt– The robots are real!
Summary:
– Simpler concurrency and distributed computing
– Reusable components and standardization– Lower barrier to entry– All of these advantages are now available
for mobile, embedded, desktop and server platforms.
© 2008 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.