From 3c5676df9fe580ef5d6a8c76d1457f02101c30a1 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Fri, 23 Nov 2018 16:26:47 -0800 Subject: Update talks page --- Makefile | 5 + talks.html | 17 - talks.md | 30 + talks/project-condor.html | 6638 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 6673 insertions(+), 17 deletions(-) delete mode 100644 talks.html create mode 100644 talks.md create mode 100644 talks/project-condor.html diff --git a/Makefile b/Makefile index b7a839d..d2aa903 100644 --- a/Makefile +++ b/Makefile @@ -57,4 +57,9 @@ $(target)/talks/scala-channels.html: talks/scala-channels.html @mkdir -p $(@D) cp $< $@ +$(target)/talks/project-condor.html: talks/project-condor.html + @mkdir -p $(@D) + cp $< $@ + + .PHONY: all clean publish diff --git a/talks.html b/talks.html deleted file mode 100644 index d7a7439..0000000 --- a/talks.html +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: Talks ---- - -### Channeling the Inner Complexity - -An essential requirement for writing programs that scale is to have -constructs to model concurrency in an understandable, safe, and -efficient manner. This talk presents an overview of various such -models available in Scala, and their impact on program structure and -complexity. It then explores a way to model concurrency with less -complexity with an implementation of Communicating Sequential -Processes (CSP), heavily inspired by goroutines, scala-async and -Clojure's core.async. - -[slides [pdf]](talks/scala-channels.pdf) [[html]](talks/scala-channels.html) -[project escale](https://github.com/jodersky/escale) diff --git a/talks.md b/talks.md new file mode 100644 index 0000000..d015352 --- /dev/null +++ b/talks.md @@ -0,0 +1,30 @@ +--- +title: Talks +--- + +### Channeling the Inner Complexity + +An essential requirement for writing programs that scale is to have +constructs to model concurrency in an understandable, safe, and +efficient manner. This talk presents an overview of various such +models available in Scala, and their impact on program structure and +complexity. It then explores a way to model concurrency with less +complexity with an implementation of Communicating Sequential +Processes (CSP), heavily inspired by goroutines, scala-async and +Clojure's core.async. + +[slides [pdf]](talks/scala-channels.pdf) [[html]](talks/scala-channels.html) +[project escale](https://github.com/jodersky/escale) + + +### Project Condor + +Building a DIY quadrotor. This talk gives an overview of all steps +necessary in building a drone from the ground up, with off-the-shelf +parts from the hardware store and hobby electronics. It describes the +evolution of Project Condor, presents its software architecture from +base station to on-board flight stack, and summarizes engineering +tradeoffs. + +[slides [html]](talks/project-condor.html) +[project website](https://project-condor.github.io) diff --git a/talks/project-condor.html b/talks/project-condor.html new file mode 100644 index 0000000..838f1bd --- /dev/null +++ b/talks/project-condor.html @@ -0,0 +1,6638 @@ + + + + + + Not Your Dad’s Scala: Flying Objects and Proactive Streams + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+

Not Your Dad’s Scala: Flying Objects and Proactive Streams

+
Jakob Odersky
+
+ @jodersky +
+

+

April 18, 2016

+

+
+ + +
+

Or,
Navigating a Drone with Scala

+
+
+

Initial Idea

+
    +
  • Build a quadrotor
  • +
  • From scratch +
      +
    • hardware
    • +
    • software
    • +
  • +
  • Control with a joystick, no remote
  • +
  • ⇒ Project Condor
  • +
+
+
+

Two Parts

+
    +
  1. The Quadrotor
  2. +
  3. The Base Station
  4. +
+
+
+

System Overview

+
+overview
overview
+
+
+
+

1. The Quadrotor

+
+

(the flying object)
No Scala Here

+

Move on to the Scala parts →

+

See backstory ↓

+
+
+

Frame

+
+Structure
Structure
+
+
+
+

Frame

+
+Unit
Unit
+
+
+
+

Electronics

+
+Trifle Board
Trifle Board
+
+
+
+

Flight Stack

+
    +
  • And then I found PX4, exactly what I was trying to build.
  • +
+
+
+

Alternative: PX4

+
    +
  • Open Source Software
  • +
  • Developed by Computer Vision and Geometry Group, ETHZ
  • +
  • Uses open, wide-spread protocol MAVLink
  • +
  • Runs on free RTOS NuttX, available for AVR, ARM and more.
  • +
+
+
+

Pixhawk Hardware

+
    +
  • Developed by the same group
  • +
  • Expensive
  • +
  • I already have a microcontroller and all sensors
  • +
+
+Pixhawk
Pixhawk
+
+
+
+

NuttX (beginning 2015)

+
    +
  • Our board uses the Teensy 3.1: +
      +
    • ARM Cortex M4
    • +
    • Freescale Kinetis K20 family
    • +
  • +
  • NuttX (beginning 2015) has support for K40 family
  • +
