[Question] About the usage of shared memory in docker
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- ドキュメント
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- docker, python
調査の方向性
まず、リンクされている CycloneDDS の共有メモリの制限に関するページ、CYCLONEDDS_URI XML 設定、および inline の publisher と subscriber のエントリポイントを確認します。示されている network、IPC、volume オプションを使ってコンテナを実行し、その後、文書化されている診断情報と共有メモリの状態を調べます。ドキュメントは、トランスポートの検証方法と、プロセスが ipcs -m に表示されるべきかどうかを説明できた時点で完成です。
索引モデルが issue の本文から書いたものです。
説明
Hi,
I'm trying to setup environment and other thins to be able to transfer messages using shared memory. First of all, here is my Image class:
Image class
@dataclass
class MainCameraImage(IdlStruct):
img: array[uint8, 4147200]
shape: array[uint64, 3]
@classmethod
def from_numpy(cls, img):
assert len(img.shape) == 3
seq_img = img.tobytes()
return MainCameraImage(seq_img, tuple(img.shape))
def to_numpy(self):
shape = self.shape
return np.frombuffer(self.img, dtype=np.uint8).reshape(shape)
Note that image array has a fixed size. Then I implement publisher and subscriber:
Publisher
import cv2
import time
import numpy as np
import fire
from cyclonedds.core import Listener, Qos, Policy
from cyclonedds.util import duration
from cyclonedds.internal import dds_infinity
from cyclonedds.domain import DomainParticipant
from cyclonedds.topic import Topic
from cyclonedds.pub import DataWriter
from dds_data_structures import MainCameraImage, Image, CameraState,DeviceState
def stream(dev=0, resize_to=None, output_topic_names=['camera_images', 'camera_images_vis', 'camera_images_clr'],
data_type='MainCameraImage', cap_gstreamer=True):
data_type = MainCameraImage
participant = DomainParticipant(0)
writers = []
# unknown, disabled, enabled, error
qos = Qos(
# livelines: automatic
# deadline: dds_infinity
# reliability: reliable
# durability: volatile
# history: keep last
Policy.Liveliness.Automatic(lease_duration=duration(seconds=10)),
Policy.Deadline(deadline=dds_infinity),
Policy.Reliability.Reliable(max_blocking_time=duration(seconds=1)),
Policy.Durability.Volatile,
Policy.History.KeepLast(1)
)
for topic_name in output_topic_names:
topic_out = Topic(participant, topic_name, data_type)
writers.append(DataWriter(participant, topic_out, qos))
frame = np.random.randint(0, 256, (1280, 1080, 3), dtype=np.uint8)
print(frame.shape, frame.dtype)
while True:
time_start = time.time()
ret, frame = 1, frame
if not ret:
print('Error: Unable to read frame')
break
if resize_to is not None:
frame = cv2.resize(frame, resize_to[::-1])
for writer in writers:
writer.write(data_type.from_numpy(frame))
loop_time = time.time() - time_start
print(f'Streaming Camera with topic {output_topic_names[0]}, {loop_time=}', end='\r')
if __name__ == '__main__':
fire.Fire(stream)
Subscriber
import cv2
import time
import numpy as np
import fire
from cyclonedds.core import Listener, Qos, Policy
from cyclonedds.util import duration
from cyclonedds.internal import dds_infinity
from cyclonedds.domain import DomainParticipant
from cyclonedds.topic import Topic
from cyclonedds.sub import DataReader
from dds_data_structures import MainCameraImage
def receive(topic_name='camera_images'):
data_type = MainCameraImage
participant = DomainParticipant(0)
qos = Qos(
# livelines: automatic
# deadline: dds_infinity
# reliability: reliable
# durability: volatile
# history: keep last
Policy.Liveliness.Automatic(lease_duration=duration(seconds=10)),
Policy.Deadline(deadline=dds_infinity),
Policy.Reliability.Reliable(max_blocking_time=duration(seconds=1)),
Policy.Durability.Volatile,
Policy.History.KeepLast(1)
)
topic_in = Topic(participant, topic_name, data_type)
reader = DataReader(participant, topic_in, qos)
while True:
time_start = time.time()
img = reader.read()
if len(img) == 0:
continue
img = img[0].to_numpy()
loop_time = time.time() - time_start
print(f'Received img {img.shape=}, {loop_time=}', end='\r')
if __name__ == '__main__':
fire.Fire(receive)
I've checked the requirements to the QoS for both publisher and subscriber here (as far as I can see they should be identical).
Next step I'm running iceoryx roudi in one docker container with --net=host --ipc=host -v /dev:/dev -v /tmp:/tmp. I also set the environment variable CYCLONEDDS_URI to the config file. I'm using default config file:
CYclonedds uri config
<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
<Domain Id="any">
<General>
<Interfaces>
<NetworkInterface autodetermine="true" priority="default" multicast="default" />
</Interfaces>
<AllowMulticast>default</AllowMulticast>
</General>
<SharedMemory>
<Enable>true</Enable>
<LogLevel>info</LogLevel>
</SharedMemory>
</Domain>
</CycloneDDS>
Finally I run above scripts in the docker containers with the same net and ipc options. They work fine and subscriber receives messages from publisher. What I'm trying to understand:
- How to make sure that messages are being sent via shared memory?
ipcs -mshows only firefox and vs code processes (I've checked pids via `ps -p ). Should my subscriber and publisher be there if everything works as expected?
- 主要言語
- Python
- スター
- 110
- フォーク
- 68
- 平均マージ
- 3日 5時間
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
eclipse-cyclonedds/cyclonedds-python のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
-
Generated Python code is not interoperable when a union contains a member called "value"再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
eclipse-cyclonedds/cyclonedds-python#333 · コメント 1 件 ·
eclipse-cyclonedds/cyclonedds-python の issue をすべて見る
似ている issue
-
Pull-through from gcr.io returns 500 when pulling using podman/buildah対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンIssue Triage-Needed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
pulp/pulp_container#2581 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
521xueweihan/HelloGitHub#4040 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
ClanGenOfficial/clangen#6313 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
bug(trainer): CustomTrainer func_args with non literal values fail inside the TrainJob対応中かも @avanishkasar が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信