# roboflex_imgui
Roboflex visualizers and guis using IMGUI/IMPLOT
## System dependencies
Requires SDL and GLEW to be installed. More than likely, they already are installed in your distro. But if not:
apt-get install libsdl2-dev
apt-get install libglew-dev
# or maybe on mac:
brew install sdl2
brew install glew
brew install glfw
## pip install
pip install roboflex.imgui
## Import
import roboflex.imgui as rgu
## Nodes
There are two so far: **OneDTV** and **MetricsTelevision**
### OneDTV (One-Dimensional Television)
![](onedviewer.png)
It expects to receive messages that contain a tensor under the key <data_key>. That tensor needs to be of shape (C, S), where C is number of channels, and S is sequence length. In general, C should be small (< 20), and S large. Think multiple audio channels.
# all parameters optional: below are the defaults
visualizer = rgu.OneDTV(
data_key = "data",
sample_size = 4,
center_zero = True,
initial_size = (640, 220),
initial_pos = (-1, -1),
name = "OneDTV",
debug = False,
)
# must be started
visualizer.start()
# NOTE!!!
# On some systems, such as mac, it's bad news to
# run a UI on a non-main thread. So instead of
# calling start(), you can do this, which will
# run on the main thread. This call will block
# until the window is closed, in this case.
visualizer.run()
### MetricsTelevision
![](metrics_central_1.png)
Real-time visualization of metrics data as published by `GraphRoot::start(profile=True)`. I.e., when you instantiate a `GraphRoot` (from roboflex core), make it the root of your graph, and call myroot.start(profile=True) on it, it will publish metrics messages. This is the node that can visualize those metrcs message.
# all parameters optional: below are the defaults
visualizer = rgu.MetricsTelevision(
window_title = "MetricsTelevision",
initial_size = (1580, 720),
initial_pos = (-1, -1),
name = "MetricsTelevision",
debug = False,
)
# must be started
visualizer.start()
# NOTE!!!
# On some systems, such as mac, it's bad news to
# run a UI on a non-main thread. So instead of
# calling start(), you can do this, which will
# run on the main thread. This call will block
# until the window is closed, in this case.
visualizer.run()
### Using MQTT in this case
MQTT is an ideal transport for metrics messages - they are small and infrequent. We provide helper functions in `metrics_central.py` to do so:
# give one of these to a GraphRoot as it's publisher node
pub = rgu.metrics_central.get_metrics_mqtt_publisher(
broker_address: str,
broker_port: int = 1883,
metrics_topic: str = "metrics",
)
# get a subscriber
sub = rgu.get_metrics_mqtt_subscriber(
broker_address: str,
broker_port: int = 1883,
metrics_topic: str = "metrics",
)
# get a visualizer
vis = rgu.get_metrics_visualizer(
broker_address: str,
broker_port: int = 1883,
metrics_topic: str = "metrics",
)
# connect the subscriber to the visualizer
sub > vis
# Here's a program that does it all - launches a MetricsVisualizer
# listening to some mqtt broker:port and topic.
python3 metrics_central.py
Raw data
{
"_id": null,
"home_page": "https://github.com/flexrobotics/roboflex_imgui",
"name": "roboflex.imgui",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "imgui,implot,gui,visualization,robotics,middleware,flexbuffers,python,c++,c++20",
"author": "Colin Prepscius",
"author_email": "colinprepscius@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/bf/b2/46a5c47befdf35d6c620eb6c86577d7803c7fbb1506b6dcf415bf8891103/roboflex.imgui-0.1.14.tar.gz",
"platform": null,
"description": "# roboflex_imgui\n\nRoboflex visualizers and guis using IMGUI/IMPLOT\n\n\n## System dependencies\n\nRequires SDL and GLEW to be installed. More than likely, they already are installed in your distro. But if not:\n\n apt-get install libsdl2-dev\n apt-get install libglew-dev\n\n # or maybe on mac:\n\n brew install sdl2\n brew install glew\n brew install glfw\n\n## pip install\n\n pip install roboflex.imgui\n\n## Import\n\n import roboflex.imgui as rgu\n\n## Nodes\n\nThere are two so far: **OneDTV** and **MetricsTelevision**\n\n\n### OneDTV (One-Dimensional Television)\n\n![](onedviewer.png)\n\nIt expects to receive messages that contain a tensor under the key <data_key>. That tensor needs to be of shape (C, S), where C is number of channels, and S is sequence length. In general, C should be small (< 20), and S large. Think multiple audio channels.\n\n # all parameters optional: below are the defaults\n visualizer = rgu.OneDTV(\n data_key = \"data\",\n sample_size = 4,\n center_zero = True,\n initial_size = (640, 220),\n initial_pos = (-1, -1),\n name = \"OneDTV\",\n debug = False,\n )\n\n # must be started\n visualizer.start()\n\n # NOTE!!!\n # On some systems, such as mac, it's bad news to\n # run a UI on a non-main thread. So instead of \n # calling start(), you can do this, which will \n # run on the main thread. This call will block \n # until the window is closed, in this case.\n visualizer.run()\n\n### MetricsTelevision\n\n![](metrics_central_1.png)\n\nReal-time visualization of metrics data as published by `GraphRoot::start(profile=True)`. I.e., when you instantiate a `GraphRoot` (from roboflex core), make it the root of your graph, and call myroot.start(profile=True) on it, it will publish metrics messages. This is the node that can visualize those metrcs message.\n\n # all parameters optional: below are the defaults\n visualizer = rgu.MetricsTelevision(\n window_title = \"MetricsTelevision\",\n initial_size = (1580, 720),\n initial_pos = (-1, -1),\n name = \"MetricsTelevision\",\n debug = False,\n )\n\n # must be started\n visualizer.start()\n\n # NOTE!!!\n # On some systems, such as mac, it's bad news to\n # run a UI on a non-main thread. So instead of \n # calling start(), you can do this, which will \n # run on the main thread. This call will block \n # until the window is closed, in this case.\n visualizer.run()\n\n### Using MQTT in this case\n\nMQTT is an ideal transport for metrics messages - they are small and infrequent. We provide helper functions in `metrics_central.py` to do so:\n\n # give one of these to a GraphRoot as it's publisher node\n pub = rgu.metrics_central.get_metrics_mqtt_publisher(\n broker_address: str,\n broker_port: int = 1883,\n metrics_topic: str = \"metrics\",\n )\n\n # get a subscriber\n sub = rgu.get_metrics_mqtt_subscriber(\n broker_address: str,\n broker_port: int = 1883,\n metrics_topic: str = \"metrics\",\n )\n\n # get a visualizer\n vis = rgu.get_metrics_visualizer(\n broker_address: str,\n broker_port: int = 1883,\n metrics_topic: str = \"metrics\",\n )\n\n # connect the subscriber to the visualizer\n sub > vis\n\n # Here's a program that does it all - launches a MetricsVisualizer\n # listening to some mqtt broker:port and topic.\n python3 metrics_central.py\n\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Roboflex Visualization/GUI Library using IMGUI/IMPLOT",
"version": "0.1.14",
"project_urls": {
"Homepage": "https://github.com/flexrobotics/roboflex_imgui"
},
"split_keywords": [
"imgui",
"implot",
"gui",
"visualization",
"robotics",
"middleware",
"flexbuffers",
"python",
"c++",
"c++20"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bfb246a5c47befdf35d6c620eb6c86577d7803c7fbb1506b6dcf415bf8891103",
"md5": "3b17941aead5124ed094e41a5a5769b4",
"sha256": "527cabfb4a9b9d666810aa11af96ca99ff8118798396f7359713b3c30d50971e"
},
"downloads": -1,
"filename": "roboflex.imgui-0.1.14.tar.gz",
"has_sig": false,
"md5_digest": "3b17941aead5124ed094e41a5a5769b4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 112152,
"upload_time": "2023-12-01T18:27:36",
"upload_time_iso_8601": "2023-12-01T18:27:36.297895Z",
"url": "https://files.pythonhosted.org/packages/bf/b2/46a5c47befdf35d6c620eb6c86577d7803c7fbb1506b6dcf415bf8891103/roboflex.imgui-0.1.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-01 18:27:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "flexrobotics",
"github_project": "roboflex_imgui",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "roboflex.imgui"
}