6 import vigir_footstep_planning_msgs.msg
8 from python_qt_binding.QtCore
import Qt, QSize, Signal, Slot
9 from python_qt_binding.QtGui
import QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QComboBox, QIcon
11 from vigir_generic_params.msg
import GetParameterSetNamesAction, GetParameterSetNamesGoal, GetParameterSetNamesResult
19 topic_changed_signal = Signal(str)
20 param_cleared_signal = Signal()
21 param_changed_signal = Signal(str)
23 def __init__(self, parent=None, logger=Logger()):
24 QWidgetWithLogger.__init__(self, parent, logger)
29 vbox.setContentsMargins(0, 0, 0, 0)
32 topic_widget =
QTopicWidget(self,
'vigir_generic_params/GetParameterSetNamesAction',
True)
33 vbox.addWidget(topic_widget)
37 self.parameter_set_selection_widget.param_cleared_signal.connect(self.
param_cleared)
38 self.parameter_set_selection_widget.param_changed_signal.connect(self.
param_changed)
40 topic_widget.topic_changed_signal.connect(self.parameter_set_selection_widget.set_topic_name)
47 topic_widget.emit_topic_name()
50 return self.parameter_set_selection_widget.current_parameter_set_name()
54 self.topic_changed_signal.emit(name)
58 self.param_cleared_signal.emit()
62 self.param_changed_signal.emit(name)
68 NO_PARAM_SET_TEXT =
"No parameters available!" 69 SELECT_TEXT =
"<Select>" 71 param_cleared_signal = Signal()
72 param_changed_signal = Signal(str)
74 def __init__(self, parent=None, logger=Logger()):
75 QWidgetWithLogger.__init__(self, parent, logger)
80 hbox.setContentsMargins(0, 0, 0, 0)
83 icon = QIcon.fromTheme(
"view-refresh")
84 size = icon.actualSize(QSize(32, 32))
88 self.parameter_set_names_combo_box.currentIndexChanged[str].connect(self.
param_changed)
95 self.get_all_parameter_set_names_button.setIcon(icon)
96 self.get_all_parameter_set_names_button.setFixedSize(size.width()+2, size.height()+2)
108 print "Parameter set topic changed: " + topic_name
112 if len(topic_name) > 0:
119 self.parameter_set_names_combo_box.setEnabled(
False)
120 self.parameter_set_names_combo_box.blockSignals(
True)
121 self.parameter_set_names_combo_box.clear()
123 self.get_all_parameter_set_names_button.setEnabled(
False)
124 self.param_cleared_signal.emit()
130 return self.parameter_set_names_combo_box.currentText()
134 self.param_changed_signal.emit(name)
138 if self.get_parameter_set_names_client.wait_for_server(rospy.Duration(0.5)):
139 self.logger.log_info(
"Requesting current list of parameter set names.")
140 goal = GetParameterSetNamesGoal()
141 self.get_parameter_set_names_client.send_goal(goal)
144 if self.get_parameter_set_names_client.wait_for_result(rospy.Duration(1.0)):
145 result = self.get_parameter_set_names_client.get_result()
147 self.logger.log_info(
"Received " + str(len(result.names)) +
" parameter set names.")
149 self.parameter_set_names_combo_box.blockSignals(
True)
150 self.parameter_set_names_combo_box.clear()
151 self.parameter_set_names_combo_box.addItem(self.
SELECT_TEXT)
152 self.parameter_set_names_combo_box.setItemData(0, 0, Qt.UserRole-1)
153 self.param_cleared_signal.emit()
155 for name
in result.names:
156 self.parameter_set_names_combo_box.addItem(name.data)
158 self.parameter_set_names_combo_box.setEnabled(
True)
159 self.parameter_set_names_combo_box.blockSignals(
False)
160 self.get_all_parameter_set_names_button.setEnabled(
True)
162 self.logger.log_error(
"Didn't received any results. Check communcation!")
165 self.logger.log_error(
"Can't connect to footstep planner parameter action server!")