param_dynreconf_client.py
Go to the documentation of this file.
00001 # Software License Agreement (BSD License)
00002 #
00003 # Copyright (c) 2012, Willow Garage, Inc.
00004 # All rights reserved.
00005 #
00006 # Redistribution and use in source and binary forms, with or without
00007 # modification, are permitted provided that the following conditions
00008 # are met:
00009 #
00010 #  * Redistributions of source code must retain the above copyright
00011 #    notice, this list of conditions and the following disclaimer.
00012 #  * Redistributions in binary form must reproduce the above
00013 #    copyright notice, this list of conditions and the following
00014 #    disclaimer in the documentation and/or other materials provided
00015 #    with the distribution.
00016 #  * Neither the name of Willow Garage, Inc. nor the names of its
00017 #    contributors may be used to endorse or promote products derived
00018 #    from this software without specific prior written permission.
00019 #
00020 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 # POSSIBILITY OF SUCH DAMAGE.
00032 #
00033 # Author: Isaac Saito, Ze'ev Klapow
00034 
00035 import dynamic_reconfigure.client
00036 import rospy
00037 
00038 from .param_editors import EditorWidget, BooleanEditor, DoubleEditor, EnumEditor, IntegerEditor, StringEditor
00039 from .param_groups import GroupWidget
00040 from .param_updater import ParamUpdater 
00041 
00042 class ClientWidget(GroupWidget):
00043     """
00044     A wrapper of dynamic_reconfigure.client instance.
00045     Represents the pane on right side where you modify params.
00046     """
00047         
00048     def __init__(self, reconf):
00049         """
00050         @type reconf: dynamic_reconfigure.client.
00051         """ 
00052     
00053         super(ClientWidget, self).__init__(ParamUpdater(reconf),
00054                                            reconf.get_group_descriptions())
00055 
00056         self.setMinimumWidth(150)
00057 
00058         self.reconf = reconf
00059 
00060         self.updater.start()
00061         self.reconf.config_callback = self.config_callback
00062 
00063     def config_callback(self, config):
00064         if config is not None:
00065             # TODO: should use config.keys but this method doesnt exist
00066             names = [name for name, v in config.items()]
00067 
00068             for widget in self.editor_widgets:
00069                 if isinstance(widget, EditorWidget):
00070                     if widget.name in names:
00071                         rospy.logdebug('EDITOR widget.name=%s', widget.name)
00072                         widget.update_value(config[widget.name])
00073                 elif isinstance(widget, GroupWidget):
00074                     cfg = find_cfg(config, widget.name)
00075                     rospy.logdebug('GROUP widget.name=%s', widget.name)
00076                     widget.update_group(cfg)
00077                 
00078     def close(self):
00079         self.reconf.close()
00080         self.updater.stop()
00081 
00082         for w in self.editor_widgets:
00083             w.close()
00084 
00085         self.deleteLater()


rqt_param
Author(s): Isaac Saito, Ze'ev Klapow
autogenerated on Fri Jan 3 2014 11:57:01