Node.js* Client & Web Bridge Readyfor ROS* 2.0Minggang Wang
September 30 2018

Agenda
●
●
●
●
●
●
●
●
●
●Who We Are
Why Use Node.js & Web in Robotics
Thinking in “ROS 2.0 + Web”
What We Have Done for “ROS 2.0 + Web”
The Design of rclnodejs & ros2-web-bridge
List of Features
Performance Comparison: Node.js, C++ & Python
Video DemoIntel Robot
Contacts & Resource Links
2

Who we are●●Intel Open Source Technology Center (OTC) is home to the core of Intel's
open source development efforts.
We’re from OTC Web Team; we do web technology in client, edge, cloud, IoT, W3C
standard, Robotics & etc., to keep web open, secure, rich-featured and performant.

Robotics + Web
Figure: What Intel OTC does3

Why Use Node.js & Web in Robotics●●●●

High-performance (JIT), faster than Python○ Do more on same robot control board
Strong ecosystem/community○ The most popular language on Github*○ Largest package system in the world
Easy deployment & debugging
Naturally for web interface

Benchmark Link

NPM* is the largest package system in the world (>600k)
4

Thinking in “ROS 2.0 + Web”●Web is best choice for remote control & dashboard○○●e.g. status inspection, supervised motion control, posturevisualization, video streaming & etc.
Available anywhere, easy to embed, tons of resources & etc.

How to bring ROS into the web?
○○○●A Web Appe.g. Remote Control / Dashboard

RWT* can bring ROS 1.0 APIs into a web browser
Nothing for ROS 2.0 back in Mid’17, so we did one
But is it the best way to expose all ROS API in web? e.g. service?

WebROS

Another approach: Node.js web server, is flexible & effective○○○

ROS API exposed in server; only business logic in web - RaaS
Don’t be scared, web server is just a few lines in Node.jsSame skill set for both frontend & backend, easy debugging

ROS + Web = Better Robot... But How?
5

What We Have Done for “ROS 2.0 + Web”
2 packages. Both hosted in GitHub RWT thanks to Jihoon● rclnodejs (github repo)
It’s a Node.js client of ROS 2.0. It provides fast, easy& powerful JavaScript API of ROS 2.0●Web AppIn this approach, ROS API isonly in server, not in browser

ros2-web-bridge

Node.js App

Py/C++ App

ros2-web-bridge (github repo)
Make it possible to call ROS 2.0 API in a web page. It’s
compatible with roslibjs*

rclnodejs

rclpy/c++rcl Interface
ROS 2.0 Core & DDS
We’ve done the green and orange, and made thepurples possible

6

The Design of rclnodejs (the ROS 2.0 Node.js API)
Principles and philosophy
●
●
●
●
●

LegendA thin wrapper to rcl -- same mindset, fast & easier to adapt change

ROS 2

Event-driven, non-blocking (promise/event) -- advantage of async IO, very simple & efficientAble to use new ROS message without recompiling -- everything’s on the fly
User-friendly debugging -- easy to figure out what’s wrong
User Application
Embrace ES6* -- most recent cool features of JavaScript language

As a result, user can write
ROS app easily & effectively.

ros nodeclient

servicepublisher subscription

messagegenerator

rclnodejs

Main Thread Worker Thread

Node.jsEventLoopbi-directional
notifications

rosidlrcl handles
JavaScript
C/C++
JS binding

rcl interface to ROS 2.0

query events
background
executor7

ros2-web-bridge Design (Bring ROS in Browser)
Principles and philosophy●●●Meet user’s expectation, be compatible with ROS 1.0 bridge (rosbridge_suite)○ Protocol compatible with the existing protocol of JSON messages (ROS 1.0)
○ Existing Web Tools can be directly used, e.g. 2D/3D visualization
Keep it fast and simple -- speed is the king; simplicity means easy to maintainros2-web-bridge
User-friendly debugging -- debugging is always important to developers
ROSInterface

As a result, RWT ROS 1.0components are transparently
compatible with ROS 2.0

WebInterface
JSON message
via WebSocket

ROS Message

rclpy/C++

rclnodejs

ros2djsroslibjs

Other lib

rcl interface to ROS 2.0
ROSROSros3djs

WebBrowser
8

List of Features
rclnodejs

ros2-web-bridge

●
●
●
●
●
●
●

●
●
●

ROS node -- create/destroy ROS nodes
Publisher/Subscription -- send/receive ROS message
Client/Service -- write client/service of ROS request
QoS support -- configure network QoS policy
Timer -- periodical notification/callback
Time/Time Source -- different type of clocks
Actionlib w/ RethinkRobotics* -- preemptable task

Publisher/Subscription -- send/receive msg in browser
Client/Service -- write client/service of ROS request in browser
Status message support -- figure out what’s going onmanagement●●●Message Gen (idl) -- dynamic generation on the fly
Validation utilities -- check if it meets rules
Logging -- easier debugging
9Performance Comparison: Node.js, C++ & Python
Test case: to publish a ROS message, measure the time and memory consumption● When runcount increases, the trends tend to stabilize● Same trends were also observed on other types of tests● Both trends match the common sense

