Skip to main content

Python client to communicate with FarSounder's ARGOS sensors

Project description

Python API Client for Argos data

Python client to communicate with SonaSoft via API.

[!NOTE] This is still under active development and testing. But may serve as an example for integration, beyond the lower level example in sdk repo. For now the docs are the interfaces and the examples in examples/

Usage

Clone locally and install (uv add .) or install from pypi like:

uv add farsounder

(or use pip, etc)

Then - for example to subscribe to TargetData messages:

import time

from farsounder import config, requests, subscriber
from farsounder.proto import nav_api_pb2


def main() -> None:

    # Build the configuration:
    # - where is the api running?
    # - what messages do you care about subscribing to?
    # - if ports are changed, they can overridden here
    cfg = config.build_config(
        host="127.0.0.1",
        subscribe=["TargetData"],
    )


    # Pub/Sub
    sub = subscriber.subscribe(cfg)
    # A callback to run when there are new target data messages
    # - don't do a lot of processing in here it will block (thank GIL - for now...)
    # - use sync mechanism if you're accessing shared data (callbacks
    #   run on thread pool [default] or on the receive thread for the message
    #   type)
    def on_targets(message: nav_api_pb2.TargetData) -> None:
        print("Got a TargetData!")
        print("Targets:", len(message.groups))

    # register the callback(s)
    sub.on("TargetData", on_targets)

    # start the receive loop
    sub.start()

    # Req/rep
    # for each of the request / reply endpoints - there are specific
    # get/set functions
    settings = requests.get_processor_settings(cfg)
    print(settings)

    history = requests.get_history_data(
        cfg,
        latitude=41.7223,
        longitude=-71.35,
        radius_meters=500,
    )
    print(history.gridded_bottom_detections)

    time.sleep(1.0)

    # Stop receive loop
    sub.stop()


if __name__ == "__main__":
    main()

Simulated backend

You can run a local simulated backend that publishes dummy messages and responds to request/reply calls:

uv run examples/simulated_backend.py

Note: the examples/ directory is not installed with uv add farsounder. Clone the repo to run the examples locally.

Development

Re-generate Protobuf stubs

Protobuf sources live in proto/. Generate Python stubs with:

uv run --group dev gen-protos

Or:

uv run tools/gen_protos.py

Tests

Run tests with:

uv run --group dev pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

farsounder-0.1.2.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

farsounder-0.1.2-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file farsounder-0.1.2.tar.gz.

File metadata

  • Download URL: farsounder-0.1.2.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for farsounder-0.1.2.tar.gz
Algorithm Hash digest
SHA256 09fa0e92e87bbd43566ecca18b91cf0227c5ed70b08d9be23abb6e20a9fe6aaf
MD5 e4f46b10c30c9d3c88a31ebd0e1d6b67
BLAKE2b-256 c12f5a1658ee898674625a8e473b27090f4a6f87526118d90645a1832ac6ba61

See more details on using hashes here.

File details

Details for the file farsounder-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: farsounder-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for farsounder-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 762cbaf5c5c91068404bfb979a88225c7835747a4ae03ab5113466d6f1a990f2
MD5 e5b2d36d9e0d426688cb63ba903ddbcd
BLAKE2b-256 9f92e1c096df153b4c1b81e88c29b9179f79fa71113ecab37a1717f44b8af9b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page