Slide 1

Slide 1 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 1/21 REACTIVE PROGRAMMING FOR REACTIVE PROGRAMMING FOR ROBOT APPLICATIONS ROBOT APPLICATIONS MICHAEL JAE-YOON CHUNG MICHAEL JAE-YOON CHUNG ROS SEATTLE MEETUP, 2019/03/27 ROS SEATTLE MEETUP, 2019/03/27 1 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 2

Slide 2 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 2/21 2 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 3

Slide 3 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 3/21 3 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 4

Slide 4 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 4/21 4 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 5

Slide 5 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 5/21 CHALLENGES CHALLENGES Uncertainty 5 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 6

Slide 6 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 6/21 CHALLENGES CHALLENGES Uncertainty Temporailty 5 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 7

Slide 7 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 7/21 CHALLENGES CHALLENGES Uncertainty Temporailty Concurrency 5 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 8

Slide 8 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 8/21 CHALLENGES CHALLENGES Uncertainty Temporailty Concurrency 6 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 9

Slide 9 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 9/21 CHALLENGES CHALLENGES Uncertainty Temporailty Concurrency 6 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 10

Slide 10 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 10/21 CYCLE.JS + ROS CYCLE.JS + ROS 7 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 11

Slide 11 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 11/21 WHAT IS WHAT IS ? ? framework in JavaScript abstraction that separates producing code from the main business logic code so the main code remains and predictable. CYCLE.JS CYCLE.JS functional and reactive programming side-effect pure 8 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 12

Slide 12 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 12/21 9 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 13

Slide 13 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 13/21 New specifications: notify the server on certain events coordinate text-to-speech and base- movement 10 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 14

Slide 14 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 14/21 11 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 15

Slide 15 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 15/21 sinks = main(sources) sources = Drivers(sinks) 11 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 16

Slide 16 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 16/21 ROS APIS AS CYCLE.JS DRIVERS ROS APIS AS CYCLE.JS DRIVERS See github repo for details. {subTopics} = ROSTopicDriver({pubTopics}); {resps} = ROSServiceDriver({reqs}); {latestVals} = ROSParamDriver({newVals}); cycle-ros-example 12 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 17

Slide 17 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 17/21  proactiveGreetingsApp.js  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 import xs from 'xstream'; ... function main(sources) { var actionGoals$ = sources.ROSTopic['/leg_tracker_measurements'] .map(function(data) { ... }) // transform data to distance .filter(function(dist) { ... }) // discard out-of-range .map(function(filteredDist) { if (filteredDist < 0.5) { return { id: Date.now(), say: 'How can I help you?', shimmy: true, } } else { return { id: Date.now(), say: 'Hi', shimmy: false, } } }); var notifyGoal$ = xs.combine( // i.e., wait for two action results sources.ROSTopic['/say/result'], sources.ROSTopic['/shimmy/result'], ).filter(function([sayResult, shimmyResult]) { // true if action ids are matching, i.e., both actions are done }) Edit on StackBlitz ros-seattle-meetup-20190328 Editor Preview Both 13 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 18

Slide 18 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 18/21 Check out github repo for more drivers and example applications!  index.js  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import xs from 'xstream'; import {div, makeDOMDriver} from '@cycle/dom'; import {run} from '@cycle/run'; import {makePoseDetectionDriver} from 'cycle-posenet-driver'; import {makeTabletFaceDriver} from '@cycle-robot-drivers/screen'; import {makeSpeechSynthesisDriver} from '@cycle-robot-drivers/speech'; function main(sources) { var vdom$ = xs.combine( sources.TabletFace.DOM, sources.PoseDetection.DOM ).map(function (vdoms) { return div(vdoms); }); var face$ = sources.PoseDetection.poses .filter( function(poses) { Console     https://ros‑seattle‑meetup‑2019…  Edit on StackBlitz ros-seattle-meetup-20190328 Editor Preview Both cycle-robot-drivers 14 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 19

Slide 19 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 19/21 RELATED WORK RELATED WORK Functional Reactive Animation - ICFP97 Yampa - 2002 "Reactive ROS" topic in ROS discourse Playful 15 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 20

Slide 20 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 20/21 CONCLUSION CONCLUSION Cycle.js + ROS as a reactive programming solution for robot applications The and the side- effect separation (i.e., ) can be applied without Cycle.js Hope to see the ROS users adapting the patterns in python or cpp via or functional reactive programming ports and adapters pattern RxPY RxCpp 16 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung 

Slide 21

Slide 21 text

3/25/2019 title localhost:54721/?print-pdf-now#/ 21/21 MORE READING MORE READING Programming a social robot using Cycle.js Implementing a finite state machine in Cycle.js 17 Reactive Programming for Robot Applications - Michael Jae-Yoon Chung   