16
16
from rqt_gui_py .plugin import Plugin
17
17
from python_qt_binding import QtCore
18
18
from python_qt_binding .QtGui import QIcon , QImage , QPixmap , QStandardItem , \
19
- QIntValidator , QStandardItemModel
19
+ QPen , QBrush , QPainter , QIntValidator , QStandardItemModel
20
20
from python_qt_binding .QtWidgets import (QComboBox , QAction , QToolBar , QStatusBar ,
21
- QLineEdit , QWidget , QVBoxLayout ,
22
- QLabel , QTextEdit , QFrame ,
23
- QHBoxLayout , QTreeView )
21
+ QLineEdit , QWidget , QVBoxLayout , QLabel ,
22
+ QTextEdit , QFrame , QHBoxLayout , QTreeView )
24
23
25
24
class bcolors :
26
25
HEADER = '\033 [95m'
@@ -74,11 +73,6 @@ def __init__(self, context):
74
73
self .widget .setObjectName (self .PLUGIN_TITLE )
75
74
self .widget .setWindowTitle (self .PLUGIN_TITLE )
76
75
77
- # parameter
78
- self .cli_param = self .node .create_client (SetParameters , '/grasp_modbus_server/set_parameters' )
79
- while not self .cli_param .wait_for_service (timeout_sec = 1.0 ):
80
- self .node .get_logger ().info ('service not available, waiting again...' )
81
-
82
76
# Data
83
77
self .Tsamples = []
84
78
@@ -95,12 +89,27 @@ def __init__(self, context):
95
89
'Clear the record data.' , self .widget )
96
90
path = path_pkg + '/share/handeye_dashboard/images/UR5.png'
97
91
self .execut_action = QAction (QIcon (QPixmap .fromImage (QImage (path ))),
98
- 'EStart the publishing the TF.' , self .widget )
92
+ 'Start the publishing the TF.' , self .widget )
93
+ self .path_red_icon = path_pkg + '/share/handeye_dashboard/images/red_circle_icon.png'
94
+ self .path_green_icon = path_pkg + '/share/handeye_dashboard/images/green_circle_icon.png'
95
+ self .parameter_action = QAction (QIcon (QPixmap .fromImage (QImage (self .path_red_icon ))),
96
+ 'Connect to parameter service.' , self .widget )
97
+ self .tf_action = QAction (QIcon (QPixmap .fromImage (QImage (self .path_red_icon ))),
98
+ 'Connect to tf service.' , self .widget )
99
+
99
100
self .toolbar = QToolBar ()
100
101
self .toolbar .addAction (self .snapshot_action )
101
102
self .toolbar .addAction (self .calibrate_action )
102
103
self .toolbar .addAction (self .clear_action )
103
104
self .toolbar .addAction (self .execut_action )
105
+ self .parameter_label = QLabel (self .widget )
106
+ self .parameter_label .setText ("Parameter service: " )
107
+ self .toolbar .addWidget (self .parameter_label )
108
+ self .toolbar .addAction (self .parameter_action )
109
+ self .tf_label = QLabel (self .widget )
110
+ self .tf_label .setText ("tf service: " )
111
+ self .toolbar .addWidget (self .tf_label )
112
+ self .toolbar .addAction (self .tf_action )
104
113
105
114
# Toolbar0
106
115
self .l0 = QLabel (self .widget )
@@ -207,16 +216,37 @@ def __init__(self, context):
207
216
self .calibrate_action .triggered .connect (self .calibration )
208
217
self .clear_action .triggered .connect (self .clear )
209
218
self .execut_action .triggered .connect (self .execution )
219
+ self .parameter_action .triggered .connect (self .parameter_connect )
220
+ self .tf_action .triggered .connect (self .tf_connect )
210
221
211
222
# Package path
212
223
self .path_pkg = path_pkg
213
224
214
- # Set up TF
215
- self .cli = self .node .create_client (HandeyeTF , 'handeye_tf_service' )
216
- while not self .cli .wait_for_service (timeout_sec = 1.0 ):
217
- self .node .get_logger ().info ('service not available, waiting again...' )
225
+ # Set up TF service client
226
+ self .client_tf = self .node .create_client (HandeyeTF , 'handeye_tf_service' )
227
+ self .tf_action .setIcon (QIcon (QPixmap .fromImage (QImage (self .path_red_icon ))) \
228
+ if not self .client_tf .wait_for_service (timeout_sec = 0.5 ) \
229
+ else QIcon (QPixmap .fromImage (QImage (self .path_green_icon ))))
218
230
self .req = HandeyeTF .Request ()
219
231
232
+ # Set up parameter service client
233
+ self .client_param = self .node .create_client (SetParameters , '/grasp_modbus_server/set_parameters' )
234
+ self .parameter_action .setIcon (QIcon (QPixmap .fromImage (QImage (self .path_red_icon ))) \
235
+ if not self .client_param .wait_for_service (timeout_sec = 0.5 ) \
236
+ else QIcon (QPixmap .fromImage (QImage (self .path_green_icon ))))
237
+
238
+ def tf_connect (self ):
239
+ self .client_tf = self .node .create_client (HandeyeTF , 'handeye_tf_service' )
240
+ self .tf_action .setIcon (QIcon (QPixmap .fromImage (QImage (self .path_red_icon ))) \
241
+ if not self .client_tf .wait_for_service (timeout_sec = 0.5 ) \
242
+ else QIcon (QPixmap .fromImage (QImage (self .path_green_icon ))))
243
+
244
+ def parameter_connect (self ):
245
+ self .client_param = self .node .create_client (SetParameters , '/grasp_modbus_server/set_parameters' )
246
+ self .parameter_action .setIcon (QIcon (QPixmap .fromImage (QImage (self .path_red_icon ))) \
247
+ if not self .client_param .wait_for_service (timeout_sec = 0.5 ) \
248
+ else QIcon (QPixmap .fromImage (QImage (self .path_green_icon ))))
249
+
220
250
def clear (self ):
221
251
# >>> Clear the recorded samples
222
252
self .textedit .append ('Clearing the recorded data ...' )
@@ -229,7 +259,7 @@ def get_tf_transform(self, frame_id, child_frame_id):
229
259
self .req .transform .child_frame_id = child_frame_id
230
260
self .req .publish .data = False
231
261
232
- future = self .cli .call_async (self .req )
262
+ future = self .client_tf .call_async (self .req )
233
263
rclpy .spin_until_future_complete (self .node , future )
234
264
235
265
transform = TransformStamped ()
@@ -247,7 +277,7 @@ def publish_tf_transform(self, transform_to_publish):
247
277
self .req .publish .data = True
248
278
self .req .transform = transform_to_publish
249
279
250
- future = self .cli .call_async (self .req )
280
+ future = self .client_tf .call_async (self .req )
251
281
rclpy .spin_until_future_complete (self .node , future )
252
282
253
283
try :
@@ -330,7 +360,7 @@ def execution(self):
330
360
param .value .integer_value = 4
331
361
req .parameters .append (param )
332
362
333
- future = self .cli_param .call_async (req )
363
+ future = self .client_param .call_async (req )
334
364
rclpy .spin_until_future_complete (self .node , future )
335
365
336
366
# >>> Publish the camera-robot transform
0 commit comments