One for (Almost) All: Using a Modern Programmable Programming Language in Robotics or A Roboticist in Language Wonderland Berthold Bäuml berthold.baeuml@dlr.de Autonomous Learning Robots Lab Institute of Robotics and Mechatronics German Aerospace Center (DLR)
Trend in Software Development • use of modern programming languages • moving away from dynamic scripting languages like Python or Ruby • all functional and (almost all) strong static type system Twitter backend backend of Chat Service Deutsche Bank Haskell tools for innovative trading group high speed trading “used for everything” ba
Demands of Modern Software Systems • execution performance • interpreters are intrinsically slow! • modern compilation and JIT techniques to come close to C/C++
Haskell Scala Computer Language Benchmarks Game SBCL Lisp OCaml Java Scheme/Racket Clojure Erlang gcc g++ Fortran Java 7 Python Ruby
Demands of Modern Software Systems • execution performance • interpreters are intrinsically slow! • modern compilation and JIT techniques to come close to C/C++ • maintenance and debugging • dynamic scripting languages good for prototyping • but for large code base and number of developers more language support for maintainability is needed • modern strong and static type system + type inference uncovers many application logical errors as type errors at compile time • support for functional programming: encourages/-forces immutability -> flow of state explicit -> easier to reason about • productivity in developing complex algorithms and application logic • function combination rather than object composition • highly efficient functional data structures • parallel execution • support for multi-core/multi-CPU has to be built into the language
Functional Programming -- Functional Programming Languages • from Matthias Felleisen, “Functional Programming is Easy, and Good for You” http://www.ccs.neu.edu/home/matthias/Presentations/11GS/gs.pdf Functional programming is about clear, concise communication between Functional programming programmers . languages keep you honest about being functional . A good transition needs training, but training pays off.
Haskell Scala OCaml Erlang Clojure Scheme Gambit/Racket functional + + + + + + typed (static) + + + - - - / (+) mutation - + + - + + strictness lazy strict(&lazy) strict(&lazy) strict strict strict / strict (lazy) parallel ++ + JoCaml ++ ++ Termite / + compiled native JVM native VM (native JVM C-code / VM- HiPE) JIT
Demands of Advanced Robotic Systems • what robots we are talking about -> advanced complex humanoids • different to, e.g., fleets of quadrocopters • with respect to computing power necessary and available! • esp. in our case: platform for fundamental research -> flexibility for developing new solutions from ground up more important than integrating many existing “classical” solutions • ...
Demands of Advanced Robotic Systems sensing acting • stereo cameras (2MPixel/25Hz) • 53 DOF = 8 (plattform) + 19 (torso) + RGB-D sensor (0.5MPixel/33Hz) 26 (hands) • torque sensor (all DOF, 1kHz) • torque control over all DOF • 1kHz, <3ms latency, <100us Jitter tactile skin on hands (3000taxel/750Hz) • IMU (6D, 500Hz) computing • 4x Core i7 Quadcore (onboard) • CPU cluster with 64 cores • GPGPU cluster 16 NVidia K20
GigE circle detector 25Hz/25ms 1394 pose estimator MHT/UKF GigE 512Hz/0.5ms 25Hz/10ms circle detector 25Hz/25ms ball tracker Linux/ 25Hz/35ms TD QuadCore GigE Sercos arm/torso/head control (19DOF) state machine/ 1kHz communicator/ SpaceWire view control user hand control USB 1kHz interaction 1kHz CAN platform control QNX/ TD 60Hz/50ms 2x DualCore GUI 3D viewer planner TD 25Hz/60ms Linux SQP SQP optimizer SQP logic planner optimizer SQP 60ms optimizer 60ms optimizer TD QNX/ 60ms Linux TD 60ms 32 Cores
Demands of Advanced Robotic Systems • easy interfacing/interaction with C/C++ for low-level, hard realtime, highly performant code (control algorithms, image processing) • multi-platform support:robotic system are often heterogenous (realtime OS, drivers only for certain OS, ...) • actor model and continuations: • for concurrent, parallel and distributed computing • to build complex synchronization and execution patterns for orchestration of interwoven task/behavior nets • not purely functional: to easily work with changing states of robots and world • Domain Specific Languages (DSLs) • robotic system span wide range of different tasks • DSLs can respect different abstractions also syntactically, e.g., • kinematic/dynamic/geometrical description • complex and concurrent state machines • data types of the communication packets
Domain Specific Languages -- An Important Concept in Modern Software Design • a little story ... by courtesy of Matthew Flatt, University of Utah (to see the animation run in Racket: (require (planet mflatt/princess:1:2/play-movie)) DSLs are cool ! DSLs are cool ! Domain specific languages are
Domain Specific Languages -- An Important Concept in Modern Software Design • a little story ... by courtesy of Matthew Flatt, University of Utah doc LaTeX
Domain Specific Languages -- An Important Concept in Modern Software Design • a little story ... • abstractions for different tasks/fields/domains often best expressed in specific language (with optimized syntax and semantics) • embedded domain specific languages (DSELs) use infrastructure of implementing language and extend these: languages as libraries • popular approaches for full fledged DSELs (including control structs) • lazy functional languages (Haskell, Scala): functions and combinators • meta-programming == syntax rewriting/manipulating the AST • Lisps, Clojure, Scheme: macro systems “directly” manipulates S-exp • Template Haskell, MetaOCaml, Scala Macros (since 2.10) • if implementing language is a compiled language, also the DSL is a compiled (and efficient) language! • even full fledged language extension possible ...
Macro Systems • A macro extends a language by specifying how to compile a new feature into existing features • The macro is itself implemented in the programming language, not an external tool. • more on macros (taken from a talk of Robby Findler)... • “history” of Scheme macros • text replacing • syntax replacing macros • hygienic macros (obey lexical scoping) • advanced macro systems • with syntax object containing source location -> precise error messages
Java-like Class System as “DSEL” • implemented with macros in Scheme (Racket) • performance ~ interface-based Java calls • M. Flatt, R. B. Findler, M. Felleisen “Scheme with Classes, Mixins, and Traits” (class object% (define fish% (class object% (init size) ....)) (init size) (define charlie (new fish% [size 10])) (define current-size size) (super-new) (define/public (get-size) current-size) > (send charlie grow 6) (define/public (grow amt) > (send charlie get-size) (set! current-size (+ amt current-size))) 16 (define/public (eat other-fish) (grow (send other-fish get-size))))
Haskell Scala OCaml Erlang Clojure Scheme Gambit/Racket functional + + + + + + typed (static) + + + - - - / (+) mutation - + + - + + strictness lazy strict(&lazy) strict(&lazy) strict strict strict / strict (lazy) parallel ++ + JoCaml ++ ++ Termite / + compiled native JVM native VM (native JVM C-code / VM- HiPE) JIT
Haskell Scala OCaml Erlang Clojure Scheme Gambit/Racket functional + + + + + + typed (static) + + + - - - / (+) mutation - + + - + + strictness lazy strict(&lazy) strict(&lazy) strict strict strict / strict (lazy) parallel ++ + JoCaml ++ ++ Termite / + compiled native JVM native VM (native JVM C-code / VM- HiPE) JIT distributed Cloud Haskell actors JoCaml actors!! no native, Termite / distrib.places e.g., Akka FFI (w/o glue) + JNA experimental + JNA + / + platforms Lin/Mac/Win Lin/Mac/Win Lin/Mac/Win Lin/Mac/Win Lin/Mac/Win gcc / Lin/Mac/ Win DSELs ++ ++ + + + + / + (functional) simple macros lisp macros meta Template macros MetaOCaml macros / Haskell (experiment.) programming adv. macros
Radical System Architecture: Use One Language for (Almost) All • modern higher level functional languages • are performant • have “batteries included”: GUI, networking, FFI, ... • fulfill (almost) all challenges in robotic • radical design • one language for all • except for small C/C++ snippets (highest performance/determinism) • language built-in parallel and distributed execution/communication • efficient DSELs for the various data description or execution logic tasks • benefits • general higher productivity with higher level language • homogeneity drastically reduces system complexity • developers have to/can learn in-depth one language • no conceptual or practical “frictional loss” due to language coupling • same higher level concepts in all components (type system, data structures, closures, continuations, ...) • distributed communication of higher level concepts -- in contrast to “least common denominator” of multi-language-compatible middleware (aRD: static packets, ROS: dynamic arrays, ...
vision driver planner GPU state machine Simulink GUI
Recommend
More recommend