Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ros/src/dashboard_api/dashboard_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .dashboard_api import (
init,
get,
card,
color,
bar
)
73 changes: 73 additions & 0 deletions ros/src/dashboard_api/dashboard_api/dashboard_api.py
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)
16 changes: 16 additions & 0 deletions ros/src/dashboard_api/package.xml
Comment thread
Hudson111-s marked this conversation as resolved.
Resolved
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.
4 changes: 4 additions & 0 deletions ros/src/dashboard_api/setup.cfg
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
23 changes: 23 additions & 0 deletions ros/src/dashboard_api/setup.py
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': [],
},
)
2 changes: 1 addition & 1 deletion ros/src/hmi_com/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>hmi_com</name>
<version>0.0.0</version>
<description>This ROS package provides real-time insights into active ROS nodes by publishing JSON-formatted information about their publishers, subscribers, service servers, and service clients.</description>
<maintainer email="goldrushrobotics@gmail.com">GoldRushRobotics</maintainer>
<maintainer email="goldrushrobotics@charlotte.edu">GoldRushRobotics</maintainer>
<license>MIT</license>

<exec_depend>rclpy</exec_depend>
Expand Down
2 changes: 1 addition & 1 deletion ros/src/hmi_com_interface/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>hmi_com_interface</name>
<version>0.0.0</version>
<description>This ROS interface provides a service that is used in the hmi_com package to allow the request of information about active nodes.</description>
<maintainer email="goldrushrobotics@gmail.com">GoldRushRobotics</maintainer>
<maintainer email="goldrushrobotics@charlotte.edu">GoldRushRobotics</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>
Expand Down
Loading