Repository navigation
Feature/dashboard-api #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
679de9d
Add dashboard_api package and dashboard_interface
Hudson111-s 01cbc5a
Move id into cards, add optional arguments, change ROS type to String…
Hudson111-s 9bc11e8
Add description and update email
Hudson111-s d2b1405
Refactor DashboardApi to use per-node instances
Hudson111-s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from .dashboard_api import ( | ||
| init, | ||
| get, | ||
| card, | ||
| color, | ||
| bar | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| from json import dumps | ||
| from rclpy.node import Node | ||
| from std_msgs.msg import String | ||
|
|
||
| class DashboardApi(): | ||
| def __init__(self, node: Node) -> None: | ||
| self.node = node | ||
| self.publisher = node.create_publisher(String, "hmi_dashboard_data", 10) | ||
|
|
||
| def _publish_dashboard(self, msg: String) -> None: | ||
| self.publisher.publish(msg) | ||
| self.node.get_logger().info(f"Published: {msg.data}") | ||
|
|
||
| def _make_msg(self, _id: str, screen: str, _type: str, data: dict) -> String: | ||
| msg = String() | ||
| data = { | ||
| "id": _id, | ||
| "screen": screen, | ||
| "type": _type, | ||
| "data": data | ||
| } | ||
| msg.data = dumps(data) | ||
| return msg | ||
|
|
||
| def card( | ||
| self, | ||
| _id: str, | ||
| screen: str, | ||
| title: str, | ||
| content: str=None | ||
| ) -> None: | ||
| data = { | ||
| "title": title, | ||
| "content": content | ||
| } | ||
| msg = self._make_msg(_id, screen, "card", data) | ||
| self._publish_dashboard(msg) | ||
|
|
||
| def color( | ||
| self, | ||
| _id: str, | ||
| screen: str, | ||
| title: str, | ||
| color: str, | ||
| content: str=None | ||
| ) -> None: | ||
| data = { | ||
| "title": title, | ||
| "content": content, | ||
| "color": color | ||
| } | ||
| msg = self._make_msg(_id, screen, "color", data) | ||
| self._publish_dashboard(msg) | ||
|
|
||
| def bar( | ||
| self, | ||
| _id: str, | ||
| screen: str, | ||
| title: str, | ||
| value: int, | ||
| content: str=None, | ||
| min_value: int=0, | ||
| max_value: int=1 | ||
| ) -> None: | ||
| data = { | ||
| "title": title, | ||
| "content": content, | ||
| "value": value, | ||
| "min": min_value, | ||
| "max": max_value | ||
| } | ||
| msg = self._make_msg(_id, screen, "bar", data) | ||
| self._publish_dashboard(msg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0"?> | ||
| <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
| <package format="3"> | ||
| <name>dashboard_api</name> | ||
| <version>0.0.0</version> | ||
| <description>A ROS 2 API for publishing structured dashboard data as JSON to a web-based HMI, allowing nodes to send cards, bars, and color indicators.</description> | ||
| <maintainer email="goldrushrobotics@charlotte.edu">GoldRushRobotics</maintainer> | ||
| <license>MIT</license> | ||
|
|
||
| <exec_depend>rclpy</exec_depend> | ||
| <exec_depend>std_msgs</exec_depend> | ||
|
|
||
| <export> | ||
| <build_type>ament_python</build_type> | ||
| </export> | ||
| </package> |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [develop] | ||
| script_dir=$base/lib/dashboard_api | ||
| [install] | ||
| install_scripts=$base/lib/dashboard_api |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from setuptools import setup | ||
|
|
||
| package_name = 'dashboard_api' | ||
|
|
||
| setup( | ||
| name=package_name, | ||
| version='0.0.0', | ||
| packages=[package_name], | ||
| data_files=[ | ||
| ('share/ament_index/resource_index/packages', | ||
| ['resource/' + package_name]), | ||
| ('share/' + package_name, ['package.xml']), | ||
| ], | ||
| install_requires=['setuptools'], | ||
| zip_safe=True, | ||
| maintainer='GoldRushRobotics', | ||
| maintainer_email='goldrushrobotics@charlotte.edu', | ||
| description='A ROS 2 API for publishing structured dashboard data as JSON to a web-based HMI, allowing nodes to send cards, bars, and color indicators.', | ||
| license='MIT', | ||
| entry_points={ | ||
| 'console_scripts': [], | ||
| }, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.