Communications

While pipeline-internal pub/sub is handled with custom communications protocols, it is often helpful for external tools (such as CLI, Qt applications, or web visualizers) to communicate with a pipeline.

You typically communicate with a pipeline via the “HTTP Server Stage”, which provides a websocket interface for subscribing to data, and an HTTP PUT interface for pushing messages to the pipeline.

Note that both the Qt and webviz systems provide a publisher/subscriber API that is identical to the pipeline publisher/subscriber API, for simplicity and future changes. It’s recommended you use those systems rather than connecting via websockets directly.

See the ark-spy and ark-put page for more details on using command line tools to interact with a pipeline.

That said, by using websockets, this also enables you to communicate with pipelines through other languages and ecosystems, without needing to link against anything in the Ark repository.

Here is an example of requesting JSON data and processing it from the Python CLI:

dtascione@desktop:~/ark$ python3
Python 3.5.2 (default, Oct  8 2019, 13:06:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import websocket
>>> ws = websocket.create_connection("ws://127.0.0.1:8080/gps_fix/json")
>>> message = ws.recv()
>>> print(message)
{
  "altitude": 358.5,
  "fix_time_utc_ns": 1604347081000000000,
  "latitude": 40.412682333333336,
  "longitude": -79.737793,
  "satellites_tracked": 12
}
>>>

The web server also allows queries for channels and other things, using curl:

dtascione@desktop:~/ark$ curl http://127.0.0.1:8080/publishers
/gps_fix
/logger/statistics
/realsense/color/image
/realsense/color/statistics
/realsense/depth/image
/realsense/depth/statistics
/realsense/imu/raw_imu_data
/realsense/imu/statistics

The architecture of the pipeline system is such that you can drop any number of communication modules into the pipeline. While we provide an HTTP Server Stage, it is possible to provide alternate stages, such as a shared memory or UDP transport system, depending on your exacty needs.