diff --git a/CMakeLists.txt b/CMakeLists.txt index 6de0467..3b0670e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,9 @@ install(DIRECTORY USE_SOURCE_PERMISSIONS ) -# Install launch files. +# Install launch and param files. install(DIRECTORY - launch + launch params DESTINATION share/${PROJECT_NAME}/ ) diff --git a/am_i_up/Api.py b/am_i_up/Api.py index 31c71bb..7550567 100644 --- a/am_i_up/Api.py +++ b/am_i_up/Api.py @@ -18,7 +18,7 @@ class Api: self._facts = facts async def run(self): - ui_share_directory = get_package_share_directory("am_i_up_ui") + ui_share_directory = get_package_share_directory(self._facts.get_ui_pkg()) ui_static_directory = ui_share_directory + "/dist/assets" app = web.Application() @@ -37,7 +37,7 @@ class Api: ]) url = "0.0.0.0" - port = 8888 + port = self._facts.get_listen_port() print("Listening on {}:{}".format(url, port)) runner = web.AppRunner(app) @@ -50,7 +50,7 @@ class Api: await runner.cleanup() async def index(self, request): - ui_share_directory = get_package_share_directory("am_i_up_ui") + ui_share_directory = get_package_share_directory(self._facts.get_ui_pkg()) ui_index_path = ui_share_directory + "/dist/index.html" return web.FileResponse(ui_index_path) diff --git a/am_i_up/Facts.py b/am_i_up/Facts.py index c44131b..c089143 100644 --- a/am_i_up/Facts.py +++ b/am_i_up/Facts.py @@ -36,6 +36,12 @@ class Facts: def get_status(self): return self._ros.get_status_string() + def get_listen_port(self): + return self._ros.get_listen_port() + + def get_ui_pkg(self): + return self._ros.get_ui_pkg() + def get_uptime(self): return time.monotonic() - self._start_time diff --git a/am_i_up/Ros.py b/am_i_up/Ros.py index 8bbe165..5546565 100644 --- a/am_i_up/Ros.py +++ b/am_i_up/Ros.py @@ -23,6 +23,9 @@ class Ros: self._image_sub = self._node.create_subscription(CompressedImage, "image/compressed", self._image_callback, 1) self._navsat_sub = self._node.create_subscription(NavSatFix, "navsatfix", self._navsat_callback, 1) + self._listen_port = self._node.declare_parameter("listen_port", "8888").value + self._ui_pkg = self._node.declare_parameter("ui_pkg", "am_i_up_ui").value + self._status_string = None self._lat_long = None self._costmap_image = None @@ -36,6 +39,12 @@ class Ros: def get_costmap_image(self): return self._costmap_image + def get_listen_port(self): + return self._listen_port + + def get_ui_pkg(self): + return self._ui_pkg + async def run(self): while rclpy.ok(): rclpy.spin_once(self._node, timeout_sec=0) diff --git a/launch/am_i_up.launch.xml b/launch/am_i_up.launch.xml index 6d1aa9a..3e88ca3 100644 --- a/launch/am_i_up.launch.xml +++ b/launch/am_i_up.launch.xml @@ -1,5 +1,16 @@ - + + + + + + + + + + + + diff --git a/package.xml b/package.xml index 82d7fdf..6d1ab6c 100644 --- a/package.xml +++ b/package.xml @@ -10,7 +10,6 @@ ament_cmake_python python3-aiohttp - python3-jinja2 rclpy diff --git a/params/am_i_up.yaml b/params/am_i_up.yaml new file mode 100644 index 0000000..c73ecac --- /dev/null +++ b/params/am_i_up.yaml @@ -0,0 +1,4 @@ +/**: + ros__parameters: + ui_pkg: "am_i_up_ui" + listen_port: "8000" \ No newline at end of file diff --git a/params/image2rtsp.yaml b/params/image2rtsp.yaml new file mode 100644 index 0000000..6adebbb --- /dev/null +++ b/params/image2rtsp.yaml @@ -0,0 +1,7 @@ +/**: + ros__parameters: + compressed: True + topic: "image/compressed" + mountpoint: "/image" + port: "8559" + local_only: True \ No newline at end of file diff --git a/params/mediamtx.yaml b/params/mediamtx.yaml new file mode 100644 index 0000000..c59e97b --- /dev/null +++ b/params/mediamtx.yaml @@ -0,0 +1,3 @@ +paths: + image: + source: rtsp://127.0.0.1:8559/image \ No newline at end of file