One for (Almost) All: Using a Modern Programmable Programming - - PowerPoint PPT Presentation

one for almost all using a modern programmable
SMART_READER_LITE
LIVE PREVIEW

One for (Almost) All: Using a Modern Programmable Programming - - PowerPoint PPT Presentation

One for (Almost) All: Using a Modern Programmable Programming Language in Robotics or A Roboticist in Language Wonderland Berthold Buml berthold.baeuml@dlr.de Autonomous Learning Robots Lab Institute of Robotics and Mechatronics German


slide-1
SLIDE 1

One for (Almost) All: Using a Modern Programmable Programming Language in Robotics

Berthold Bäuml

berthold.baeuml@dlr.de Autonomous Learning Robots Lab Institute of Robotics and Mechatronics German Aerospace Center (DLR)

  • r

A Roboticist in Language Wonderland

slide-2
SLIDE 2

Trend in Software Development

  • use of modern programming languages
  • moving away from dynamic scripting languages like Python or Ruby

Twitter backend Haskell Deutsche Bank tools for innovative trading group backend of Chat Service high speed trading “used for everything” ba

  • all functional and (almost all) strong static type system
slide-3
SLIDE 3

Demands of Modern Software Systems

  • execution performance
  • interpreters are intrinsically slow!
  • modern compilation and JIT techniques to come close to C/C++
slide-4
SLIDE 4

Computer Language Benchmarks Game

SBCL Lisp Scheme/Racket Clojure Scala Haskell OCaml Erlang Java gcc g++ Fortran Java 7 Ruby Python

slide-5
SLIDE 5

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
slide-6
SLIDE 6

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 programmers. A good transition needs training, but training pays off. Functional programming languages keep you honest about being functional.

slide-7
SLIDE 7

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 HiPE) JVM C-code / VM- JIT

slide-8
SLIDE 8

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

  • ...
slide-9
SLIDE 9

Demands of Advanced Robotic Systems

sensing

  • stereo cameras (2MPixel/25Hz)

RGB-D sensor (0.5MPixel/33Hz)

  • torque sensor (all DOF, 1kHz)

tactile skin on hands (3000taxel/750Hz)

  • IMU (6D, 500Hz)

acting

  • 53 DOF = 8 (plattform) + 19 (torso) +

26 (hands)

  • torque control over all DOF
  • 1kHz, <3ms latency, <100us Jitter

computing

  • 4x Core i7 Quadcore (onboard)
  • CPU cluster with 64 cores
  • GPGPU cluster 16 NVidia K20
slide-10
SLIDE 10
slide-11
SLIDE 11

hand control

1kHz

arm/torso/head control (19DOF)

1kHz

platform control

60Hz/50ms

state machine/ communicator/ view control

1kHz

pose estimator

512Hz/0.5ms

circle detector

25Hz/25ms

circle detector

25Hz/25ms

MHT/UKF

25Hz/10ms

ball tracker

25Hz/35ms

Linux/ QuadCore planner

25Hz/60ms

SQP

  • ptimizer

60ms

SQP

  • ptimizer

60ms

SQP

  • ptimizer

60ms

SQP

  • ptimizer

60ms

QNX/ 32 Cores QNX/ 2x DualCore user interaction

GigE GigE 1394 GigE Sercos SpaceWire CAN TD TD TD USB

GUI 3D viewer Linux logic planner Linux

TD TD

slide-12
SLIDE 12

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
  • f 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
slide-13
SLIDE 13

Domain Specific Languages -- An Important Concept in Modern Software Design

DSLs are cool!

DSLs are cool!

Domain specific languages are

  • 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))

slide-14
SLIDE 14

Domain Specific Languages -- An Important Concept in Modern Software Design

LaTeX doc

  • a little story ... by courtesy of Matthew Flatt, University of Utah
slide-15
SLIDE 15

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 ...
slide-16
SLIDE 16

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

slide-17
SLIDE 17
  • 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% (init size) (define current-size size) (super-new) (define/public (get-size) current-size) (define/public (grow amt) (set! current-size (+ amt current-size))) (define/public (eat other-fish) (grow (send other-fish get-size)))) (define fish% (class object% (init size) ....)) (define charlie (new fish% [size 10])) > (send charlie grow 6) > (send charlie get-size) 16

Java-like Class System as “DSEL”

slide-18
SLIDE 18

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 HiPE) JVM C-code / VM- JIT

slide-19
SLIDE 19

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 HiPE) JVM C-code / VM- JIT distributed

Cloud Haskell

actors JoCaml actors!! no native, e.g., Akka