+
+
+

Let’s port it!

+
    +
  • Subtle differences in processor families, K20 != K40
  • +
  • I was never much involved with kernel development beforehand
  • +
  • Debugging microcontrollers is no fun +
      +
    • (without JTAG or other fancy equipment)
    • +
  • +
+
+
+

Fast-forward 2 months

+
+
+

Get the Pixhawk and move on

+
+
+
+

Quadrotor Take-Away:

+
    +
  • A lot of work has gone into existing hardware platforms
  • +
  • ⇒ Use existing Pixhawk controller
  • +
+
+Pixhawk
Pixhawk
+
+
+
+

2. The Base Station

+
    +
  • Control drone with joystick/gamepad
  • +
  • Display live flight information +
      +
    • “virtual cockpit”
    • +
  • +
  • Underlying process: (proactive) message streaming
  • +
+
+ + + + +
+

Mavigator

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Requirementadd ScalaArea
Modern, portable UIScala.jsfrontend
Web serverAkka Httpbackend
Message streamingAkka Streamsbackend
+
+
+

Live Demo

+
+

Alternatives

+ +
+
+
+

Frontend: Scala.js

+
    +
  • A JavaScript backend to the Scala compiler. +
      +
    • All the goodies from Scala: type safety, collections, etc
    • +
    • Outputs plain JavaScript
    • +
    • Can interface with plain JavaScript
    • +
  • +
  • Developed at EPFL by Sebastien Doeraene
  • +
  • Still in 0.x but totally usable!
  • +
+
+
+

Frontend: Design

+
    +
  • One-page applications
  • +
  • Static scaffolding with Twirl (Play! templates)
  • +
  • Common launcher for all applications
  • +
  • Extensible “cake” pattern: +
      +
    • Providing web page environment
    • +
    • Reading messages
    • +
    • Displaying instruments
    • +
    • Laying out elements
    • +
  • +
+
+
+

Backend: Akka Streams

+
    +
  • Compatible with Reactive Streams +
  • +
  • “Natural” Streaming API
  • +
+
+
+

Streams as Graphs

+
+overview
overview
+
+
+
+

Streams in Code

+

+
//Simple source
+val src: Source[Int, _] = Source.tick[Int](100millis, 100millis, 1)
+
+//Nested source
+val inc: Source[Int, _] = src.scan(0)(_+_)
+
+//A discrete flow
+val flow = Flow[Int].map(_*2)
+
+//Simple sink
+val sink = Sink.foreach(println)
+
+//Print all even numbers, ad infinitum
+(inc via flow to sink).run()
+
+
+
+

More Streams

+
    +
  • Arbitrary graphs
  • +
  • Feedback loops
  • +
  • Materialization
  • +
  • Much more…
  • +
+

http://akka.io

+
+
+

Backend: Conceptual Model

+
+Conceptual stream model
Conceptual stream model
+
+
+
+

Backend: Actual Model

+
+Actual stream model
Actual stream model
+
+
+
+

Serial Backend

+
Serial().watch(Set("/dev/ttyUSB0")).runForeach{ port =>
+
+  //replace backend on connection
+  val multiplexer: Flow[Bytes, Bytes, NotUsed] = setBackend()
+
+  //open actual connection to drone
+  val uav: Flow[Bytes, Bytes, NotUsed] =
+    Serial().open(port, serialSettings)
+
+  (uav join multiplexer).run()
+}
+ +
+
+

Web Sockets

+
path("/mavlink") {
+  get {
+    val fromWebSocket = Flow[Message].collect{
+      case BinaryMessage.Strict(data) => data
+    }
+
+    val toWebSocket = Flow[Bytes].map{bytes =>
+      BinaryMessage(bytes)
+    }
+
+    //request connection to multiplexer
+    val backend: Flow[Bytes, Bytes, NotUsed] = Uav().connect()
+
+    handleWebSocketMessages(fromWebSocket via backend via toWebSocket)
+  }
+}
+
    +
  • Akka Route DSL
  • +
  • Graph is run by Akka Http
  • +
+
+ +
+

Demo: Do a Barrel Roll

+
    +
  • Define “unstable” message
  • +
  • Add extra UI element to notify user
  • +
  • Inject attitude messages
  • +
+
+
+

Message

+

Add to dialect definition:

+
<message id="150" name="STABILITY">
+    <description>Stability issues</description>
+    <field type="uint8_t" name="stable">Is it stable?</field>
+</message>
+
+
+

New UI element

+
    +
  • Danger indicator
  • +
  • Illuminates on stability issues
  • +
+
+
+

Barrel Roll: Injection

+
+overview
overview
+
+
+
+

Live Demo

+
+

Alternatives

+
    +
  • git checkout demo1-before
  • +
  • git checkout demo1-after
  • +
+
+
+
+

References

+ +
+
+ + + + + + + + -- cgit v1.2.3