From 2c340cd5f5e3d4698d036959a571054d32b0b809 Mon Sep 17 00:00:00 2001 From: PannapatC Date: Wed, 6 Dec 2023 19:42:03 +0700 Subject: [PATCH 1/3] add ros args --- .../yasmin_viewer/yasmin_viewer_node.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py b/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py index 60735c5..bab39ef 100644 --- a/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py +++ b/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py @@ -44,7 +44,15 @@ class YasminFsmViewer(Node): def __init__(self) -> None: super().__init__("yasmin_viewer") - + + self.declare_parameters( + namespace="", + parameters=[ + ("host", "localhost"), + ("port", 5000), + ] + ) + self.__started = False self.__fsm_dict = ExpiringDict(max_len=300, max_age_seconds=3) @@ -79,7 +87,13 @@ def get_fsm(fsm_name): self.__started = True # app.run(host="localhost", port=5000) - serve(app, host="localhost", port=5000) + + _host = str(self.get_parameter('host').value) + _port = str(self.get_parameter('port').value) + print(f"Started Yasmin viewer on {_host}:{str(_port)}") + serve(app, + host = _host, + port = _port) def start_subscriber(self) -> None: self.create_subscription(StateMachine, From 62984e10be859b0d579c4f01a96f0e6750a55b55 Mon Sep 17 00:00:00 2001 From: PannapatC Date: Wed, 6 Dec 2023 20:00:04 +0700 Subject: [PATCH 2/3] add yasmin_viewer_node custom host and port --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d308030..7b0b606 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,14 @@ $ ros2 run yasmin_viewer yasmin_viewer_node http://localhost:5000/ +### Also you can custom host and port + +```shell +$ ros2 run yasmin_viewer yasmin_viewer_node --ros-args -p host:=127.0.0.1 -p port:=5032 +``` + +http://127.0.0.1:5032/ + ## Citations ```bibtex From 4c1b67da76454d4ba4a8b7b7a018ca87cbb9f33e Mon Sep 17 00:00:00 2001 From: PannapatC Date: Wed, 6 Dec 2023 20:00:23 +0700 Subject: [PATCH 3/3] change type param port str->int --- yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py b/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py index bab39ef..4a26047 100644 --- a/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py +++ b/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py @@ -89,7 +89,7 @@ def get_fsm(fsm_name): # app.run(host="localhost", port=5000) _host = str(self.get_parameter('host').value) - _port = str(self.get_parameter('port').value) + _port = int(self.get_parameter('port').value) print(f"Started Yasmin viewer on {_host}:{str(_port)}") serve(app, host = _host,