Termite / distrib.places 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) ++

++ +

+

+ + / +

meta programming

Template Haskell

macros (experiment.) MetaOCaml

simple macros lisp macros

macros /

  • adv. macros
slide-20
SLIDE 20

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, ...

slide-21
SLIDE 21

GPU

state machine planner vision driver GUI Simulink

slide-22
SLIDE 22

GPU

state machine planner vision driver GUI Simulink

slide-23
SLIDE 23

GPU

state machine planner vision driver GUI Simulink

slide-24
SLIDE 24

GPU

state machine planner vision driver GUI Simulink

GPU

slide-25
SLIDE 25

GPU

state machine planner vision driver GUI Simulink

slide-26
SLIDE 26

GPU

state machine planner vision driver GUI Simulink

slide-27
SLIDE 27
  • follows this radical “one language” philosophy
  • we chose the Scheme variant Racket as base language
  • only for hard realtime (controllers) and high performance (image processing,

GPU) we additionally need C/C++ and Matlab/Simulink models

  • aRDx allows seamless integration of C/C++ and Matlab/Simulink with

Racket up to module loading with auto-compilation

  • aRDx provides highly performant and hard realtime capable communication

layer for raw data transport for C/C++ -- setup of communication logic already in Racket application Racket OS aRDx

aRDx RT

C/C++

  • first prototype (many things still missing) successfully works on Agile Justin

The aRDx Framework (aRD Next Generation)

slide-28
SLIDE 28
  • T. Hammer, B. Bäuml, “Raw Performance of Robotic

Software Middleware: A Comparison and aRDx’s New Realtime Communication Layer”

Ê Ê Ê Ê Ê Ê Ê Ê Ù Ù Ù Ù Ù Ù Ù Ù Á Á Á Á Á Á Á Á ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ Ï Ï Ï Ï Ï Ï Ï Ï Ú Ú Ú Ú Ú Ú Ú Ú Ê aRDx Ù aRD Á Orocos ‡ ROS Ï ROS HfixedL Ú YARP 1 102 104 106 108 10-6 10-4 10-2 1 packet size @byteD round-trip time @sD

process

Ê Ê Ê Ê Ê Ê Ê Ê Ù Ù Ù Ù Ù Ù Ù Ù Á Á Á Á Á Á Á Á ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ Ú Ú Ú Ú Ú Ú Ú Ú

10-3 1 10-4 10-2 ‡

‡ ‡ ‡ ‡

*

pause @sD

1 102 104 106 108 10-6 10-4 10-2 1 packet size @byteD

host

Ê Ê Ê Ê Ê Ê Ê Ê Ù Ù Ù Ù Ù Ù Ù Ù Á Á Á Á Á Á Á Á ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ Ú Ú Ú Ú Ú Ú Ú Ú 1 102 104 106 108 10-4 10-3 10-2 10-1 1 10 packet size @byteD

distributed

Ê Ê Ê Ê Ê Ê Ê Ù Ù Ù Ù Ù Ù Ù Á Á Á Á Á Á ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ Ï Ï Ï Ï Ï Ï Ï Ï Ú Ú Ú Ú Ú Ú Ú 1 102 104 106 108 10-6 10-4 10-2 1 packet size @byteD round-trip time @sD

process

Ê Ê Ê Ê Ê Ê Ê Ù Ù Ù Ù Ù Ù Ù Á Á Á Á Á Á Á ‡ ‡ ‡ ‡ ‡ ‡ ‡ Ú Ú Ú Ú Ú Ú Ú Ú 1 102 104 106 108 10-6 10-4 10-2 1 packet size @byteD

host

Ê Ê Ê Ê Ê Ê Ê Ù Ù Ù Ù Ù Ù Ù Á Á Á Á Á Á Á ‡ ‡ ‡ ‡ ‡ ‡ ‡ Ú Ú Ú Ú Ú Ú Ú 1 102 104 106 108 10-4 10-3 10-2 10-1 1 10 packet size @byteD

distributed

slide-29
SLIDE 29

Conclusions

  • modern high level languages (beyond Python or Ruby) have much to offer
  • functional programming, advanced static type systems, performance, DSELs ...
  • allows radical new system architecture with One Language for (Almost) All
  • our new aRDx framework successfully follows this philosophy
  • many interesting candidate languages for robotics: Haskell, Scala, Erlang,

Clojure, Schemes (Gambit, Racket, ...), OCaml, ...

  • Tip:

Roboticists, go to language wonderland!

  • B. A. Tate. “Seven Languages in Seven Weeks”,

The Pragmatic Programmer, 2010.