bdsim-realtime


Namebdsim-realtime JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/CallumJHays/bdsim_realtime
SummaryReal-time execution and remote monitoring and tuning of BDSim Block-Diagrams for modelling and control of Dynamical Systems
upload_time2023-02-05 04:12:37
maintainer
docs_urlNone
authorCallum Hays
requires_python>=3.6
licenseMIT
keywords python bdsim realtime control remote-control telemetry tuning-interface webapplication tuner signal-analysis control-system block-diagram computation-graph data-flow control-flow rtos simulation modeling computer-vision opencv
VCS
bugtrack_url
requirements msgpack sanic
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BDSim Realtime

Real-time execution and remote monitoring and tuning of BDSim Block-Diagrams for modelling and control of Dynamical Systems.
See https://github.com/petercorke/bdsim for the base framework and simulation package.

TODO: more docs

## BDSim Web-Tuner

Web-based telemetry and parameter tuning interface for BDSim

![Demo](./demo.gif)

Note: Screen-recording lead to low FPS - usual FPS was around 30 on the laptop used (max for webcam).

Note: under heavy development (pre-alpha). These instructions will not fully work at the time of writing, but is supposed to give an idea of the usage once released.

## Installation

```bash
pip install "bdsim_realtime[opencv]" # opencv optional
```


## Usage

First, start the server and keep it running:

```bash
python -m bdsim_realtime.webapp
```

Then, add and run your bdsim script, 

```python
import bdsim, numpy as np
import bdsim_realtime

# setup block-diagram and tuner client
bd = bdsim.BDSim(packages="bdsim_realtime").blockdiagram()

# All TunableBlocks within this context manager will register their parameters swith the Tuner
with bdsim_realtime.tuning.tuners.TcpClientTuner() as tuner:
    # use first local camera available
    clock = bd.clock(24, unit='Hz')
    bgr = bd.CAMERA(0, clock=clock)

    # display in web stream
    bd.DISPLAY(bgr, name="BGR Stream", web_stream_host=tuner, show_fps=True)

    # tune system parameters in the web editor
    gain = tuner.param(1, min=0, max=100)

    # stream some telemetry data (random for demo)
    data = bd.FUNCTION(
        lambda _: (gain.val * np.random.rand(3)).tolist(),
        nin=1, # unused import required here to use function as a Clocked Source Block
        nout=3
    )
    bd.connect(bgr, data)

    bd.TUNERSCOPE(
        data[0], data[1], data[2],
        nin=3,
        labels=['x', 'y', 'z'],
        name='Random Data',
        tuner=tuner)

bd.compile() # perform verification
bdsim_realtime.run(bd, tuner=tuner) # run forever
```

