Microsoft Robotics Studio
Miguel Angel Ramos BarrosoMVP ASP.NET
Microsoft Code Camp Junio 2007
¿Robots?
Gran variedad de hardware…
¿Qué es una aplicación para Robots?
Objetivo: Responder a un sensorEjemplo: Arrancar un motor cuendo se pulse un botón (sensor)
Explorer (Orchestrator
)
Bumper (Sensor)
Drive (Actuator)
¿Qué es una aplicación para Robots?
Mensaje(Actuator)
Motor
Motor
Orquestador
Bumper (Sensor)
Bumper (Sensor)
Detector Infrarrojos(Sensor)
Microsoft Robotics Studio (MSRS)
Plataforma de desarrollo para programar robots que soporta una gran variedad de hardware y escenarios
Runtime Concurrencia Infraestructura en
Servicios
Servicios y Ejemplos Ejemplos y tutoriales Servicios para Robots Modelos de Robots
Microsoft Robotics Studio
Herramientas Simulador Visual Programming
Language
Objetivos conseguidos…
Configurar sensores y actuadores en un sistema en ejecución
Coordinar sensores y actuadores asincronamente
Iniaciar y parar componentes dinamicamente
Monitorizar, Interactuar y depurar en tiempo de ejecución
Desarrollar cuando el acceso al robot es limitado
Extenderse sobre multiples ordenadores
Reutiliar componentes através de distintas plataformas de hardware y dispositivos.
Entorno de Desarrollo
Construido sobre CLR 2.0PortableConcurrencia y coordinaciónInfraestructura distribuidaEntorno de despliegue muy ligero para los serviciosMuy integrado con tecnologias Web
Servicios Personalidados
Infraestructuradistribuida
Biblioteca deconcurrencia
Entorno de Desarrollo
Modelo de aplicación distribuidoDistributed Application Model (DSS)
Simple, flexible, y orientado a serviciosGrano grueso y poco acopladoCompatible con la infraestructura Web actual
Modelo concurrente de programcionConcurrent Programming Model (CCR)
Enfocado en la coordinación de mensajesNos oculta los tradicionales threads y locksHabilita la ejucución secuencial sin bloquear los thread entre I/O, evitando las cadenas de callback
¿Qué es una aplicación para Robots?
Mensaje(Actuator)
Motor
Motor
Orquestador
Bumper (Sensor)
Bumper (Sensor)
Detector Infrarrojos(Sensor)
Modelo de aplicación distribuido (DSS)
Esquema de aplicación
Mensaje(Actuator)
Motor
Motor
Orquestador
Bumper (Sensor)
Bumper (Sensor)
Detector Infrarrojos(Sensor)
Orquestación de sensores y actuadores.
En el se subscriben
los servicios
Un servicio puede ser Partner
de otros muchos servicios
Puede representar:Hardware: Sensores, actuadoresSoftware: UI, AlmacenamientoAgregados: Mash-Ups, conjuntos de sensores
Se reutiliazan gracias a la composición:
Separar el estado del comportamiento (No ocultes el estado)
Servicios
Port
State
Handlers
Service
FIFO
Ejemplo de Servicio Bumper
Estructura del estado.
Los manejadores de eventos fuera de la estructuraOperaciones sobre el estado:
GET, QUERY, UPDATE, DELETE, DROP, SUBSCRIBE
Interacciones de servicios
Runtime, Hosting Environment y System Services
Programación del CCR
Los fundamentos para escribir aplicaciones para Robotics.
El CCR Runtime
Modelo asíncrono de programaciónUn modelo concurrente sin programarnos a a mano threads, locks o semáforos.
Basado en mensajes asíncronosEnfocados en la coordinación de primitivasEjecución secuencial pero sin tener hilos bloqueados y sin necesidad de callbacks, sólo cuando sea necesario.
Contexto de ejecución para los serviciosAislamiento de la infraestructuraAislamiento de otros servicios
Mensajes, Puertos y Árbitros
Los mensajes son enviados a los PuertosPort<int> myPort = new Port<int>() ;myPort.Post (42) ;
Los Puertos contienen:Una FIFO que gestiona los mantiene los valores del puerto…Una lista de continuidades que pueder ser ejecutada dependiendo del mensaje que llegue y el arbitraje
La continuacion es representada por un delegado en C#Puede ser anónimo o nombrado
ÁrbitrosImplementa los contructores de enlaces o entrelazado de las concurrencia.
Primitivas CCRIteradores en C# como una forma de agenda…
Escala millones de elementos concurrentes pendientes, usa solo un hilo por microprocesador, se programa de la forma tradicional.
Single item receiverEjecuta sólo el código cuando llega un mensaje
Choice arbiter Elige un mensaje recibido (join o single) de muchos, a través de diferentes piertos, lo ejecuta solo una vez con las condiciones conocidas descartando a otros.
JoinStaticDynamic
Interleave arbiterTeardown group, Concurrent Group, Exclusive Group
Ejemplo: Iterators
IEnumerator<ITask> MultistageIterator(){ bool result = false; Port<bool> port = new Port<bool>(); // Stage A, send request port.Post(true); yield return Arbiter.Receive(false, port, delegate(bool b)
{result=b; }); // Stage B, received first result, send second request port.Post(result); yield return Arbiter.Receive(false, port, delegate(bool b)
{result=b; }); // Stage C, received second result, print it Console.WriteLine(result);}
Ejemplo: ChoicePortSet<int, string> port = new PortSet<int, string>();
Activate(Arbiter.Choice(port, MyIntHandler, MyStringHandler)
);
void MyIntHandler(int i){ Console.WriteLine("Received: " + i);}
void MyStringHandler(string s){ Console.WriteLine("Received: " + s);}
Ejemplo: JoinPort<double> balancePort = new Port<double>();Port<int> depositPort = new Port<int>();
Activate(Arbiter.JoinedReceive<int,double>(true,
depositPort, balancePort, delegate(int b, double d)
{balance.post(b + d);
}));
Ejemplo: Dynamic JoinPortSet<Result,Exception> resultsPort = new PortSet<int>();
// parallel computation by posting requestsFor (int i=0;i<N;i++){ computePort.Post(new DoWork(someData,resultsPort));}
// requests complete asynchronously with unknown number// of failures vs. successesActivate(
Arbiter.MultipleItemReceive(resultsPort, delegate (ICollection<Result> successes, ICollection<Exception> failures){ foreach(Result r in results) { …… }});
Ejemplo: InterleaveInterleave coordination = Arbiter.Interleave( new TeardownGroup( Arbiter.Receive<Drop>(false, port, ShutdownHandler) ), new ExclusiveGroup( Arbiter.Receive<Update>(true,port,UpdateHandler), Arbiter.Receive<Insert>(true,port,InsertHandler) ), new ConcurrentGroup( Arbiter.Receive<Query>(true,port,QueryHandler) ));
Activate(coordination);
[ServiceHandler(ServiceHandlerBehavior.Concurrent)] public IEnumerator<ITask> GetHandler(Get get) { get.ResponsePort.Post(_state); yield break; }
[ServiceHandler(ServiceHandlerBehavior.Exclusive)] public IEnumerator<ITask> UpdateHandler(Update update) { _state.CurrentResult += update.Body.Value; update.ResponsePort.Post(new UpdateResponse()); yield break; }
Coodinación de ServiciosDe forma declarativa
Recursos
Web sitehttp://www.microsoft.com/robotics
Community Newsgrouphttp://msdn.microsoft.com/robotics/
Wiki with Patterns and Trouble Shooting
http://channel9.msdn.com/wiki/default.aspx/Channel9.MSRoboticsStudio
© 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.
Lego Mindstorms NXT
1. NXT Brick2. Touch Sensor3. Sound Sensor4. Light Sensor5. Ultrasonic
Sensor6. Servo Motors
(3)• NXT Programming Software (LabView)• Bluetooth & USB Communications
NXT Projects
SummaryBroad third party support
Microsoft Robotics StudioApplication deployment models
Supports standalone and distributed processing scenarios
Disconnectedautonomous operation (with optional networked monitoring)
Distributed execution(execution across compute units)
Connected operation(remote execution on PC)
Robotics Studio Runtime
Joystick serviceUI service
Microsoft Robotics StudioInteraction through the browser
Service state observable at all levels of the applicationServices are capable of providing rich representation of data
Robot Motor
services
Sensor services
Browser Robot DashboardScripting Connect
Robotics Studio Runtime
JS ServiceJS Service JS Service
Motor services
Sensor services
Microsoft Robotics Studio Driving a robot with the browser and JScript
Robotics Runtime
Concurrencyand coordination
runtime
Runtime
Activation
Discovery
Diagnostics
Monitoring
UX
Storage
DecentralizedSystemServices
Algorithms
…
Sensors
Actuators
ReferenceServices
Services
Simulation
Visualization
AuthoringServices
Sensors Actuators
Custom/Application Services
Orchestration Control