<launch>
  <arg name="other_topics" default=""/>
  <arg name="other_options" default=""/>

  <!-- for PR2 -->
  <arg name="save_openni" default="true" />
  <arg name="save_tilt_scan" default="true" />
  <arg name="save_base_scan" default="true" />
  <arg name="save_robot_model" default="true" />
  <arg name="save_all_image" default="true" />
  <arg name="save_pressure" default="true" />
  <arg name="save_gripper_command" default="true" />
  <arg name="save_prosilica" default="false" />
  <arg name="camera_namespace" default="openni"/>
  <arg name="save_dir" default="/removable/bagfile/"/>
  <!--                          -->
  <!--       Conditions         -->
  <!--                          -->

  <arg unless="$(arg save_openni)"
       name="openni_topics" value="" />
  <arg if    ="$(arg save_openni)"
       name="openni_topics" value="/$(arg camera_namespace)/depth_registered/image_raw /$(arg camera_namespace)/depth_registered/camera_info /$(arg camera_namespace)/rgb/image_raw /$(arg camera_namespace)/rgb/camera_info /tf" />

  <arg unless="$(arg save_base_scan)"
       name="base_scan_topics" value="" />
  <arg if    ="$(arg save_base_scan)"
       name="base_scan_topics" value="/base_scan" />

  <arg unless="$(arg save_tilt_scan)"
       name="tilt_scan_topics" value="" />
  <arg if    ="$(arg save_tilt_scan)"
       name="tilt_scan_topics" value="/tilt_scan" />

  <arg unless="$(arg save_robot_model)"
       name="robot_model_topics" value="" />
  <arg if    ="$(arg save_robot_model)"
       name="robot_model_topics" value="/tf /joint_states" />

  <arg unless="$(arg save_all_image)"
       name="all_image_topics" value="" />
  <arg if    ="$(arg save_all_image)"
       name="all_image_topics" value="-e .*/(image_raw|camera_info)" />

  <arg unless="$(arg save_pressure)"
       name="pressure_topics" value="" />
  <arg if    ="$(arg save_pressure)"
       name="pressure_topics" value="/pressure/l_gripper_motor /pressure/r_gripper_motor" />

  <arg unless="$(arg save_gripper_command)"
       name="gripper_command_topics" value="" />
  <arg if    ="$(arg save_gripper_command)"
       name="gripper_command_topics"
       value="/l_gripper_controller/command /r_gripper_controller/command" />

  <arg unless="$(arg save_prosilica)"
       name="prosilica_topics" value="" />
  <arg if    ="$(arg save_prosilica)"
       name="prosilica_topics" value="/prosilica/image_raw /prosilica/camera_info" />


  <!-- execute -->
  <node name="default_rosbag_record" pkg="rosbag" type="record"
	args="$(arg openni_topics) 
          $(arg base_scan_topics) 
          $(arg tilt_scan_topics) 
          $(arg robot_model_topics) 
          $(arg all_image_topics) 
          $(arg pressure_topics) 
          $(arg gripper_command_topics) 
	  $(arg prosilica_topics)
          $(arg other_topics)
          -o $(arg save_dir) 
          $(arg other_options)
          "/>
   <node if  ="$(arg save_prosilica)" 
         name="set_prosilica_mode" pkg="dynamic_reconfigure" type="dynparam"
         args="set /prosilica_driver trigger_mode 'streaming'" />
</launch>
