"""
Establish communications with the Kobuki platform so that it starts publishing odometry
measurements and accepting velocity commands.
"""

from ament_index_python.packages import get_package_share_path
from launch_ros.actions import Node

from launch import LaunchDescription
from launch.actions import Shutdown
from slamcore_ros2_examples.configuration import Configuration
from slamcore_ros2_examples.utils import add_all_actions


def generate_launch_description():
    cfg = Configuration()

    # get directories & paths -----------------------------------------------------------------
    share_dir = get_package_share_path("slamcore_ros2_examples")

    # non-editable config variables -----------------------------------------------------------
    default_demo_params_file = share_dir / "config" / "nav2-demo-params.yaml"

    # launch arguments ------------------------------------------------------------------------
    cfg.register(
        "params_file",
        default_value=default_demo_params_file,
        description="Full path to the ROS2 parameters file to use for all launched nodes",
    )

    # assemble launch description -------------------------------------------------------------
    ld = LaunchDescription(
        [
            # launch arguments ----------------------------------------------------------------
            *cfg.launch_arguments(),
        ]
    )

    # include launchfiles and nodes -----------------------------------------------------------
    add_all_actions(
        # kobuki ------------------------------------------------------------------------------
        Node(
            package="kobuki_node",
            executable="kobuki_ros_node",
            name="kobuki_ros_node",
            output="screen",
            parameters=[
                str(
                    get_package_share_path("kobuki_node")
                    / "config"
                    / "kobuki_node_params.yaml"
                ),
                cfg.params_file.cfg,
            ],
            remappings=[("/commands/velocity", "/cmd_vel")],
            on_exit=Shutdown(),
        ),
        ld=ld,
    )

    return ld

"""
Establish communications with the Kobuki platform so that it starts publishing odometry
measurements and accepting velocity commands.
"""

from ament_index_python.packages import get_package_share_path
from launch_ros.actions import Node

from launch import LaunchDescription
from launch.actions import Shutdown
from slamcore_ros2_examples.configuration import Configuration
from slamcore_ros2_examples.utils import add_all_actions


def generate_launch_description():
    cfg = Configuration()

    # get directories & paths -----------------------------------------------------------------
    share_dir = get_package_share_path("slamcore_ros2_examples")

    # non-editable config variables -----------------------------------------------------------
    default_demo_params_file = share_dir / "config" / "nav2-demo-params.yaml"

    # launch arguments ------------------------------------------------------------------------
    cfg.register(
        "params_file",
        default_value=default_demo_params_file,
        description="Full path to the ROS2 parameters file to use for all launched nodes",
    )

    # assemble launch description -------------------------------------------------------------
    ld = LaunchDescription(
        [
            # launch arguments ----------------------------------------------------------------
            *cfg.launch_arguments(),
        ]
    )

    # include launchfiles and nodes -----------------------------------------------------------
    add_all_actions(
        # kobuki ------------------------------------------------------------------------------
        Node(
            package="kobuki_node",
            executable="kobuki_ros_node",
            name="kobuki_ros_node",
            output="screen",
            parameters=[
                str(
                    get_package_share_path("kobuki_node")
                    / "config"
                    / "kobuki_node_params.yaml"
                ),
                cfg.params_file.cfg,
            ],
            remappings=[("/commands/velocity", "/cmd_vel")],
            on_exit=Shutdown(),
        ),
        ld=ld,
    )

    return ld

Establish communications with the Kobuki platform so that it starts publishing odometry measurements and accepting velocity commands. # get directories & paths ----------------------------------------------------------------- # non-editable config variables ----------------------------------------------------------- # launch arguments ------------------------------------------------------------------------ # assemble launch description ------------------------------------------------------------- # launch arguments ---------------------------------------------------------------- # include launchfiles and nodes ----------------------------------------------------------- # kobuki ------------------------------------------------------------------------------