#!/usr/bin/env python
"""
Add your desired parameters here. All required headers will be generated from this.
!!!IMPORTANT this file must be executable !!!

Use one of these commands to add parameters to your parameter struct:

def add(self, name, paramtype, description, level=0, edit_method='""', default=None, min=None, max=None, configurable=False, global_scope=False, constant=False):
        Adds parameters to your parameter struct.

def add_enum(self, name, description, entry_strings, default=None, paramtype='int'):
        Adds an enum to dynamic reconfigure

def add_group(self, name):
        Create a parameter group for the dynamic_reconfigure window

def add_publisher(self, name, message_type, description, default_topic=None, default_queue_size=5, topic_param=None,
                  queue_size_param=None, header=None, module=None, configurable=False, scope="private",
                  constant=False, diagnosed=False, min_frequency=0., min_frequency_param=None, max_delay=float('inf'),
                  max_delay_param=None):
        Adds an initialized publisher to your parameter struct and parameter for its topic and queue size.
        Diagnosed publishers require the line: gen.add_diagnostic_updater().


def add_subscriber(self, name, message_type, description, default_topic=None, default_queue_size=5, no_delay=False,
                   topic_param=None, queue_size_param=None, header=None, module=None, configurable=False,
                   scope='private', constant=False, diagnosed=False, min_frequency=0., min_frequency_param=None,
                   max_delay=float('inf'), max_delay_param=None):
        Adds an initialized subscriber to your parameter struct and parameters for topic and queue size.
        Diagnosed subscribers require the line: gen.add_diagnostic_updater().


For more information on the API, see here: https://gitlab.mrt.uni-karlsruhe.de/MRT/rosinterface_handler/blob/master/doc/HowToWriteYourFirstInterfaceFile.md
"""
from rosinterface_handler.interface_generator_catkin import *

gen = InterfaceGenerator()

# Add a parameter for changing verbosity (=log level) on the fly
gen.add_verbosity_param(configurable=True)

# Your Params here

gen.add("timer_rate", paramtype='double', description="publisher frequency", default=50, min=0, max=100, configurable=True, global_scope=False)
gen.add("path_to_ground_depth", paramtype='std::string', description="directory to image file", default="")
gen.add("map_area_max_x", paramtype='double', description="max x value of map area", default=12.0, min=-1, max=15, configurable=True, global_scope=False)
gen.add("map_area_min_x", paramtype='double', description="min x value of map area", default=0.4, min=-1, max=15, configurable=True, global_scope=False)
gen.add("map_area_max_y", paramtype='double', description="max y value of map area", default=6.2, min=-1, max=7, configurable=True, global_scope=False)
gen.add("map_area_min_y", paramtype='double', description="min y value of map area", default=-0.4, min=-1, max=7, configurable=True, global_scope=False)
gen.add("map_area_max_z", paramtype='double', description="max z value of map area", default=1.0, min=-1, max=5, configurable=True, global_scope=False)
gen.add("map_area_min_z", paramtype='double', description="min z value of map area", default=0.05, min=-1, max=5, configurable=True, global_scope=False)
gen.add("min_detect_distance",paramtype = 'double', description="min detect distance of obstacle", default=1.6, min=1.0,max=3.0,configurable=True, global_scope=False)
gen.add("min_detect_area",paramtype = 'double', description="min detect area of obstacle", default=1.0, min=1.0,max=5.0,configurable=True, global_scope=False)
gen.add("min_procent",paramtype = 'double', description="min procent of white area", default=0.6, min=0.0,max=1.0,configurable=True, global_scope=False)
gen.add("min_h", paramtype='int', description="min h value of hsv image", default=0, min=0, max=255, configurable=True, global_scope=False)
gen.add("max_h", paramtype='int', description="max h value of hsv image", default=180, min=0, max=255, configurable=True, global_scope=False)
gen.add("min_s", paramtype='int', description="min s value of hsv image", default=0, min=0, max=255, configurable=True, global_scope=False)
gen.add("max_s", paramtype='int', description="max s value of hsv image", default=43, min=0, max=255, configurable=True, global_scope=False)
gen.add("min_v", paramtype='int', description="min v value of hsv image", default=135, min=0, max=255, configurable=True, global_scope=False)
gen.add("max_v", paramtype='int', description="max v value of hsv image", default=255, min=0, max=255, configurable=True, global_scope=False)
gen.add("opening_times", paramtype='int', description="times of opening calculation", default=7, min=1, max=10, configurable=True, global_scope=False)
gen.add("opening_filter_size", paramtype='int', description="the size of opening elemnt", default=3, min=1, max=20, configurable=True, global_scope=False)

gen.add("ir_focal_length", paramtype='double', description="focal length of kinect", default=540.686, configurable=False, global_scope=False)
gen.add("ir_u0", paramtype='double', description="u0", default=479.75, configurable=False, global_scope=False)
gen.add("ir_v0", paramtype='double', description="v0", default=269.75, configurable=False, global_scope=False)


# Frames
frame = gen.add_group("Frames")
frame.add("kinect_ir_frame", paramtype="std::string", description="frame id", default="kinect2_ir_optical_frame", configurable=False)
frame.add("world_frame", paramtype="std::string", description="frame id", default="world", configurable=False)


# Publisher and subscriber (group name will show up in dynamic_reconfigure window)
pub_sub = gen.add_group("Publisher and subscriber")
pub_sub.add_subscriber("dummy_subscriber", message_type="std_msgs::Header", description="example subscriber", default_topic="in_topic", no_delay=True, configurable=True)
pub_sub.add_publisher("dummy_publisher", message_type="std_msgs::Header", description="example publisher", default_topic="out_topic", configurable=True)

# DO NOT TOUCH THIS LINE
#Syntax : Package, Node, Config Name(The final name will be ObstacleDetectionConfig)
exit(gen.generate("neverdrive_obstacle_detection_ros_tool", "obstacle_detection", "ObstacleDetection"))
