<launch>

  <arg name="gui" default="true" />
  <arg name="launch_manager" default="true" />

  <arg name="MANAGER" default="sample_manager" />
  <node name="$(arg MANAGER)"
        pkg="nodelet" type="nodelet" args="manager"
        if="$(arg launch_manager)"
        output="screen" />

  <param name="/use_sim_time" value="true" />
  <node name="rosbag_play"
    pkg="rosbag" type="play"
    args="$(find jsk_perception)/sample/data/2016-11-11-12-53-06_in_lab.bag --clock --loop" />

  <arg name="INPUT_IMAGE" default="/camera/rgb/image_raw" />
  <arg name="INPUT_DEPTH_IMAGE" value="/camera/depth_registered/image_raw" />
  <arg name="INPUT_CAMERA_INFO" value="/camera/depth_registered/camera_info" />

  <node name="selective_search"
        pkg="jsk_perception" type="selective_search.py">
    <remap from="~input" to="$(arg INPUT_IMAGE)" />
  </node>
  <node name="rect_array_actual_size_filter"
        pkg="nodelet" type="nodelet"
        args="load jsk_perception/RectArrayActualSizeFilter $(arg MANAGER)"
        respawn="true">
    <remap from="~input" to="selective_search/output" />
    <remap from="~input/depth_image" to="$(arg INPUT_DEPTH_IMAGE)" />
    <remap from="~input/info" to="$(arg INPUT_CAMERA_INFO)" />
    <rosparam>
      approximate_sync: true
      <!-- Detect only large objects -->
      min_x: 0.5
      max_x: 1.0
      min_y: 0.5
      max_y: 1.0
    </rosparam>
  </node>

  <node name="draw_rects"
        pkg="jsk_perception" type="draw_rects">
    <remap from="~input" to="$(arg INPUT_IMAGE)" />
    <remap from="~input/rects" to="selective_search/output" />
  </node>
  <node name="draw_rects_filtered"
        pkg="jsk_perception" type="draw_rects">
    <remap from="~input" to="$(arg INPUT_IMAGE)" />
    <remap from="~input/rects" to="rect_array_actual_size_filter/output" />
  </node>
  <node name="binpack_rect_array"
        pkg="jsk_perception" type="binpack_rect_array.py">
    <remap from="~input" to="$(arg INPUT_IMAGE)" />
    <remap from="~input/rect_array" to="rect_array_actual_size_filter/output" />
  </node>

  <group if="$(arg gui)">
    <node name="rqt_gui"
          pkg="rqt_gui" type="rqt_gui"
          args="--perspective-file $(find jsk_perception)/sample/config/sample_rect_array_actual_size_filter.perspective" />
  </group>

</launch>
