35 from __future__
import division
40 import dynamic_reconfigure.client
42 from python_qt_binding.QtCore
import Qt
43 from python_qt_binding.QtGui
import QBrush, QStandardItem
45 from rospy.exceptions
import ROSException
50 from .dynreconf_client_widget
import DynreconfClientWidget
56 super(ParamserverConnectThread, self).
__init__()
61 dynreconf_client =
None 63 dynreconf_client = dynamic_reconfigure.client.Client(
66 'ParamserverConnectThread dynreconf_client={}'.format(
69 self._parent.set_dynreconf_client(dynreconf_client)
70 except ROSException
as e:
72 e.message +
"TreenodeQstdItem. Couldn't connect to {}".format(
79 Extending ReadonlyItem - the display content of this item shouldn't be 87 :param args[0]: str (will become 1st arg of QStandardItem) 88 :param args[1]: integer value that indicates whether this class 89 is node that has GRN (Graph Resource Names, see 90 http://www.ros.org/wiki/Names). This can be None 92 grn_current_treenode = args[0]
95 super(TreenodeQstdItem, self).
__init__(grn_current_treenode)
111 logging.error(
'TreenodeQstdItem IndexError')
115 @param dynreconf_client: dynamic_reconfigure.client.Client 118 logging.debug(
'Qitem set dynreconf_client={} param={}'.format(
124 self._dynreconf_client.close()
130 @rtype: DynreconfClientWidget (QWidget) 131 @return: None if dynreconf_client is not yet generated. 135 logging.debug(
'get dynreconf_client={}'.format(
138 logging.debug(
'In get_dynreconf_widget 1')
141 logging.debug(
'In get_dynreconf_widget 2')
151 self.setEnabled(
False)
152 raise ROSException(
'dynreconf client failed')
156 logging.debug(
'In get_dynreconf_widget loop#{}'.format(loop))
158 logging.debug(
'In get_dynreconf_widget 4')
166 self._dynreconfclient_widget.destroyed.connect(
168 self._dynreconfclient_widget.destroyed.connect(
170 logging.debug(
'In get_dynreconf_widget 5')
181 Connect to parameter server using dynamic_reconfigure client. 182 Behavior is delegated to a private method _connect_param_server, and 183 its return value, client, is set to member variable. 191 logging.error(
'connect_param_server failed due to missing ' 192 'ROS Node. Return with nothing.')
197 if self._paramserver_connect_thread.isAlive():
198 self._paramserver_connect_thread.join(1)
201 self._paramserver_connect_thread.start()
207 if self._paramserver_connect_thread.isAlive():
208 self._paramserver_connect_thread.join(1)
215 Create QStdItem per parameter and addColumn them to myself. 216 :rtype: None if _dynreconf_client is not initiated. 220 param_names = self._dynreconfclient_widget.get_treenode_names()
221 param_names_items = []
222 brush = QBrush(Qt.lightGray)
223 for param_name
in param_names:
225 item.setBackground(brush)
226 param_names_items.append(item)
227 logging.debug(
'enable_param_items len of paramnames={}'.format(
228 len(param_names_items)
230 self.appendColumn(param_names_items)
234 :param param_name: A string formatted as GRN (Graph Resource Names, see 235 http://www.ros.org/wiki/Names). 236 Example: /paramname/subpara/subsubpara/... 238 logging.debug(
'_set_param_name param_name={} '.format(param_name))
248 logging.debug(
'paramname={} nodename={} _list_params[-1]={}'.format(
255 :rtype: String of the top level param name. 257 return self._name_top
264 :rtype: List of string. Null if param 271 :return: A value of single tree node (ie. NOT the fullpath node name). 272 Ex. suppose fullpath name is /top/sub/subsub/subsubsub and you 273 are at 2nd from top, the return value is subsub. 278 return QStandardItem.UserType