"""Launch file for power supervisor node."""

from pathlib import Path

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.substitutions import PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description() -> LaunchDescription:
    """Generate launch description for power supervisor."""
    config_dir = PathJoinSubstitution(
        [FindPackageShare("saltybot_power_supervisor"), "config"]
    )
    config_file = PathJoinSubstitution([config_dir, "power_supervisor_params.yaml"])

    power_supervisor_node = Node(
        package="saltybot_power_supervisor",
        executable="power_supervisor_node",
        name="power_supervisor_node",
        output="screen",
        parameters=[config_file],
    )

    return LaunchDescription([power_supervisor_node])
