"""
panoramic_node.py — Combined equirect stitcher + RTSP entry point.

Launches both equirect_stitcher and rtsp_server in a single process
using rclpy MultiThreadedExecutor.

This is useful when you want to run both nodes with a single command, e.g.:
  ros2 run saltybot_panoramic panoramic

For separate process deployment (recommended for production), use:
  ros2 run saltybot_panoramic equirect_stitcher
  ros2 run saltybot_panoramic rtsp_server
or use the provided launch file:
  ros2 launch saltybot_panoramic panoramic.launch.py
"""

import rclpy
from rclpy.executors import MultiThreadedExecutor

from saltybot_panoramic.equirect_stitcher_node import EquirectStitcherNode
from saltybot_panoramic.rtsp_server_node import RTSPServerNode


def main(args=None):
    rclpy.init(args=args)

    stitcher_node = EquirectStitcherNode()
    rtsp_node = RTSPServerNode()

    executor = MultiThreadedExecutor(num_threads=4)
    executor.add_node(stitcher_node)
    executor.add_node(rtsp_node)

    try:
        executor.spin()
    except KeyboardInterrupt:
        pass
    finally:
        stitcher_node.destroy_node()
        rtsp_node.destroy_node()
        rclpy.shutdown()


if __name__ == '__main__':
    main()
