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 diff --git a/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py b/yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py index 60735c5..4a26047 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 = int(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,