Now access the tuner at [http://localhost:8080](http://localhost:8080)


## Development

### Setup


```bash
python -m venv .venv # create venv
source .venv/bin/activate # activate venv

pip install -e ".[opencv]" # install in editable symlink mode
npm i # install JS deps
```

#### Frontend

```
npm run dev # run hot-reloaded app
```

#### Backend

Same as non-development version. Run:

```
python -m bdsim_realtime.webapp
```

And then run your example / test script:

```
python examples/blob_detector_tuner.py
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/CallumJHays/bdsim_realtime",
    "name": "bdsim-realtime",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python bdsim realtime control remote-control telemetry tuning-interface webapplication tuner signal-analysis control-system block-diagram computation-graph data-flow control-flow rtos simulation modeling computer-vision opencv",
    "author": "Callum Hays",
    "author_email": "callumjhays@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "# BDSim Realtime\n\nReal-time execution and remote monitoring and tuning of BDSim Block-Diagrams for modelling and control of Dynamical Systems.\nSee https://github.com/petercorke/bdsim for the base framework and simulation package.\n\nTODO: more docs\n\n## BDSim Web-Tuner\n\nWeb-based telemetry and parameter tuning interface for BDSim\n\n![Demo](./demo.gif)\n\nNote: Screen-recording lead to low FPS - usual FPS was around 30 on the laptop used (max for webcam).\n\nNote: under heavy development (pre-alpha). These instructions will not fully work at the time of writing, but is supposed to give an idea of the usage once released.\n\n## Installation\n\n```bash\npip install \"bdsim_realtime[opencv]\" # opencv optional\n```\n\n\n## Usage\n\nFirst, start the server and keep it running:\n\n```bash\npython -m bdsim_realtime.webapp\n```\n\nThen, add and run your bdsim script, \n\n```python\nimport bdsim, numpy as np\nimport bdsim_realtime\n\n# setup block-diagram and tuner client\nbd = bdsim.BDSim(packages=\"bdsim_realtime\").blockdiagram()\n\n# All TunableBlocks within this context manager will register their parameters swith the Tuner\nwith bdsim_realtime.tuning.tuners.TcpClientTuner() as tuner:\n    # use first local camera available\n    clock = bd.clock(24, unit='Hz')\n    bgr = bd.CAMERA(0, clock=clock)\n\n    # display in web stream\n    bd.DISPLAY(bgr, name=\"BGR Stream\", web_stream_host=tuner, show_fps=True)\n\n    # tune system parameters in the web editor\n    gain = tuner.param(1, min=0, max=100)\n\n    # stream some telemetry data (random for demo)\n    data = bd.FUNCTION(\n        lambda _: (gain.val * np.random.rand(3)).tolist(),\n        nin=1, # unused import required here to use function as a Clocked Source Block\n        nout=3\n    )\n    bd.connect(bgr, data)\n\n    bd.TUNERSCOPE(\n        data[0], data[1], data[2],\n        nin=3,\n        labels=['x', 'y', 'z'],\n        name='Random Data',\n        tuner=tuner)\n\nbd.compile() # perform verification\nbdsim_realtime.run(bd, tuner=tuner) # run forever\n```\n\nNow access the tuner at [http://localhost:8080](http://localhost:8080)\n\n\n## Development\n\n### Setup\n\n\n```bash\npython -m venv .venv # create venv\nsource .venv/bin/activate # activate venv\n\npip install -e \".[opencv]\" # install in editable symlink mode\nnpm i # install JS deps\n```\n\n#### Frontend\n\n```\nnpm run dev # run hot-reloaded app\n```\n\n#### Backend\n\nSame as non-development version. Run:\n\n```\npython -m bdsim_realtime.webapp\n```\n\nAnd then run your example / test script:\n\n```\npython examples/blob_detector_tuner.py\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Real-time execution and remote monitoring and tuning of BDSim Block-Diagrams for modelling and control of Dynamical Systems",
    "version": "1.0.1",
    "split_keywords": [
        "python",
        "bdsim",
        "realtime",
        "control",
        "remote-control",
        "telemetry",
        "tuning-interface",
        "webapplication",
        "tuner",
        "signal-analysis",
        "control-system",
        "block-diagram",
        "computation-graph",
        "data-flow",
        "control-flow",
        "rtos",
        "simulation",
        "modeling",
        "computer-vision",
        "opencv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e76d4605d968fa2313017775812ea41b5ca5506219c2bf850dc40f031e34130b",
                "md5": "da685fa23534f4655adfe4a320d6be86",
                "sha256": "5eeb6d3b2c0bd5d8064152ea3aad3e337e5cd3ad804d0b122b818b9fc272d802"
            },
            "downloads": -1,
            "filename": "bdsim_realtime-1.0.1-py3.10.egg",
            "has_sig": false,
            "md5_digest": "da685fa23534f4655adfe4a320d6be86",
            "packagetype": "bdist_egg",
            "python_version": "1.0.1",
            "requires_python": ">=3.6",
            "size": 230560,
            "upload_time": "2023-02-05T04:12:37",
            "upload_time_iso_8601": "2023-02-05T04:12:37.146018Z",
            "url": "https://files.pythonhosted.org/packages/e7/6d/4605d968fa2313017775812ea41b5ca5506219c2bf850dc40f031e34130b/bdsim_realtime-1.0.1-py3.10.egg",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-05 04:12:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "CallumJHays",
    "github_project": "bdsim_realtime",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "msgpack",
            "specs": []
        },
        {
            "name": "sanic",
            "specs": []
        }
    ],
    "lcname": "bdsim-realtime"
}
        
Elapsed time: 0.05779s