RemoteDCL

Transcription

RemoteDCL
10 July 2002
RemoteDCL
A component-based environment to carry out
experiments with mobile robots over the Internet
HASSO - PLATTNER - INSTITUT
für Softwaresystemtechnik
Teammembers
Human
Helge Issel
Kai Köhne
Michael Richter
Stefan Henze
Kai Müller
Artificial
Hunter
Runner
HPI, SS2002: Middleware und Komponentenprogrammierung / 2
Agenda
Introduction
Involved projects
Aim of the project
Existing Tools
Overview
The whole system
The three main components
Interesting Parts
Configuration
Compiler
LNPoI
Tracker
Testing
Other platforms
Living example
HPI, SS2002: Middleware und Komponentenprogrammierung / 3
Involved Projects
DCL
Distributed Control Lab
part of the professorship „Betriebssysteme und Middleware“ / HPI
aim is the research of software paradigm and design patterns allowing a
connection between middleware-based components and embedded
(mobile) systems
experiments with component software and mobile devices
DISCOURSE
Distributed & Collaborative University Research & Study Environment
“a distributed laboratory for distributed computing featuring advanced
middleware technology”
FU, TU, HU Berlin, HPI are involved
a testbed for research and a reference platform for teaching
usage of Microsoft .NET technology
HPI, SS2002: Middleware und Komponentenprogrammierung / 4
Aim of the Project
To develop a component-based environment which allows for
creating experiments easily
experiments involve to control and communicate with mobile devices
further requirements
The components should be simple to replace
new experiments should require minimal changes
existing tools & programs should be integrated
the primary framework should be Microsoft .NET
HPI, SS2002: Middleware und Komponentenprogrammierung / 5
Existing Tools
RCX
of the "Lego Mindstorms Robotics Invention System" in-a-box robot-kit
a productized version of the MIT Programmable Brick
uses the Hitachi H8/3292 microcontroler
RAM size 512 K / speed 16Mhz@5V
supports Infrared communication
legOS
a free (primitive) OS for he RCX
consists of a kernel as a replacement for the original firmware and several
utilities (f.ex. to download new programs)
user tasks are executed as native code
supported language is C and C++
user programs are compiled with GCC on the PC and downloaded as
binaries to the RCX
Remote Control Patch: kernel extension to support downloading, starting
and stopping programs remotely
HPI, SS2002: Middleware und Komponentenprogrammierung / 6
Existing Tools II
Cygwin
provides a UNIX environment under Windows
consists of
library to emulate UNIX syscalls (cygwin1.dll)
various UNIX programs (bash, gcc …)
needed by legOS to compile & download programs under Windows
LNPoI
Lego Network Protocol over Internet
a router for LNP (Lego Network Protocol) messages
LNP messages consist of a header used for addressing and a body
equivalent to UDP packages
communicates
with programs on the PC over TCP/IP
with the RCX over an Infrared Tower
HPI, SS2002: Middleware und Komponentenprogrammierung / 7
The Web-Interface
was already designed for another DCL experiment (a
programmable pendulum)
consists of
various Active Server Pages
a controller for registering new experiments
handles user authentication & authorisation
Interface for an experiment to implement:
HPI, SS2002: Middleware und Komponentenprogrammierung / 8
Agenda
Introduction
Involved projects
Aim of the project
Existing Tools
Overview
The whole system
The three main components
Interesting Parts
Configuration
Compiler
LNPoI
Tracker
Testing
Other platforms
Living example
HPI, SS2002: Middleware und Komponentenprogrammierung / 9
Overview
Browser
RemoteDCL Systemsicht der Softwareebenen der Experimente sowie RCX-Hardware
Webserver and MasterControl
IDCLControl
IDCLControl
RemoteDCL
DCLControl RCX
Configuration
IRCXRunner
legOSCompile
RCXRunnerControl
legOSCompileControl
File
Storage
LNPOI
DLL
Tracker
VideoStreamer
VideoStreamer
VideoStreamer
IlegOSCompile
RCXRunner
Tracker
Component
DCLControl Pendel
GCC
Compiler
LEGO Tower
RCX
RCX
Tracking Hardware
(Webcam)
HPI, SS2002: Middleware und Komponentenprogrammierung / 10
Security
Checker
Webcam
Webcam
Webcam
The Experiment Controller
«interface»
SInterfaces::IDCLControl
+DownLoad(inout file : string) : string
+Start() : string
+Stop() : string
+SendOpCode(inout code : string) : string
+GetStatus() : string
«interface»
SInterfaces::IRegistration
+ControllerRef() : string
+Finalize()
+StartController() : bool
SDCLControlRCX::DCLControlRCX
-binaryFile : IFile
-robo2Prog : IFile
-homeRunnerProg : IFile
+ControllerRef() : string{polymorphic,sequential,__CG_C#_operation_kind = Property}
+Finalize(){polymorphic,sequential}
+StartController() : bool{polymorphic,sequential}
+DownLoad(inout file : string) : string{polymorphic,sequential}
+Start() : string{polymorphic,sequential}
+Stop() : string{polymorphic,sequential}
+SendOpCode(inout code : string) : string{polymorphic,sequential}
+GetStatus() : string{polymorphic,sequential}
1
-Controller
1
-Controller
1
-RcxRunner
1
-CompileControl
«interface»
SInterfaces::IRCXRunnerControl
+getStatus() : string
+download(in fileRobot1 : IFile, in fileRobot2 : IFile)
+start()
+stop()
+send(in message : string, in to : int)
+init(in homeRunner : IFile)
«interface»
SInterfaces::ILegOSCompileControl
+setCompilerPath(in compilerPath : string)
+setOutputPath(in outputPath : string)
+createBinary(in fileObject : IFile) : IFile
+createFileFromString(in text : string) : IFile
+getErrorMessages() : IMessageContainer
+setCompilerOptions(in param : string)
SRCXRunnerControl::RCXRunnerControl
SLegOSCompile::LegOSCompileControl
-config : RCXConfig
-status : string
+getStatus() : string
+download(in fileRobot1 : IFile, in fileRobot2 : IFile)
+start()
+stop()
+send(in message : string, in to : int)
+init(in homeRunner : IFile)
-SetStatus(in message : string)
-GoHome()
-startExperimentThread()
HPI, SS2002: Middleware und Komponentenprogrammierung / 11
+setCompilerPath(in compilerPath : string)
+setOutputPath(in outputPath : string)
+createBinary(in fileObject : IFile) : IFile
+createFileFromString(in text : string) : IFile
+getErrorMessages() : IMessageContainer
+setCompilerOptions(in param : string)
+LegOSCompileControl(in compilerPath : string, in outputPath : string)
The Compiler
«interface»
SInterfaces::ILegOSCompileControl
+setCompilerPath(in compilerPath : string)
+setOutputPath(in outputPath : string)
+createBinary(in fileObject : IFile) : IFile
+createFileFromString(in text : string) : IFile
+getErrorMessages() : IMessageContainer
+setCompilerOptions(in param : string)
SLegOSCompile::LegOSCompileControl
+setCompilerPath(in compilerPath : string)
+setOutputPath(in outputPath : string)
+createBinary(in fileObject : IFile) : IFile
+createFileFromString(in text : string) : IFile
+getErrorMessages() : IMessageContainer
+setCompilerOptions(in param : string)
+LegOSCompileControl(in compilerPath : string, in outputPath : string)
1
1
1
-Controller
1
1
1
-messageContainer
-Compiler
-Security Checker
«interface»
SInterfaces::ICompiler
+compile(in file : IFile) : IFile
+getMessages() : IMessageContainer
+setOptions(in param : string)
+getStatus() : string
+getOutputPath() : string
+getCompilerPath() : string
+setOutputPath(in outputPath : string)
+setCompilerPath(in outputPath : string)
«interface»
SInterfaces::ISecurityChecker
+check(in file : IFile) : bool
+getStatus() : string
+getMessages()
«interface»
SInterfaces::IMessageContainer
+next() : IMessage
+isEmpty() : bool
+add(in newMessage : IMessage)
SLegOSCompile::LegOSCompiler
SLegOSCompile::MessageList
+next() : IMessage
+isEmpty() : bool
+add(in newMessage : IMessage)
+MessageList()
1
-Container
*
-Element
«interface»
SInterfaces::IMessage
+getType() : string
+getMessageText() : string
+getRow() : int
+getLine() : int
SLegOSCompile::LegOSSecurityChecker
-messageList : MessageList
-status : string
+check(in file : IFile) : bool
+getStatus() : string
+getMessages()
+LegOSSecurityChecker()
-compilePath : string
-compileOptions : string
-status : string
-messageList : MessageList
-outputPath : string
+compile(in file : IFile) : IFile
+getMessages() : IMessageContainer
+setOptions(in param : string)
+getStatus() : string
+getOutputPath() : string
+getCompilerPath() : string
+setOutputPath(in outputPath : string)
+setCompilerPath(in outputPath : string)
+LegOSCompiler(in compilerPath : string, in outputPath : string)
SLegOSCompile::Message
-type : string
-body : string
-column : int
-row : int
+getType() : string
+getMessageText() : string
+getRow() : int
+getLine() : int
+Message(in messageText : string, in type : string, in row : int, in line : int)
HPI, SS2002: Middleware und Komponentenprogrammierung / 12
The RCXRunner
«interface»
SInterfaces::IRCXRunnerControl
+getStatus() : string
+download(in fileRobot1 : IFile, in fileRobot2 : IFile)
+start()
+stop()
+send(in message : string, in to : int)
+init(in homeRunner : IFile)
SRCXRunnerControl::RCXRunnerControl
-config : RCXConfig
-status : string
+getStatus() : string
+download(in fileRobot1 : IFile, in fileRobot2 : IFile)
+start()
+stop()
+send(in message : string, in to : int)
+init(in homeRunner : IFile)
-SetStatus(in message : string)
-GoHome()
-startExperimentThread()
1
1
1
-TrackerControl
«interface»
SInterfaces::ITrackerControl
+Config() : TrackerConfig
+Position() : TrackerPosition
1
1
-Downloader
«interface»
SInterfaces::IDCLDLL
+download(in rcxNr : int, in file : IFile, in programSlot : int)
+setDllPath(in path : string)
1
-Router
«interface»
SInterfaces::ILNPOI
+connectUSB(in port : byte, in mask : byte, in usbnr : byte) : bool
+disconnectUSB(in port : byte, in mask : byte) : bool
+start(in rcxNr : byte, in programNr : byte) : bool
+stop(in rcxNr : byte) : bool
+send(in rcxNr : byte, in data : string) : bool
+receive(in rcxNr : byte) : string
SDLL::Dll
-status : string
+download(in rcxNr : int, in file : IFile, in programSlot : int)
+setDllPath(in path : string)
STrackerControl::TrackerControl
-config : TrackerConfig
-position : TrackerPosition
+Config() : TrackerConfig
+Position() : TrackerPosition
HPI, SS2002: Middleware und Komponentenprogrammierung / 13
SLNPOI::LNPOI
+connectUSB(in port : byte, in mask : byte, in usbnr : byte) : bool
+disconnectUSB(in port : byte, in mask : byte) : bool
+start(in rcxNr : byte, in programNr : byte) : bool
+stop(in rcxNr : byte) : bool
+send(in rcxNr : byte, in data : string) : bool
+receive(in rcxNr : byte) : string
Agenda
Introduction
Involved projects
Aim of the project
Existing Tools
Overview
The whole system
The three main components
Interesting Parts
Configuration
Compiler
LNPoI
Tracker
Testing
Other platforms
Living example
HPI, SS2002: Middleware und Komponentenprogrammierung / 14
Configuration - Concept
Problem
interfaces abstract from implementation, nevertheless often
implementation-specific configuration data needed by implementing class
Idea:
a single object which encapsulates all configuration data reduces coupling
between components
configuration may be stored in an configuration file or generated at runtime
allows design of small, „clean“ interfaces which concentrate on functional
requirements
as default: data should be stored in XML-files
HPI, SS2002: Middleware und Komponentenprogrammierung / 15
Configuration - Implementation
Realisation
configuration may only be set once
config-objects builds in-memory lightweight object-tree representing current
configuration
components may only access well-known sub trees, hence component
data clearly separated
each component gets a private copy of the (sub-) tree Æ data tamper-proof
Implementation
uses „Builder-Pattern“
configuration object calls a „Config-Builder“ object, configured with an
„XML-Director“
parsing of XML-file done by „Director“, tree build by „Config-Builder“ Æ
allows (not implemented) for different file formats
HPI, SS2002: Middleware und Komponentenprogrammierung / 16
Configuration – Builder-Pattern
«interface»
IBuilder
+buildNode()
+setProperty()
«interface»
IDirector
1
1
ConfigBuilder
ConfigDirector
ConfigNode
+buildNode()
+setProperty()
+getConfiguration()
HPI, SS2002: Middleware und Komponentenprogrammierung / 17
Compiler - Concept
Concept
definition of interface to allow easy substitution with different compilers
classes implement a compiler or encapsulate access to an external
compiler running in a separate process
«interface»
SInterfaces::ILegOSCompileControl
LegOSCompileControl
+setCompilerPath()
+setOutputPath()
+createBinary()
+createFileFromString()
+getErrorMessages()
+LegOSCompileControl()
1
-Compiler
1
-Controller
LegOSCompiler
Factory method
generation of source and binary files
HPI, SS2002: Middleware und Komponentenprogrammierung / 18
1
-Security Chec
LegOSSecurityChecker
Compiler - Implementation
using GCC
RCX-native file loaded as kernel extension, therefore multiple creational
steps necessary
compiling, relocation text segent, linking against kernel symbol table …
using of make Æ requires using bash-script
Facade
our „compiler“ is an facade for class that actual encapsulates „gcc“ and a
„security checker“ class
Why a Security Checker?
using C as programming language is risky: some programmers may try to
overwrite control routines on robots
to provide (at least) some safeguard mechanisms: scanning code for
potentially harmful constructs
relies on regular expressions
HPI, SS2002: Middleware und Komponentenprogrammierung / 19
LNPoI
LNPoI Æ transport protocol used to communicate with the robots
Situation:
Sourcecode for handling LNPoI available
Problem:
Available only in C++
Solution:
Wrapping code within a managed C++ class
The .Net managed C++ Extensions
integration of C++ into .Net
class / function wrapping
data marshaling
Design pattern implemented: Wrapper
HPI, SS2002: Middleware und Komponentenprogrammierung / 20
Tracking Environment
How to know where we are?
many experiments need the knowledge of position
RCX-Robots running in a flat world
the world is a disc (a table is nearly a disc)
sudden death must be prevented (they must not fall down from the table)
World can be observed by a camera
track the position of a robot in an image
calculate the Robot’s position in the world
tracking data must be submitted
to the experiment environment
and the Robots
HPI, SS2002: Middleware und Komponentenprogrammierung / 21
Components working together
Configurator
Filter 2
R
Data Server
Filter 1
Camera
HPI, SS2002: Middleware und Komponentenprogrammierung / 22
C#
TrackerControl
CamShift Filter
COM-Component
DirectX
DirectMedia used to get video stream from the camera
output on the screen
Filter Chains
Configurator builds up filter chains to apply CamShift-Filter to the video
CamShift-Filter
area selected by user
filter creates a histogram with matching colors for that area
based on this it looks for a rectangle filled with these colors
by moving the colored area the filter recognizes changes and calculates a
new rectangle
points within this rectangle are submitted to a data server
integration
we integrated the whole data-capturing to get coordinates of the tracked
data out of the filter
HPI, SS2002: Middleware und Komponentenprogrammierung / 23
Tracking Data Server
COM-Object
singleton
we have one component that holds all tracked data
filters register themselves to that object
integrating COM in C# and .NET Framework
see Lecture
how it works
filters send their data to the server every time they track a position
very often
experiment pulls the data from the server whenever it wants to
sometimes (about 2 times a second)
may be configured by experiment-configuration
the big deal
we could use any data server that matches the interface
might be changed even at runtime
HPI, SS2002: Middleware und Komponentenprogrammierung / 24
Tracking Theory
HPI, SS2002: Middleware und Komponentenprogrammierung / 25
Tracking Theory
HPI, SS2002: Middleware und Komponentenprogrammierung / 26
Tracking Theory
HPI, SS2002: Middleware und Komponentenprogrammierung / 27
Tracking Theory
HPI, SS2002: Middleware und Komponentenprogrammierung / 28
O1
Tracking Theory
b
pt
a
pl
O2
p
d
c
HPI, SS2002: Middleware und Komponentenprogrammierung / 29
Configurator
HPI, SS2002: Middleware und Komponentenprogrammierung / 30
Agenda
Introduction
Involved projects
Aim of the project
Existing Tools
Overview
The whole system
The three main components
Interesting Parts
Configuration
Compiler
LNPoI
Tracker
Testing
Other platforms
Living example
HPI, SS2002: Middleware und Komponentenprogrammierung / 31
Testing
Testing-Environment for all components
all self-written components but controllers have their own test-classes
each step during the experiment (compiling, downloading, tracking…) can be
tested separately
controllers can use dummy-components for some components
creating a well defined world by simulating user, and robots
may be heavily improved
Log4NET
thanks for org.apache.log4j
easy logging with several levels
HPI, SS2002: Middleware und Komponentenprogrammierung / 32
Agenda
Introduction
Involved projects
Aim of the project
Existing Tools
Overview
The whole system
The three main components
Interesting Parts
Configuration
Compiler
LNPoI
Tracker
Testing
Other platforms
Living example
HPI, SS2002: Middleware und Komponentenprogrammierung / 33
Other platforms?
Key features important for our project
remoting
interoperability with native code
interoperability with COM-components
CORBA
CORBA addresses only remoting, therefore it is not suited
Java
very powerful all-purpose language / component software
discussed in more detail on following slides
COM
is a mess
HPI, SS2002: Middleware und Komponentenprogrammierung / 34
Java – Remoting / Processes
Java allows for Java-specific remoting (Java RMI)
powerful, but usage more complicated
creation of special interface
creation of stub/skeleton with separate compiler (rmic)
rmi naming service has to be started on server
in contrast: C# a class has to inherit from MarshalByRef object – that‘s all
Java allows creating / using of CORBA-objects
bridge between both worlds: RMI over IIOP
makes RMI-objects „real“ CORBA-objects (language interoperability!)
Processes
Java allows creation / destruction of processes as well as communication
with them (via redirected stdin / stdout / stderr )
HPI, SS2002: Middleware und Komponentenprogrammierung / 35
Java – interacting with native / C /C++ code
Using of C-functions / C-libraries
JNI (Java Native Interface) allows calling of C-functions
works with Dlls (under Windows)
requires preliminary modifications to code
developer needs access to source code or
to encapsulate existing functions within own functions
Interacting with C++ objects
feasible: C++ using Java objects
as far as we know no way the other way around: C++ objects can not be
referenced under Java
COM-interoperability
we did not found any tool / library addressing that problem
only Microsoft‘s Java compiler dated from 1998 allowed COMinteroperation
HPI, SS2002: Middleware und Komponentenprogrammierung / 36
.NET vs. Java EJBs - Performance
Microsoft‘s „Pet Store“
Microsoft implemented Sun‘s „Pet Store“ with .NET
several benchmarks, latest made by VeriTest: .NET about 10 times faster
„NILE“-benchmark (implementation of an online-shop)
3 times faster, better scaling on multiple CPUs
benchmark sponsored by Microsoft
Conclusions drawn
no widely accepted benchmark available – Pet Store benchmark had to be
repeated several times due to mistakes
benchmark results controversial discussed in the net
interesting: SUN pretends .Net doesn’t exists Æ maybe .NET really faster
„platform“-performance relies heavily on underlying middleware (application
server, databases, ... )
HPI, SS2002: Middleware und Komponentenprogrammierung / 37
Agenda
Introduction
Involved projects
Aim of the project
Existing Tools
Overview
The whole system
The three main components
Interesting Parts
Configuration
Compiler
LNPoI
Tracker
Testing
Other platforms
Living example
HPI, SS2002: Middleware und Komponentenprogrammierung / 38
...
... Demonstration and further perspectives ...
HPI, SS2002: Middleware und Komponentenprogrammierung / 39
What‘s next
short term goals
open the experiment to the DISCOURSE-project
further generalize components
support alternative experiment
long term goals
develop a new, more secure scripting language
use handhelds supporting .NET as mobile devices (instead of directly
communicating with the RCX)
HPI, SS2002: Middleware und Komponentenprogrammierung / 40
Links
http://gotdotnet.com/team/compare/
http://www.onjava.com/pub/a/onjava/2001/11/28/catfight.html
HPI, SS2002: Middleware und Komponentenprogrammierung / 41

Similar documents