Skip to content

Commit

Permalink
Add url_path config option (#709)
Browse files Browse the repository at this point in the history
Add new --url_path command line arg and corresponding ROS param to the websocket process. This argument allows for specifying an alternative path other than the root path when running the websocket process.
  • Loading branch information
leossok committed Jun 27, 2022
1 parent 277d260 commit 4bcf816
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions rosbridge_server/scripts/rosbridge_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ def __init__(self):
print("--address argument provided without a value.")
sys.exit(-1)

url_path = self.declare_parameter("url_path", "/").value
if "--url_path" in sys.argv:
idx = sys.argv.index("--url_path") + 1
if idx < len(sys.argv):
url_path = str(sys.argv[idx])
else:
print("--url_path argument provided without a value.")
sys.exit(-1)

retry_startup_delay = self.declare_parameter("retry_startup_delay", 2.0).value # seconds.
if "--retry_startup_delay" in sys.argv:
idx = sys.argv.index("--retry_startup_delay") + 1
Expand All @@ -137,9 +146,11 @@ def __init__(self):
# Done with parameter handling #
##################################################

application = Application(
[(r"/", RosbridgeWebSocket), (r"", RosbridgeWebSocket)], **tornado_settings
)
handlers = [(r"/", RosbridgeWebSocket), (r"", RosbridgeWebSocket)]
if url_path != "/":
handlers = [(rf"{url_path}", RosbridgeWebSocket)]

application = Application(handlers, **tornado_settings)

connected = False
while not connected and self.context.ok():
Expand Down

0 comments on commit 4bcf816

Please sign in to comment.