"""VESC CAN dual-motor odometry bridge (Issue #646)."""

import os
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
    pkg = get_package_share_directory("saltybot_nav2_slam")
    params_file = os.path.join(pkg, "config", "vesc_odometry_params.yaml")

    use_sim_time = LaunchConfiguration("use_sim_time")

    return LaunchDescription([
        DeclareLaunchArgument("use_sim_time", default_value="false"),

        Node(
            package="saltybot_nav2_slam",
            executable="vesc_can_odometry",
            name="vesc_can_odometry",
            parameters=[
                params_file,
                {"use_sim_time": use_sim_time},
            ],
            output="screen",
        ),
    ])
