aiboにおけるROSの利用とソニーの取り組み
ソニー株式会社
R&Dセンター
藤田智哉

R&D Center System Technology Development Division Base System Development Department
Copyright 2018 Sony Corporation

Agenda• 背景• ROS エンベデッド最適化例• Unix Domain Socket• Direct I/O• EPOLL• Polling Frequency• ROS2に向けて• ソニー ロボティクスソフトウェア

2

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

背景

• ROS

• 組み込み課題• オープンソース• リアルタイム• 豊富なパッケージ• リソース消費• シミュレーション／デバッグツール• ビルドツール• メッセージ通信• デバイスドライバ

組み込み製品にROSを搭載するために行った最適化や施策を紹介

3

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

ROSエンベデッド最適化事例

4

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

ROS Transport Overview
 ROS Concept

XMLRPC:
configuration information
TCPROS/UDPROS:
data payload such as topic and services.

• TCPROS(TCP/IP) and UDPROS(UDP/IP).
• IP is world wide experience via ether.

Computation Robot

Laptoprosmaster
XMLRPCXMLRPC

Image
Process

XMLRPCTCPROS/UDPROS

CameraNode

Display
NodeXMLRPC
5R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

ROS Transport Overview
 Whatʼs the problem?

 Countermeasure Preconditions• CPU resource stress• No change required for applications.

• Software overhead for IP protocol.

• Good affinity with TCP/UDP

Computation Robot• small latency and high throughput.
Laptoprosmaster

XMLRPCXMLRPCXMLRPC

Extend UDSROS layer with TCPROS/UDPROS,
but nothing else will be changed.
Our ScopeImage
Process

TCPROS/UDPROS

CameraNodeDisplay
Node

XMLRPC
6R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

Expected Improvement as System
 Source Code• https://github.com/tomoyafujita/ipc-bench Environment• skylake(amd64) / hikey(arm64)• CPU frequency governor is “performance”• 100byte data payload / 10000 test loop average Performance Improvement for System
CategoryHikeyLatency

UDS(STREAM)

1.82 us[usec]UDS(DGRAM)

2.14 us19.9 us

TCP/IP

3.14 us87.7 us

UDP/IP

2.78 us67.2 usUDS(STREAM)

1.95 Gbps

UDS(DGRAM)

1.98 Gbps

92 Mbps

TCP/IP

0.43 Gbps

12 MbpsThrough-Put

7

SkylakeR&D Center

Copyright 2018 Sony Corporation

x1.7 ↓x4 ↑44.4 us127 Mbpsx2 ↓x10 ↑ROSCon JP 2018

Extended Transport Overview
topic/service

ROS node

Software Stack

Hardware Stack

System-A(OS instance)

System-B(OS instance)rosmasterNode(py)Node(cpp)
Node(py)Node(cpp)

roscppNode(py)Node(cpp)rospy

Node(py)Node(cpp)

roscpprospy

System Internal

UDSROS

System Internal

TCPROS/UDPROS

Network8System External
R&D Center

Copyright 2018 Sony Corporation

UDSROSTCPROS/UDPROS
System Boundary Aware, so itʼs automatically whichconnection should be used.

ROSCon JP 2018

Improvement Result
 HelloWorld Benchmark• Publisher:Subscriber=1:1• Synchronous test loop using shared memory.
• Latency is the time window between publish and callback entrance.
• Environment: amd64(skylake) and arm64(hikey)

 Result Comparison
Platform
Skylake
Hikey

9ROS
Transport

Duration [nsec]
minmaxaverage

TCP/IP

46,582

287,173

70,393

UDS

42,877286,130

64,796

TCP/IP

552,224

6,040,312

1,145,881

UDS

435,833

10,075,833

872,981

R&D Center

Copyright 2018 Sony Corporation

8% ↓

24% ↓

ROSCon JP 2018

Source Code

Github URL<will be released soon>
Maintainer
Tomoya, Fujita <Tomoya.Fujita@sony.com>
Xu, Barry <Barry.Xu@sony.com>

10R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

Direct I/O with rosbag
 Reference https://github.com/osrf/rosbag̲direct̲write

Process
page

Process

page

page

page
Data in userland will be stored
directly to the storage device
without CPU workload.

Page Cache(*) memory alignment constraints

File System
inodeinodeBlock I/O

11R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

Epoll What is the problem?
• The more ROS topic connection, the more CPU stress with ros::spin()• Waiting for the stimulus during ros::spin without any message transmission.

• Poll system call is not good enough to take care of many file descriptors.

 Countermeasure• Using epoll instead, to reduce CPU stress.
• Already introduces as following commit, so backport the fix into 1.12.7 ros̲comm.
commit 9c0db37d9231003a7f162857e4aeb45675839609
Author: Mike Purvis <mike@uwmike.com>
Date: Thu Dec 21 11:31:08 2017 -0500
Topic subscription scalability fix (#1217)
Switching to using epoll system calls to improve performance of the topic polling code by a factor of 2.
This required disabling the addDelMultiThread test.

12R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

Polling Frequency
 ROS Threads
Thread Name

Use

Main

Main thread

PollManager

Publish/Subscribe I/O Polling

XMLRPCManager

Talk to rosmaster for connectivity map and services

ROSOutAppender

Logging

internalCallbackQueue

Connection drop, data store etc…

Polling Frequency Tunable for each processes, less CPU stress. (default freq is 100msec)

No Logging thread, less CPU stress. (instead of that, using own log system)

13

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

ROS2

14

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

ROS2 RMW with Own Implementation
ROS2 Application
can be switched the RMW
implementation with environmental
variable.

Own RMW

Own
Implementation

https://roscon.ros.org/2016/presentations/ROSCon%202016%20-%20ROS%202%20Update.pdf
15

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

ソニー ロボティクスソフトウェア

16

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

Architecture Overview
知的処理周辺環境と背景として持つ知識から、目的を決定する
目的行動

行動計画

状況理解
認識結果を使い、周辺環境を解釈する。事前の環境知識も持ちうる

認識

自律行動

反射行動

周辺環境と自身の意図する目的から、なすべき行動を計画する

行動制御
計画された行動に基づき機体を制御する

センサを使い、外界や自身の状態を検出する

機体
外界
17

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

Componential Overview

18

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

Letʼs make a difference with Sony

19

R&D Center

Copyright 2018 Sony Corporation

ROSCon JP 2018

SONYはソニー株式会社の登録商標または商標です。
各ソニー製品の商品名・サービス名はソニー株式会社またはグループ各社の登録商標または商標です。その他の製品および会社名は、各社の商号、登録商標または商標です。