Skip to content

PyAER Communication Module

Yuhuang Hu edited this page Jan 4, 2021 · 13 revisions

A Long-awaited Feature

PyAER has been a simple interface to DAVIS Camera. It's better than pure libcaer, but less complicated than full-featured frameworks such as DV and ROS. What is missing from day-one is a communication module that can manage the activities between devices. This feature has been considered for a long time and now it's here!

Support from 0.2.0

What is this? and what for?

It's a ROS-like communication module that implements similar features such as roscore, publisher, subscriber, roslaunch, rostopic, and rosbag. It's implemented by using zeromq's XPUB and XSUB. Specifically, I implemented Figure 13 in this chapter.

In one sentence, this module is a 42 KB "ROS". Imagine you want to simultaneously record and display outputs from a DAVIS camera. You can first run a publisher to broadcast all the polarity events, frame events, and IMU events. Then one subscriber can record the data while another subscriber display outputs.

Thanks to the powerful zeromq socket, you can construct a much more complex network than I just described.

Quick Start

Example 1: Record DAVIS Output

# Define an AER Hub, the launcher will start a default hub if you don't specify one.
"Hub":
    "use_default": true

# start a saver, it will save all topics.
"Saver-hdf5":
    "url": "tcp://127.0.0.1"
    "port": 5099
    "topic": ""
    "name": "aer_saver"
    "filename": "~/pyaer_test.hdf5"
    "mode": "w"
    "hdf5": true
    "libver": "earliest"

# start a DAVIS publisher, this publisher will publish all output types
"Publisher-davis":
    "use_default": true
    "url": "tcp://127.0.0.1"
    "port": 5100
    "master_topic": "davis_1"
    "name": "davis_publisher"
    "device": "DAVIS"
    "noise_filter": true
    "bias_file": "../configs/davis346_config.json"
    "use_default_pub": true

To run this configuration, use AER Launcher:

aer_launch --launch_file ./example_recorder.yml

Why?

Why not multiprocess?

Python sucks at threading and multi-processing. This is a known fact. The learning curve is too steep, the features are not as desired, there are locks, and I can go on. Most of all, I have never successfully written a multi-processing project in Python without making my code unreadable.

Another fact is there are many attempts and projects trying to improve multi-processing in Python because of the need for readability and scalability. I didn't go for those solutions because most of them aim for a super-computing scenario.

Finally, I decided to implement a ROS-like communication module that creates a network among agents. But you may wonder "why wouldn't you use ROS instead?". And the answer is "it's too heavy for prototyping scenario". If you don't know ROS, you may spend a week or so to understand its rationale. And, even then you probably still quite confused about.. well, everything.

This is why I coded pyaer.comm, a small module (42 KB) which you can basically deploy almost everywhere (Raspberry Pi, Edge TPU, Desktop, Laptop, whatever with a decent *nix based OS.

More importantly, this module does not limit the use of pyaer, you can basically use it like a mini-ROS and your life becomes brighter.

Why YAML?

As a good configuration file, I need the following features:

  • Hierarchy
  • Comments

And the only two viable solutions are:

  • XML
  • YAML

XML is used by ROS and it's too complicated. Therefore I use YAML. JSON was my top choice, however, it doesn't support comments.

What's missing?

  • Will try to use configparse module.

  • I haven't properly benchmarked the performance or dealt with loss packets. (Hopefully, there is not).

  • I haven't address the late-arrived subscriber issue. Therefore, please start subscribers before publishers.

  • Make some proper applications, for example, stereo setup, proper reactive robotics with DNN.

Clone this wiki locally