# Default parameter of vehicle_detection

#    ^-x
#    |
#    |
#    m0
#    /\
#   /  \
#m1/_00_\m2_________> y
# Fahrtrichtung nach untern
debug_level: 0b11100000000000 # controlls the published debug image
debug_dt_visual_scaleing: 15 # multiplicates the drawen velocity/yaw rate with this factor. Make it {1,20} for {fast,slow} moveing car.

acc_x_abs_max: 5.0 # meter/sec
acc_y_abs_max: 1.0 # meter/sec
acc_yaw_abs_max: 0.35 # rad/sec

marker_0_radius: 0.0395 # meter hintere Kugel m0
marker_1_radius: 0.06 # meter Kugel m1 in Fahrtrichtung rechts
marker_2_radius: 0.06 # meter Kugel m2 in Fahrtrichtung links
marker_0_to_car_x: 0.1903 # meter
marker_1_to_car_x: 0 # meter
marker_2_to_car_x: 0 # meter
marker_0_to_car_y: 0 # meter
marker_1_to_car_y: 0.17315 # meter
marker_2_to_car_y: -0.18815 # meter
marker_triangle_pose_yaw_2_car_pose: deg(0.0) # how much the triangle y-axis is rotated rellative to vehicle x-axis

hough_radius_search_tolerance_pix: 2 #pixel
hough_blur: 5 # medianBlur pixel value before hough trafo. If you dont want to blur, set it negative
hough_canny_max_threshold: 1.01 # 1.10 # upper trashold for canny-edge-detector !!! mean_greyimage * hough_canny_max_trashold
hough_canny_min_threshold: 0.99 # 0.80 # lower trashold for canny-edge-detector !!! mean_greyimage * hough_canny_min_trashold

contour_radius_search_tolerance_pix: 1.8 #1.5 #pixel
contour_ellipse_min_ratio_minor_mayor_axis: 0.1 #0.2 #0.3 # 1=circle ratio minor/major ayis found ellipse
contour_contrast: 5 # 5 seems to be good
contour_brightness: -120 # dimm the noise amplified from contrast
contour_threshold: 100

blob_radius_search_tolerance_pix: 1.8 #1.5 #pixel
blob_max_threshold: 255 # gray value to end search for blob.
blob_min_threshold: 30 # gray value to begin search for blob. can be low as 30 for dark rosbags!
blob_threshold_step: 5 # 5 - 10
blob_min_repeatability: 5 # 2 - 10 -> blobs must differ min_repeatability in threshold_step gray values to sourrounding
blob_filter_by_inertia: true
blob_min_inertia: 0.1 # how elliptical it is, compare with contour_ellipse_min_ratio_minor_mayor_axis
blob_filter_by_convexity: true
blob_min_convexity: 0.75 # 0.3 - 0.8
blob_filter_by_circularity: false # circularity = 4∗π∗Area / (perimeter∗perimeter)
blob_min_circularity: 0.5 # 1 => only true circles. 0.5 seems to be a good compromiss
blob_filter_by_color: true
blob_color: 255 # they have either black blobs = 0, or white blobs = 255


template_methode: 2 #https://docs.opencv.org/2.4/modules/imgproc/doc/object_detection.html?highlight=matchtemplate#matchtemplate 0: CV_TM_SQDIFF, 1: CV_TM_SQDIFF_NORMED, 2: CV_TM_CCORR, 3: CV_TM_CCORR_NORMED, 4: CV_TM_CCOEFF, 5: CV_TM_CCOEFF_NORMED
template_match_threshold: 0.5 #0.96 # 0 - 1
template_mean_diff_threshold: 25 # 0 - 255

transformation_guard_threshold: 15 # pixel
multiple_variance_for_search_frame: 2 # the size of the searchframe rellative to the variance of the system
init: {
  triangle_max_fit_error_radius: 0.8,  # no false negative: 0.8  # no false positive: 0.015  # best trade of: 0.053  # meter max error of radius difference for fitting triangle to marker-triangle
  triangle_max_fit_error_angles: 0.25,  # no false negative: 0.495  # no false positive: 0.089  # best trade of: 0.3    # rad max error of summ of angle differences for fitting triangle to marker-triangle
  triangle_max_fit_error_sides: 0.1,  # no false negative: 0.146  # no false positive: 0.035  # best trade of: 0.13   # meter max error of summ of sides differences for fitting triangle to marker-triangle
  triangle_max_fit_error_outline: 0.1, # no false negative: 0.146  # no false positive: 0.035  # best trade of: 0.13   # meter max error of outline difference for fitting triangle to marker-triangle
  triangle_max_fit_error_area: 0.008    # no false negative: 0.013  # no false positive: 0.0007 # best trade of: 0.01   # meter max error of outline difference for fitting triangle to marker-triangle
}
kalman: {
  system_noise_sd: {
    position: 1,  # meter
    velocity: 10, # meter/sec
    acceleration: 500, # meter/sec²
    yaw_deg: 700, # deg
    yaw_rate_deg: 6000 #deg/sec
  },
  measurement_noise_sd: {
    # position needs at least 1 marker to be calculated. 2 Are more stable. 3 would be perfect
    position_3_marker: 0.0001, # meter
    position_2_marker: 0.01,  # meter
    position_1_marker: 0.075,   # meter should be somewhat equal or higher to system position noise since one marker is not realy stable and could ruin the stateestimation if wron and trusted too much
    # yaw needs at least 2 marker to be calculated. 3 Are more stable.
    yaw_3_marker_deg: 0.2,  # deg
    yaw_2_marker_deg: 5.0,   # deg
    yaw_1_marker_deg: 360, # deg (basicly a high value, we have no measurement. So should be higher than system yaw position)
  }
}
