6 import vigir_footstep_planning_msgs.msg
9 from python_qt_binding.QtCore
import Qt
10 from python_qt_binding.QtGui
import QWidget, QSplitter, QVBoxLayout, QPushButton
12 from vigir_generic_params.msg
import SetParameterSetAction, SetParameterSetGoal, GetParameterSetAction, GetParameterSetGoal, GetParameterSetResult
13 from vigir_footstep_planning_msgs.msg
import ErrorStatus
26 super(ParameterEditorDialog, self).
__init__(context)
27 self.setObjectName(
'ParameterEditorDialog')
32 context.add_widget(self.
_parent)
35 self._widget.shutdown_plugin()
41 super(ParameterEditorWidget, self).
__init__()
54 vsplitter = QSplitter()
55 vsplitter.setOrientation(Qt.Vertical)
56 vsplitter.setChildrenCollapsible(
False)
60 add_widget_with_frame(vsplitter, parameter_editor_widget,
"Editor:")
63 add_widget_with_frame(vsplitter, error_status_widget,
"Status:")
66 vbox.addWidget(vsplitter)
69 widget.setLayout(vbox)
73 self.parameter_set_widget.topic_changed_signal.connect(parameter_editor_widget.set_get_parameter_set_topic_name)
74 self.parameter_set_widget.param_changed_signal.connect(parameter_editor_widget.load_parameters)
75 self.parameter_set_widget.param_cleared_signal.connect(parameter_editor_widget.clear)
78 print "Shutting down ..." 84 parameter_set_name = str()
86 def __init__(self, parent=None, logger=Logger()):
87 QWidgetWithLogger.__init__(self, parent, logger)
92 vbox.setContentsMargins(0, 0, 0, 0)
99 vbox_commands = QVBoxLayout()
103 send_parameter_topic_widget =
QTopicWidget(self,
'vigir_footstep_planning_msgs/SetParameterSetAction',
True)
105 hbox.addWidget(send_parameter_topic_widget)
111 vbox_commands.addLayout(hbox)
119 vbox.addLayout(vbox_commands)
126 send_parameter_topic_widget.emit_topic_name()
131 print "Parameter set topic changed: " + topic_name
135 if len(topic_name) > 0:
136 print "Upload parameter set topic changed: " + topic_name
142 if len(topic_name) > 0:
148 self.upload_command.setEnabled(
False)
149 self.reload_command.setEnabled(
False)
150 self.parameter_tree_widget.clear()
154 param_set_msg = self.parameter_tree_widget.get_parameter_set()
156 if self.upload_parameter_set_client.wait_for_server(rospy.Duration(0.5)):
157 self.logger.log_info(
"Sending parameter set '" + param_set_msg.name.data +
"'...")
159 goal = SetParameterSetGoal()
160 goal.params = param_set_msg;
161 self.upload_parameter_set_client.send_goal(goal)
163 if self.upload_parameter_set_client.wait_for_result(rospy.Duration(0.5)):
164 self.logger.log_info(
"Sent parameter set!")
165 result = self.upload_parameter_set_client.get_result()
166 self.logger.log(result.status)
168 self.logger.log_error(
"Can't send parameter set. Check communcation!")
170 self.logger.log_error(
"Can't connect to footstep parameter action server!")
176 if self.get_parameter_set_client.wait_for_server(rospy.Duration(0.5)):
177 self.logger.log_info(
"Requesting parameter set '" + name +
"'...")
179 goal = GetParameterSetGoal()
180 goal.name.data = name;
181 self.get_parameter_set_client.send_goal(goal)
183 if self.get_parameter_set_client.wait_for_result(rospy.Duration(0.5)):
184 self.logger.log_info(
"Received parameter set!")
185 result = self.get_parameter_set_client.get_result()
189 self.logger.log_error(
"Didn't received parameter set. Check communcation!")
191 self.logger.log_error(
"Can't connect to footstep parameter action server!")
199 self.logger.log_info(
"Visualize parameter set with " + str(len(param_set_msg.params)) +
" parameters.")
200 self.parameter_tree_widget.set_parameter_set(param_set_msg)
201 self.upload_command.setEnabled(
True)
202 self.reload_command.setEnabled(
True)