diff --git a/workspace/.catkin_tools/profiles/default/devel_collisions.txt b/workspace/.catkin_tools/profiles/default/devel_collisions.txt index 881f52a..1b9af23 100644 --- a/workspace/.catkin_tools/profiles/default/devel_collisions.txt +++ b/workspace/.catkin_tools/profiles/default/devel_collisions.txt @@ -1 +1 @@ -/home/klafyvel/Documents/supelec/2A/projet/workspace/devel/./cmake.lock 88 +/home/klafyvel/Documents/supelec/2A/projet/workspace/devel/./cmake.lock 89 diff --git a/workspace/devel/.private/detect_targets/include/detect_targets/DetectTargetsConfig.h b/workspace/devel/.private/detect_targets/include/detect_targets/DetectTargetsConfig.h index 4f4775e..07a0c3a 100644 --- a/workspace/devel/.private/detect_targets/include/detect_targets/DetectTargetsConfig.h +++ b/workspace/devel/.private/detect_targets/include/detect_targets/DetectTargetsConfig.h @@ -236,17 +236,21 @@ class DEFAULT boost::any val; (*_i)->getValue(config, val); - if("blue"==(*_i)->name){blue = boost::any_cast(val);} - if("red"==(*_i)->name){red = boost::any_cast(val);} - if("green"==(*_i)->name){green = boost::any_cast(val);} - if("draw_targets"==(*_i)->name){draw_targets = boost::any_cast(val);} + if("blue_min"==(*_i)->name){blue_min = boost::any_cast(val);} + if("blue_max"==(*_i)->name){blue_max = boost::any_cast(val);} + if("red_min"==(*_i)->name){red_min = boost::any_cast(val);} + if("red_max"==(*_i)->name){red_max = boost::any_cast(val);} + if("green_min"==(*_i)->name){green_min = boost::any_cast(val);} + if("green_max"==(*_i)->name){green_max = boost::any_cast(val);} } } - int blue; -int red; -int green; -bool draw_targets; + int blue_min; +int blue_max; +int red_min; +int red_max; +int green_min; +int green_max; bool state; std::string name; @@ -257,13 +261,17 @@ bool draw_targets; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - int blue; + int blue_min; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - int red; + int blue_max; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - int green; + int red_min; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - bool draw_targets; + int red_max; +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + int green_min; +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + int green_max; //#line 228 "/opt/ros/melodic/share/dynamic_reconfigure/cmake/../templates/ConfigType.h.template" bool __fromMessage__(dynamic_reconfigure::Config &msg) @@ -403,45 +411,65 @@ bool draw_targets; { DetectTargetsConfig::GroupDescription Default("Default", "", 0, 0, true, &DetectTargetsConfig::groups); //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __min__.blue = 0; + __min__.blue_min = 0; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __max__.blue = 255; + __max__.blue_min = 255; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __default__.blue = 140; + __default__.blue_min = 140; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("blue", "int", 0, "Blue threshold", "", &DetectTargetsConfig::blue))); + Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("blue_min", "int", 0, "Blue minimal threshold", "", &DetectTargetsConfig::blue_min))); //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("blue", "int", 0, "Blue threshold", "", &DetectTargetsConfig::blue))); + __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("blue_min", "int", 0, "Blue minimal threshold", "", &DetectTargetsConfig::blue_min))); //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __min__.red = 0; + __min__.blue_max = 0; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __max__.red = 255; + __max__.blue_max = 255; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __default__.red = 120; + __default__.blue_max = 255; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("red", "int", 0, "Bed threshold", "", &DetectTargetsConfig::red))); + Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("blue_max", "int", 0, "Blue maximal threshold", "", &DetectTargetsConfig::blue_max))); //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("red", "int", 0, "Bed threshold", "", &DetectTargetsConfig::red))); + __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("blue_max", "int", 0, "Blue maximal threshold", "", &DetectTargetsConfig::blue_max))); //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __min__.green = 0; + __min__.red_min = 0; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __max__.green = 255; + __max__.red_min = 255; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __default__.green = 190; + __default__.red_min = 0; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("green", "int", 0, "Green threshold", "", &DetectTargetsConfig::green))); + Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("red_min", "int", 0, "Red minimal threshold", "", &DetectTargetsConfig::red_min))); //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("green", "int", 0, "Green threshold", "", &DetectTargetsConfig::green))); + __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("red_min", "int", 0, "Red minimal threshold", "", &DetectTargetsConfig::red_min))); //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __min__.draw_targets = 0; + __min__.red_max = 0; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __max__.draw_targets = 1; + __max__.red_max = 255; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __default__.draw_targets = 0; + __default__.red_max = 120; //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("draw_targets", "bool", 0, "Draw Targets", "", &DetectTargetsConfig::draw_targets))); + Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("red_max", "int", 0, "Red maximal threshold", "", &DetectTargetsConfig::red_max))); //#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" - __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("draw_targets", "bool", 0, "Draw Targets", "", &DetectTargetsConfig::draw_targets))); + __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("red_max", "int", 0, "Red maximal threshold", "", &DetectTargetsConfig::red_max))); +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + __min__.green_min = 0; +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + __max__.green_min = 255; +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + __default__.green_min = 0; +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("green_min", "int", 0, "Green minimal threshold", "", &DetectTargetsConfig::green_min))); +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("green_min", "int", 0, "Green minimal threshold", "", &DetectTargetsConfig::green_min))); +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + __min__.green_max = 0; +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + __max__.green_max = 255; +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + __default__.green_max = 190; +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + Default.abstract_parameters.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("green_max", "int", 0, "Green maximal threshold", "", &DetectTargetsConfig::green_max))); +//#line 291 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" + __param_descriptions__.push_back(DetectTargetsConfig::AbstractParamDescriptionConstPtr(new DetectTargetsConfig::ParamDescription("green_max", "int", 0, "Green maximal threshold", "", &DetectTargetsConfig::green_max))); //#line 246 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" Default.convertParams(); //#line 246 "/opt/ros/melodic/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator_catkin.py" diff --git a/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig-usage.dox b/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig-usage.dox index 3b06437..e787e40 100644 --- a/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig-usage.dox +++ b/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig-usage.dox @@ -1,10 +1,12 @@ \subsubsection usage Usage \verbatim - - - - + + + + + + \endverbatim diff --git a/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig.dox b/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig.dox index 4536d61..07e4021 100644 --- a/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig.dox +++ b/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig.dox @@ -2,8 +2,10 @@ Reads and maintains the following parameters on the ROS server -- \b "~blue" : \b [int] Blue threshold min: 0, default: 140, max: 255 -- \b "~red" : \b [int] Bed threshold min: 0, default: 120, max: 255 -- \b "~green" : \b [int] Green threshold min: 0, default: 190, max: 255 -- \b "~draw_targets" : \b [bool] Draw Targets min: False, default: False, max: True +- \b "~blue_min" : \b [int] Blue minimal threshold min: 0, default: 140, max: 255 +- \b "~blue_max" : \b [int] Blue maximal threshold min: 0, default: 255, max: 255 +- \b "~red_min" : \b [int] Red minimal threshold min: 0, default: 0, max: 255 +- \b "~red_max" : \b [int] Red maximal threshold min: 0, default: 120, max: 255 +- \b "~green_min" : \b [int] Green minimal threshold min: 0, default: 0, max: 255 +- \b "~green_max" : \b [int] Green maximal threshold min: 0, default: 190, max: 255 diff --git a/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig.wikidoc b/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig.wikidoc index 7481af6..f2a4a78 100644 --- a/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig.wikidoc +++ b/workspace/devel/.private/detect_targets/share/detect_targets/docs/DetectTargetsConfig.wikidoc @@ -3,22 +3,30 @@ param { group.0 { name=Dynamically Reconfigurable Parameters desc=See the [[dynamic_reconfigure]] package for details on dynamically reconfigurable parameters. -0.name= ~blue +0.name= ~blue_min 0.default= 140 0.type= int -0.desc=Blue threshold Range: 0 to 255 -1.name= ~red -1.default= 120 +0.desc=Blue minimal threshold Range: 0 to 255 +1.name= ~blue_max +1.default= 255 1.type= int -1.desc=Bed threshold Range: 0 to 255 -2.name= ~green -2.default= 190 +1.desc=Blue maximal threshold Range: 0 to 255 +2.name= ~red_min +2.default= 0 2.type= int -2.desc=Green threshold Range: 0 to 255 -3.name= ~draw_targets -3.default= False -3.type= bool -3.desc=Draw Targets +2.desc=Red minimal threshold Range: 0 to 255 +3.name= ~red_max +3.default= 120 +3.type= int +3.desc=Red maximal threshold Range: 0 to 255 +4.name= ~green_min +4.default= 0 +4.type= int +4.desc=Green minimal threshold Range: 0 to 255 +5.name= ~green_max +5.default= 190 +5.type= int +5.desc=Green maximal threshold Range: 0 to 255 } } # End of autogenerated section. You may edit below. diff --git a/workspace/src/detect_targets/cfg/DetectTargets.cfg b/workspace/src/detect_targets/cfg/DetectTargets.cfg index 489a1d3..865d084 100755 --- a/workspace/src/detect_targets/cfg/DetectTargets.cfg +++ b/workspace/src/detect_targets/cfg/DetectTargets.cfg @@ -5,9 +5,11 @@ from dynamic_reconfigure.parameter_generator_catkin import * gen = ParameterGenerator() -gen.add("blue", int_t, 0, "Blue threshold", 140, 0, 255) -gen.add("red", int_t, 0, "Bed threshold", 120, 0, 255) -gen.add("green", int_t, 0, "Green threshold", 190, 0, 255) -gen.add("draw_targets", bool_t, 0, "Draw Targets", False) +gen.add("blue_min", int_t, 0, "Blue minimal threshold", 140, 0, 255) +gen.add("blue_max", int_t, 0, "Blue maximal threshold", 255, 0, 255) +gen.add("red_min", int_t, 0, "Red minimal threshold", 0, 0, 255) +gen.add("red_max", int_t, 0, "Red maximal threshold", 120, 0, 255) +gen.add("green_min", int_t, 0, "Green minimal threshold", 0, 0, 255) +gen.add("green_max", int_t, 0, "Green maximal threshold", 190, 0, 255) exit(gen.generate(PACKAGE, "detect_targets", "DetectTargets")) diff --git a/workspace/src/detect_targets/scripts/find_targets.py b/workspace/src/detect_targets/scripts/find_targets.py index ab2c03f..d392c4f 100644 --- a/workspace/src/detect_targets/scripts/find_targets.py +++ b/workspace/src/detect_targets/scripts/find_targets.py @@ -27,18 +27,15 @@ def normalize_coordinates(p, w, h): def find_targets( - picture, threshold_blue=140, threshold_red=120, - threshold_green=190, return_slices=False): + picture, threshold_blue=(140, 255), threshold_red=(0, 120), + threshold_green=(0, 190), return_slices=False): """Find three blue targets in the given picture (RGB matrix). Args: picture: a 2D matrix of RGB values - threshold_blue: minimal value of the blue channel for a point to be - considered as blue. - threshold_red: maximal value of the red channel allowed for a - target - threshold_green: maximal value of the green channel allowed for a - target + threshold_blue: interval of allowed values for blue channel. + threshold_red: interval of allowed values for red channel + threshold_green: interval of allowed values for green channel return_slices: Boolean stating if the slices locating the targets should be returned. @@ -50,9 +47,12 @@ def find_targets( """ blue_points = np.where( - (picture[:, :, 2] > threshold_blue) - & (picture[:, :, 0] < threshold_red) - & (picture[:, :, 1] < threshold_green), + (threshold_red[0] <= picture[:, :, 0]) + & (picture[:, :, 0] <= threshold_red[1]) + & (threshold_green[0] <= picture[:, :, 1]) + & (picture[:, :, 1] <= threshold_green[1]) + & (threshold_blue[0] <= picture[:, :, 2]) + & (picture[:, :, 2] <= threshold_blue[1]), 1, 0 ) @@ -97,6 +97,6 @@ def find_targets( R = tuple(reversed(sides[-1])) if return_slices: - return H, L, R, [(o[0], o[1]) for o in objects] + return H, L, R, ((o[0], o[1]) for o in objects) else: return H, L, R diff --git a/workspace/src/detect_targets/scripts/find_targets.pyc b/workspace/src/detect_targets/scripts/find_targets.pyc index b951caa..0e9b04d 100644 Binary files a/workspace/src/detect_targets/scripts/find_targets.pyc and b/workspace/src/detect_targets/scripts/find_targets.pyc differ diff --git a/workspace/src/detect_targets/scripts/target_publisher.py b/workspace/src/detect_targets/scripts/target_publisher.py index fcab8cf..afa3daf 100755 --- a/workspace/src/detect_targets/scripts/target_publisher.py +++ b/workspace/src/detect_targets/scripts/target_publisher.py @@ -13,22 +13,20 @@ from detect_targets.cfg import DetectTargetsConfig class Publisher: def __init__(self): - self.threshold_blue = 140 - self.threshold_red = 120 - self.threshold_green = 190 + self.threshold_blue = (140, 255) + self.threshold_red = (0, 120) + self.threshold_green = (0, 190) self.centers = component_centers() self.pub = rospy.Publisher('targets', component_centers, queue_size=10) self.img_pub = rospy.Publisher('img_targets', Image, queue_size=0) rospy.Subscriber("/bebop/image_raw", Image, self.on_picture) self.bridge = CvBridge() self.config_srv = dynamic_reconfigure.server.Server(DetectTargetsConfig, self.on_reconf) - self.draw_targets = False def on_reconf(self, config, level): - self.threshold_red = config['red'] - self.threshold_blue = config['blue'] - self.threshold_green = config['green'] - self.draw_targets = config['draw_targets'] + self.threshold_red = (config['red_min'], config['red_max']) + self.threshold_blue = (config['blue_min'], config['blue_max']) + self.threshold_green = (config['green_min'], config['green_max']) return config def on_picture(self, msg): diff --git a/workspace/src/detect_targets/scripts/test_find_targets.py b/workspace/src/detect_targets/scripts/test_find_targets.py index b16cc7b..03cce60 100644 --- a/workspace/src/detect_targets/scripts/test_find_targets.py +++ b/workspace/src/detect_targets/scripts/test_find_targets.py @@ -1,3 +1,4 @@ +# coding: utf-8 import matplotlib.pyplot as pl from matplotlib.patches import Rectangle @@ -26,7 +27,7 @@ L = normalize_coordinates(L, w, h) R = normalize_coordinates(R, w, h) ax.plot([H[0], L[0], R[0]], [H[1], L[1], R[1]], 'o', color='red') ax.grid() -ax.set_title("Positions normalisées") +ax.set_title(u"Positions normalisées") pl.show()