Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reactive Programming for Robot Applications

Reactive Programming for Robot Applications

Mike Chung

March 27, 2019
Tweet

More Decks by Mike Chung

Other Decks in Programming

Transcript

  1. 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 
  2. 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 
  3. 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 
  4. 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 
  5. 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 
  6. 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 
  7. 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 
  8. 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 
  9. 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 
  10. 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 
  11. 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   