<launch>
    <arg name="aruco_detect" default="true"/>
    <arg name="aruco_map" default="true"/>
    <arg name="aruco_vpe" default="true"/>

    <!-- For additional help go to https://clever.coex.tech/aruco -->

    <!-- aruco_detect: detect aruco markers, estimate poses -->
    <node name="aruco_detect" pkg="nodelet" if="$(arg aruco_detect)" type="nodelet" args="load aruco_pose/aruco_detect nodelet_manager" output="screen" clear_params="true">
        <remap from="image_raw" to="main_camera/image_raw"/>
        <remap from="camera_info" to="main_camera/camera_info"/>
        <remap from="map_markers" to="aruco_map/markers" if="$(arg aruco_map)"/>
        <param name="estimate_poses" value="true"/>
        <param name="send_tf" value="true"/>
        <param name="known_tilt" value="map"/>
        <param name="length" value="0.33"/>
    </node>

    <!-- aruco_map: estimate aruco map pose -->
    <node name="aruco_map" pkg="nodelet" type="nodelet" if="$(arg aruco_map)" args="load aruco_pose/aruco_map nodelet_manager" output="screen" clear_params="true">
        <remap from="image_raw" to="main_camera/image_raw"/>
        <remap from="camera_info" to="main_camera/camera_info"/>
        <remap from="markers" to="aruco_detect/markers"/>
        <param name="map" value="$(find aruco_pose)/map/animation_map.txt"/>
        <param name="known_tilt" value="map"/>
        <param name="image_axis" value="true"/>
        <param name="frame_id" value="aruco_map_detected" if="$(arg aruco_vpe)"/>
        <param name="frame_id" value="aruco_map" unless="$(arg aruco_vpe)"/>
        <param name="markers/frame_id" value="aruco_map"/>
        <param name="markers/child_frame_id_prefix" value="aruco_"/>
    </node>

    <!-- vpe publisher from aruco markers -->
    <node name="vpe_publisher" pkg="clever" type="vpe_publisher" if="$(arg aruco_vpe)" output="screen" clear_params="true">
        <remap from="~pose_cov" to="aruco_map/pose"/>
        <remap from="~vpe" to="mavros/vision_pose/pose"/>
        <param name="frame_id" value="aruco_map_detected"/>
        <param name="publish_zero" value="true"/>
        <param name="offset_frame_id" value="aruco_map"/>
    </node>
</launch>
