# -------------------------------------------------------------------
#  Config file for the "rawlog-grabber" application
# Read more online: 
# http://www.mrpt.org/list-of-mrpt-apps/application-rawlog-grabber/
# -------------------------------------------------------------------

#  Each section [XXXXX] (but [global]) setups a thread in the rawlog-grabber
#   standalone application. Each thread collects data from some
#   sensor or device, then the main thread groups and orders them before
#   streaming everything to a rawlog file.
#
#  The name of the sections will become the sensor label. The driver for
#   each sensor is actually determined by the field "driver", which must
#   match the name of some class in HWDRIVERS implementing CGenericSensor.


# =======================================================
#  Section: Global settings to the application
#   
# =======================================================
[global]
# The prefix can contain a relative or absolute path.
# The final name will be <PREFIX>_date_time.rawlog
rawlog_prefix		= ./data_openni2

# Milliseconds between thread launches
time_between_launches	= 1000

use_sensoryframes	= 0

GRABBER_PERIOD_MS	= 1000

# ** IMPORTANT **: When grabbing from a 3D camera, disable GZ compression to avoid 
# a bottleneck compressing the 3D point clouds in real-time!
rawlog_GZ_compress_level  = 0   // 0: No compress, 1: fastest (default), 9: best 

# =======================================================
#  SENSOR: OpenNI2
#   
# =======================================================
[RGBD1]
# ** IMPORTANT **: See the note on "rawlog_GZ_compress_level" above
driver                         = COpenNI2Sensor
process_rate                   = 200		// Hz (max)

device_number   = 0           // Device index to open (0:first OpenNI2, 1:second OpenNI2,...)
width 		= 320
height 		= 240
fps 		= 30

grab_decimation = 1    // Grab 1 out of N only.

sensorLabel  	= RGBD_0      // A text description
COM_port_WIN 	= COM3
COM_port_LIN 	= ttyUSB1
preview_window  = true        // Show a window with a preview of the grabbed data in real-time

grab_image      = true        // Grab the RGB image channel? (Default=true)
grab_depth      = true        // Grab the depth channel? (Default=true)
grab_3D_points  = true        // Grab the 3D point cloud? (Default=true) If disabled, points can be generated later on.

# Optional: Set the initial tilt angle of OpenNI2: upon initialization, the motor is sent a command to 
#            rotate to this angle (in degrees). Note: You must be aware of the tilt when interpreting the sensor readings.
initial_tilt_angle = 0

pose_x                         = 0	// Camera position on the robot (meters)
pose_y                         = 0
pose_z                         = 0
pose_yaw                       = 0	// Angles in degrees
pose_pitch                     = 0
pose_roll                      = 0

# OpenNI2 sensor calibration:
# See http://www.mrpt.org/OpenNI2_and_MRPT

# Left/Depth camera
[RGBD1_LEFT]
rawlog-grabber-ignore = true // Instructs rawlog-grabber to ignore this section (it is not a separate device!)

resolution = [640 488]
cx         = 314.649173
cy         = 240.160459
fx         = 572.882768
fy         = 542.739980
dist       = [-4.747169e-03 -4.357976e-03 0.000000e+00 0.000000e+00 0.000000e+00]    // The order is: [K1 K2 T1 T2 K3]

# Right/RGB camera
[RGBD1_RIGHT]
rawlog-grabber-ignore = true // Instructs rawlog-grabber to ignore this section (it is not a separate device!)

resolution = [640 480]
cx         = 322.515987
cy         = 259.055966
fx         = 521.179233
fy         = 493.033034
dist       = [5.858325e-02 3.856792e-02 0.000000e+00 0.000000e+00 0.000000e+00]    // The order is: [K1 K2 T1 T2 K3]

# Relative pose of the right camera wrt to the left camera:
# This assumes that both camera frames are such that +Z points
# forwards, and +X and +Y to the right and downwards.
# For the actual coordinates employed in 3D observations, see figure in:
# http://reference.mrpt.org/svn/classmrpt_1_1slam_1_1_c_observation3_d_range_scan.html
[RGBD1_LEFT2RIGHT_POSE]
rawlog-grabber-ignore = true // Instructs rawlog-grabber to ignore this section (it is not a separate device!)

pose_quaternion      = [0.0 -0.000609 -0.001462 0.999987 0.0 0.0 0.0]


# =======================================================
#  SENSOR: OpenNI2
#   
# =======================================================
[RGBD2]
# ** IMPORTANT **: See the note on "rawlog_GZ_compress_level" above
driver                         = COpenNI2Sensor
process_rate                   = 200		// Hz (max)

device_number   = 1           // Device index to open (0:first OpenNI2, 1:second OpenNI2,...)
width 		= 320
height 		= 240
fps 		= 30

grab_decimation = 1    // Grab 1 out of N only.

sensorLabel  	= RGBD_1      // A text description
COM_port_WIN 	= COM3
COM_port_LIN 	= ttyUSB1
preview_window  = true        // Show a window with a preview of the grabbed data in real-time

grab_image      = true        // Grab the RGB image channel? (Default=true)
grab_depth      = true        // Grab the depth channel? (Default=true)
grab_3D_points  = true        // Grab the 3D point cloud? (Default=true) If disabled, points can be generated later on.

# Optional: Set the initial tilt angle of OpenNI2: upon initialization, the motor is sent a command to 
#            rotate to this angle (in degrees). Note: You must be aware of the tilt when interpreting the sensor readings.
initial_tilt_angle = 0

pose_x                         = 0	// Camera position on the robot (meters)
pose_y                         = 0
pose_z                         = 0
pose_yaw                       = 0	// Angles in degrees
pose_pitch                     = 0
pose_roll                      = 0

# OpenNI2 sensor calibration:
# See http://www.mrpt.org/OpenNI2_and_MRPT

# Left/Depth camera
[RGBD2_LEFT]
rawlog-grabber-ignore = true // Instructs rawlog-grabber to ignore this section (it is not a separate device!)

resolution = [640 488]
cx         = 314.649173
cy         = 240.160459
fx         = 572.882768
fy         = 542.739980
dist       = [-4.747169e-03 -4.357976e-03 0.000000e+00 0.000000e+00 0.000000e+00]    // The order is: [K1 K2 T1 T2 K3]

# Right/RGB camera
[RGBD2_RIGHT]
rawlog-grabber-ignore = true // Instructs rawlog-grabber to ignore this section (it is not a separate device!)

resolution = [640 480]
cx         = 322.515987
cy         = 259.055966
fx         = 521.179233
fy         = 493.033034
dist       = [5.858325e-02 3.856792e-02 0.000000e+00 0.000000e+00 0.000000e+00]    // The order is: [K1 K2 T1 T2 K3]

# Relative pose of the right camera wrt to the left camera:
# This assumes that both camera frames are such that +Z points
# forwards, and +X and +Y to the right and downwards.
# For the actual coordinates employed in 3D observations, see figure in:
# http://reference.mrpt.org/svn/classmrpt_1_1slam_1_1_c_observation3_d_range_scan.html
[RGBD2_LEFT2RIGHT_POSE]
rawlog-grabber-ignore = true // Instructs rawlog-grabber to ignore this section (it is not a separate device!)

pose_quaternion      = [0.0 -0.000609 -0.001462 0.999987 0.0 0.0 0.0]

