Skip to content

Commit

Permalink
launch live server
Browse files Browse the repository at this point in the history
  • Loading branch information
git-afsantos committed Aug 1, 2023
1 parent 815c0a1 commit 46833b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.0.0](https://github.com/HAROS-framework/hpl-rv-ros/releases/tag/v1.0.0) - 2023-08-01
## [v1.0.1](https://github.com/HAROS-framework/hpl-rv-ros/releases/tag/v1.0.1) - 2023-08-01
### Changed
- The generated ROS nodes now start the live monitoring server.

## [v1.0.0](https://github.com/HAROS-framework/hpl-rv-ros/releases/tag/v1.0.0) - 2023-08-01
Initial release.

This package provides a tool to generate ROS1 and ROS2 Python runtime monitors from HPL specifications.
This version includes both an interface to use as a library and a CLI script for direct usage.

## [0.0.0](https://github.com/HAROS-framework/hpl-rv-ros/releases/tag/v0.0.0) - 2023-07-19
## [v0.0.0](https://github.com/HAROS-framework/hpl-rv-ros/releases/tag/v0.0.0) - 2023-07-19
Repository creation.
7 changes: 7 additions & 0 deletions src/hplrv_ros/templates/rclpy.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class HplMonitorNode(Node):
def __init__(self):
super().__init__('hplrv_monitor')
self.monitor = HplMonitorManager(success_cb=self._on_success, failure_cb=self._on_failure)
self.monitor.live_server.host = '127.0.0.1'
self.monitor.live_server.port = 4242
self._thread = None
self.timer = self.create_timer(0.01, self.on_timer)
latching_qos = QoSProfile(
depth=1,
Expand All @@ -51,12 +54,16 @@ class HplMonitorNode(Node):
]

def on_launch(self):
self._thread = self.monitor.live_server.start_thread()
t = self.get_clock().now()
self.monitor.launch(t)

def on_shutdown(self):
t = self.get_clock().now()
self.monitor.shutdown(t)
assert self._thread is not None
self._thread.join(10.0)
self._thread = None

def on_timer(self):
t = self.get_clock().now()
Expand Down
4 changes: 4 additions & 0 deletions src/hplrv_ros/templates/rospy.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {{ rospkg }}.msg as {{ rospkg }}
class HplMonitorNode:
def __init__(self):
self.monitor = HplMonitorManager(success_cb=self._on_success, failure_cb=self._on_failure)
self.monitor.live_server.host = '127.0.0.1'
self.monitor.live_server.port = 4242
self.pubs = {}
for i in range(len(self.monitor.monitors)):
mon = self.monitor.monitors[i]
Expand All @@ -37,6 +39,7 @@ class HplMonitorNode:
]

def run(self):
thread = self.monitor.live_server.start_thread()
t = rospy.get_time()
self.monitor.launch(t)
rate = rospy.Rate(100) # 100hz
Expand All @@ -48,6 +51,7 @@ class HplMonitorNode:
except rospy.ROSInterruptException:
t = rospy.get_time()
self.monitor.shutdown(t)
thread.join(10.0)
{# -#}
{% for topic in topics %}

Expand Down

0 comments on commit 46833b8

Please sign in to comment.