Conclusion: Node.js is times fasterthan Python, but consumes morememory in runtime.
* Don’t forget to run Python with -O

i5-4250 Haswell/4G RAM/Ubuntu 16.04

10

Video Demo (URL)●

Turtlebot* 3 + ROS 2.0○○●

Intel® RealSense™ Depth Camera D415
A compact camera designed to bring depth sensing to more devices:●
Depth FOV: 69.4x42.5x77●
Active IR stereo rolling shutter●Up to 90 FPS RGB●Range 0.3-10M+●
Includes ROS 2.0 Wrapper
For more info, please visit https://realsense.intel.com

Intel® RealSense™ camera
Up Board* with Intel Atom®

A web app as remote control○○○

roslibjs + ros2-web-bridge
Easy to build powerful UI
Running everywhere●Source code: github●

ROS 2.0 Message Type:geometry_msgs/msg/Twist

11

Intel●AI/ML/CV Software for ROS 2.0○○○●

A ROS service/publisher for object classification and detection
Support multiple CNN models of Caffe* and Tensorflow*

Up to 10 meter range, up to 90 fps
Realtime 1080p RGB video + 720p depth video
Integrated publisher to ROS 2.0, visualized by ROS rviz*

Better Manipulation with Better ROS MoveIt*○○●SAWR = Simple Autonomous Wheeled Robot

RealSenseTM depth camera: perceive the world in 3D
○
○
○

●

Object detection/segmentation/tracking/velocity estimation & etc.
A ROS service to support Intel® OpenVINO™ - the Open VisualInference & Neural Network Optimization Toolkit.
A bridge to connect ROS 2.0 & OpenCV*.

MovidiusTM NCS: dedicated AI hardware by Intel®
○○●Robot (Intel’s Contribution to Robotics)

Intel® SAWR robot, both software & hardware areopensource. Simple, inexpensive, built on
desktop Ubuntu + ROS, for teaching & learning.
●Opensource chassis or Turtlebot 3●SLAM capability●
Intel(R) RealSenseTM depth camera

Hand-eye calibration
Grasp planner (with accelerated grasp detection)

Redesign of ROS 2.0 Navigation
12

Code Example: Publisher/Subscription
Create a ROS NodeCreate a Publisher

Publish a String Message

1. Publisher Example
Create a Subscription

The Callback Function
2. Subscription Example
13

Code Example: Service/Client
Create a Service

Create a Client3. Service Example
Get Requested Data
Send a Service Request& Get the Result
Send Result to Client
4. Client Example
14

Code Example: ROS in Web Browser
A New roslibjs InstanceDefine a Twist Message

Create a Publisher in Browser

Publish the Twist Message.
This message will be sent toROS 2.0 via ros2-web-bridge.

5. ROS in Web Browser Example

15

Contacts & Resource Links
Contacts: Minggang Wang

The developer/QA teamemail:●Minggang Wang

●Kenny Yuan

●Wanming Lin●Yi Han●Zhong Qiu

Useful links:●rclnodejs: github, npm●ros2-web-bridge: github, npm●Intel ROS 2.0 projects: wiki (also 1.0)

●Robot Web Tools: libs/widgets/systems/etc.

●

rosnodejs by RethinkRobotics* for ROS 1.0
16

Questions...

17

Legal Notices and Disclaimers•Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration.
No computer system can be absolutely secure. Check with your system manufacturer or retailer or learn more at intel.com.
•Tests document performance of components on a particular test, in specific systems. Differences in hardware, software, or configuration will affect actual performance. Consult other sources of
information to evaluate performance as you consider your purchase. For more complete information about performance and benchmark results, visit http://www.intel.com/performance.
•Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured
using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information andperformance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. For more complete information visit
http://www.intel.com/performance.
•Cost reduction scenarios described are intended as examples of how a given Intel-based product, in the specified circumstances and configurations, may affect future costs and provide costsavings. Circumstances will vary. Intel does not guarantee any costs or cost reduction.
•This document contains information on products, services and/or processes in development. All information provided here is subject to change without notice. Contact your Intel representative toobtain the latest forecast, schedule, specifications and roadmaps.
•No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document.
•Statements in this document that refer to Intel’s plans and expectations for the quarter, the year, and the future, are forward-looking statements that involve a number of risks and uncertainties. A
detailed discussion of the factors that could affect Intel’s results and plans is included in Intel’s SEC filings, including the annual report on Form 10-K.
•All products, computer systems, dates and figures specified are preliminary based on current expectations, and are subject to change without notice. The products described may contain design
defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.
•Intel does not control or audit third-party benchmark data or the web sites referenced in this document. You should visit the referenced web site and confirm whether referenced data are accurate.
•© 2016 Intel Corporation. Intel, the Intel logo, RealSense, Atom and others are trademarks of Intel Corporation in the U.S. and/or other countries.
•*Other names and brands may be claimed as the property of others.

19