Skip to content

Commit

Permalink
Merge pull request #11 from aminballoon/add-ros-args-yasmin-viewer-node
Browse files Browse the repository at this point in the history
Add ros args yasmin viewer node for custom host and port
  • Loading branch information
mgonzs13 authored Dec 6, 2023
2 parents d9978aa + 4c1b67d commit 575d5d6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions yasmin_viewer/yasmin_viewer/yasmin_viewer_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 575d5d6

Please sign in to comment.