<!-- Single entry point for all robot deployments — stack dispatch only
     (RFC #379).

     The stack folder's entry launch file (stacks/<name>/launch/
     <entry>.launch.xml) composes the autonomy graph. `airstack up` with the
     stack flag exports AIRSTACK_STACK_DIR / AIRSTACK_STACK_ENTRY (container
     paths); with no stack selected, the trunk reference stack full_default
     launches. See docs/development/stacks.md.

     Migration note: the legacy AUTONOMY_ROLE dispatch (full | onboard |
     offboard role groups) was removed on this branch.
       - full        -> stacks/full_default (machine-proven graph-identical:
                        the committed wiring.md baseline)
       - onboard     -> stacks/lite_default (the desktop-profile 'onboard'
                        role was unreachable anyway: the robot-desktop
                        service hardcoded AUTONOMY_ROLE=full)
       - onboard/offboard split -> stacks/lite_offload_global (:onboard /
                        :offboard entries). Its bridge.yaml-generated DDS
                        router config deliberately improves on the legacy
                        split's dds_router.yaml by dropping the
                        set_trajectory_mode crossing — command authority
                        stays onboard (`airstack doctor` hard gate #2).

     The shared preamble below (namespace push, use_sim_time,
     robot_state_publisher, world->map TF) runs for every stack; entry files
     do not repeat it.
-->
<launch>
  <arg name="sim" default="true" />
  <arg name="urdf_file" default="$(env URDF_FILE iris_with_sensors.pegasus.robot.urdf)" />

  <!-- Stack dispatch (RFC #379 S3): stack_dir/stack_entry select
       launch/<stack_entry>.launch.xml inside the stack folder. Defaults come
       from env vars so both launch wrappers (desktop_bringup,
       autonomy_bringup) work unchanged; `airstack up` exports them
       (container paths). No stack env set = full_default. -->
  <arg name="stack_dir" default="$(env AIRSTACK_STACK_DIR /root/AirStack/stacks/full_default)" />
  <arg name="stack_entry" default="$(env AIRSTACK_STACK_ENTRY stack)" />

  <push_ros_namespace namespace="$(env ROBOT_NAME)" />

  <set_parameter name="use_sim_time" value="true" if="$(var sim)" />

  <!-- Robot State Publisher -->
  <include file="$(find-pkg-share robot_descriptions)/launch/robot_state_publisher.launch.py">
    <arg name="robot_name" value="$(env ROBOT_NAME)" />
    <arg name="urdf_file_path" value="$(var urdf_file)" />
    <arg name="ignore_timestamp" value="true" />
    <arg name="use_sim_time" value="$(var sim)" />
  </include>

  <!-- Static TFs (world → map) -->
  <node pkg="tf2_ros" exec="static_transform_publisher"
    name="world_to_map_broadcaster"
    args="0 0 0 0 0 0 world map" />

  <!-- ── Stack dispatch ─────────────────────────────────────────────────── -->
  <include file="$(var stack_dir)/launch/$(var stack_entry).launch.xml" />

</launch>
