本文整理汇总了Python中python_qt_binding.QtGui.QWidget.setObjectName方法的典型用法代码示例。如果您正苦于以下问题:Python QWidget.setObjectName方法的具体用法?Python QWidget.setObjectName怎么用?Python QWidget.setObjectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QWidget
的用法示例。
在下文中一共展示了QWidget.setObjectName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class MyPlugin(Plugin):
def __init__(self, context):
super(MyPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('MyPlugin')
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
# Create QWidget
self._widget = QWidget()
# Get path to UI file which should be in the "resource" folder of this package
ui_file = os.path.join(rospkg.RosPack().get_path('rqt_mypkg'), 'resource', 'MyPlugin.ui')
# Extend the widget with all atrributes and children from UI File
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('MyPluginUi')
# Show _widget.windowTitle on left-top of each plugin(when it's set in _widget).
# This is useful when you open multiple plugins aat once. Also if you open multiple
# instances of your plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' %d' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
self._widget.cancelButton.clicked[bool].connect(self._handle_cancel_clicked)
self._widget.okButton.clicked[bool].connect(self._handle_ok_clicked)
def shutdown_plugin(self):
# TODO unregister all publishers here
pass
def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.get_value(k, v)
pass
def restore_settings(self, pluign_settings, instance_settings):
# TODO restore intrinsic configuration, usually using:
# v = instance_settings.value(k)
pass
def _handle_cancel_clicked(self):
print "cancelButton is clicked"
def _handle_ok_clicked(self):
print "okButton is clicked"
示例2: skeletonPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class skeletonPlugin(Plugin):
def __init__(self, context):
super(skeletonPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('skeletonPlugin')
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
# Create QWidget
self._widget = QWidget()
# Get path to UI file which is a sibling of this file
# in this example the .ui and .py file are in the same folder
ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'skeleton.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('skeletonUi')
# Show _widget.windowTitle on left-top of each plugin (when
# it's set in _widget). This is useful when you open multiple
# plugins at once. Also if you open multiple instances of your
# plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
def shutdown_plugin(self):
# TODO unregister all publishers here
pass
def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.set_value(k, v)
pass
def restore_settings(self, plugin_settings, instance_settings):
# TODO restore intrinsic configuration, usually using:
# v = instance_settings.value(k)
pass
示例3: ExampleGuiPub
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class ExampleGuiPub(Plugin):
def __init__(self, context=None):
super(ExampleGuiPub, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('ExampleGuiPub')
# Create QWidget
self._widget = QWidget()
# Get path to UI file which is a sibling of this file
pkg_dir = roslib.packages.get_pkg_dir('example_gui_pub')
ui_file_path = os.path.join(pkg_dir, 'ui/example_gui_pub.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file_path, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('ExampleGuiPubUi')
# Show _widget.windowTitle on left-top of each plugin (when
# it's set in _widget). This is useful when you open multiple
# plugins at once. Also if you open multiple instances of your
# plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
# Now Set up our own interface:
# ==> Connect the buttons to the functions
self._widget.btn_ok.clicked.connect(self.btn_ok_clicked)
def shutdown_plugin(self):
"""Kill all subscribers and publishers."""
pass
def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.set_value(k, v)
pass
def restore_settings(self, plugin_settings, instance_settings):
# TODO restore intrinsic configuration, usually using:
# v = instance_settings.value(k)
pass
def btn_ok_clicked(self):
#printing the word in the ui label box
spin_speed = 3.0
self._widget.StatusReturn.setText('set LIDAR speed to ' + str(spin_speed))
#publisher the data to multisense_sl
self.pub = rospy.Publisher('multisense_sl/set_spindle_speed', Float64, queue_size=10)
self.pub.publish(spin_speed)
示例4: BalanceModeWidget
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class BalanceModeWidget(Plugin):
def __init__(self, context):
super(BalanceModeWidget, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('BalanceMode')
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
# Create QWidget
self._widget = QWidget()
# Get path to UI file which should be in the "resource" folder of this package
ui_file = os.path.join(rospkg.RosPack().get_path('rsv_balance_rqt'), 'resource', 'BalanceModeWidget.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('BalanceModeWidgetUI')
# Numerated windowTitle
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
self._widget.set_park.clicked[bool].connect(self.on_set_park_button)
self._widget.set_tractor.clicked[bool].connect(self.on_set_tractor_button)
self._widget.set_balance.clicked[bool].connect(self.on_set_balance_button)
self._widget.topic_line_edit.textChanged.connect(self.on_topic_changed)
# Set mode client
self.set_mode_srv = None
self.on_topic_changed()
def shutdown_plugin(self):
pass
def save_settings(self, plugin_settings, instance_settings):
instance_settings.set_value('topic', self._widget.topic_line_edit.text())
def restore_settings(self, plugin_settings, instance_settings):
value = instance_settings.value('topic', "/set_mode")
self._widget.topic_line_edit.setText(value)
def on_set_park_button(self):
try:
self.set_mode_srv(rsv_balance_msgs.srv.SetModeRequest.PARK)
except rospy.ServiceException, e:
rospy.logwarn("Service call failed: %s" % e)
示例5: CalibrationControl
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class CalibrationControl(Plugin):
def __init__(self, context):
super(CalibrationControl, self).__init__(context)
self.setObjectName('CalibrationControl')
# Argument parsing
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
# Create QWidget
self._widget = QWidget()
# Get path to UI file which is a sibling of this file
rp = rospkg.RosPack()
ui_file = os.path.join(rp.get_path('industrial_calibration_gui'), 'resource', 'calibration_control.ui')
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('calibration_control_Ui')
# Custom code begins here
self._widget.cal_button.clicked[bool].connect(self.__handle_cal_clicked)
self.cal_service = rospy.ServiceProxy('calibration_service', Empty)
# Add widget to the user interface
context.add_widget(self._widget)
def shutdown_plugin(self):
# TODO unregister all publishers here
pass
def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.set_value(k, v)
pass
def restore_settings(self, plugin_settings, instance_settings):
# TODO restore intrinsic configuration, usually using:
# v = instance_settings.value(k)
pass
def __handle_cal_clicked(self, checked):
self.cal_service()
示例6: RunStopPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class RunStopPlugin(Plugin):
def __init__(self, context):
super(RunStopPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('RunStopPlugin')
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
# Create QWidget
self._widget = QWidget()
# Get path to UI file
ui_file = os.path.join(rospkg.RosPack().get_path('rqt_runstop'), 'src', 'rqt_runstop', 'runstop.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('RunStopPluginUi')
# Show _widget.windowTitle on left-top of each plugin (when
# it's set in _widget). This is useful when you open multiple
# plugins at once. Also if you open multiple instances of your
# plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
# initialize publisher to publish cancel messages
self._publisher = rospy.Publisher('move_base/cancel', GoalID, queue_size=10)
self._widget.runstopButton.clicked.connect(self.runstopButton_clicked) # button handler
# cancel all goals by sending empty goal to /move_base/cancel
def runstopButton_clicked(self):
emptyGoal = GoalID()
self._publisher.publish(emptyGoal)
return
示例7: Builder
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class Builder(Plugin):
def __init__(self, context):
super(Builder, self).__init__(context)
self.setObjectName('BeetreeBuilder')
# Create QWidget
self._widget = QWidget()
# Get path to UI file which is a sibling of this file
rospack = rospkg.RosPack()
ui_path = rospack.get_path('beetree_builder') + '/ui/main.ui'
# Load the ui attributes into the main widget
loadUi(ui_path, self._widget)
self._widget.setObjectName('BeetreeBuilderPluginUi')
# Show _widget.windowTitle on left-top of each plugin (when
# it's set in _widget). This is useful when you open multiple
# plugins at once. Also if you open multiple instances of your
# plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
palette = QPalette ()
palette.setColor(QPalette.Background, Qt.white)
self._widget.setPalette(palette)
# Add custom options
self._widget.node_type_list.addItems(['test1','test2'])
def shutdown_plugin(self):
# TODO unregister all publishers here
pass
def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.set_value(k, v)
pass
def restore_settings(self, plugin_settings, instance_settings):
# TODO restore intrinsic configuration, usually using:
# v = instance_settings.value(k)
pass
示例8: WoZPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class WoZPlugin(Plugin):
def __init__(self, context):
super(WoZPlugin, self).__init__(context)
self._widget = QWidget()
self._widget.setFixedSize(600, 600)
QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
large_box = QtGui.QVBoxLayout()
#Button for outreaching to recieve book from Human
button_box = QtGui.QVBoxLayout()
box_1 = QtGui.QHBoxLayout()
box_2 = QtGui.QHBoxLayout()
box_3 = QtGui.QHBoxLayout()
box_4 = QtGui.QHBoxLayout()
box_5 = QtGui.QHBoxLayout()
box_6 = QtGui.QHBoxLayout()
box_7 = QtGui.QHBoxLayout()
box_8 = QtGui.QHBoxLayout()
box_9 = QtGui.QHBoxLayout()
box_10 = QtGui.QHBoxLayout()
box_1.addWidget(self.create_button('print nice', self.printCallback))
self._widget.setObjectName('TrashbotGUI')
self._widget.setLayout(large_box)
context.add_widget(self._widget)
def create_button(self, name, callback):
btn = QtGui.QPushButton(name, self._widget)
btn.clicked.connect(callback)
btn.setAutoRepeat(True)
return btn
def printCallback(self):
print 'nice'
示例9: ChooseGazeboPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class ChooseGazeboPlugin(Plugin):
def __init__(self, context,namespace = None):
# it is either "" or the input given at creation of plugin
self.namespace = self._parse_args(context.argv())
super(ChooseGazeboPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('ChooseGazeboPlugin')
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
# Create QWidget
self._widget = QWidget()
# Get path to UI file which is a sibling of this file
# in this example the .ui and .py file are in the same folder
ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'choose_gazebo.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('ChooseGazeboUi')
# Show _widget.windowTitle on left-top of each plugin (when
# it's set in _widget). This is useful when you open multiple
# plugins at once. Also if you open multiple instances of your
# plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
# Button to start gazebo
self._widget.start_gazebo.clicked.connect(self.start_gazebo)
# Button to kill gazebo
self._widget.kill_gazebo.clicked.connect(self.kill_gazebo)
#@Slot(bool)
def start_gazebo(self):
#os.system('roslaunch quad_control mav_hovering_example.launch')
#subprocess.call('roslaunch quad_control mav_hovering_example.launch &', shell=True)
subprocess.call('roslaunch quad_control mav_with_load_example.launch &', shell=True)
# subprocess.call('roslaunch quad_control firefly_example.launch &', shell=True)
return
#@Slot(bool)
def kill_gazebo(self):
#os.system('killall gzclient')
#os.system('killall gzclient;killall gzserver')
subprocess.call('killall gzclient &', shell=True)
subprocess.call('killall gzserver &', shell=True)
return
def _parse_args(self, argv):
parser = argparse.ArgumentParser(prog='saver', add_help=False)
# args = parser.parse_args(argv)
if argv:
namespace = argv[0]
return namespace
else:
# is argv is empty return empty string
return ""
def shutdown_plugin(self):
# TODO unregister all publishers here
pass
def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.set_value(k, v)
pass
def restore_settings(self, plugin_settings, instance_settings):
# TODO restore intrinsic configuration, usually using:
# v = instance_settings.value(k)
pass
#def trigger_configuration(self):
# Comment in to signal that the plugin has a way to configure
#.........这里部分代码省略.........
示例10: QuestionDialogPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class QuestionDialogPlugin(Plugin):
def __init__(self, context):
super(QuestionDialogPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('QuestionDialogPlugin')
# Create QWidget
self._widget = QWidget()
self._widget.setFont(QFont("Times", 14, QFont.Bold))
self._layout = QVBoxLayout(self._widget)
self._text_browser = QTextBrowser(self._widget)
self._layout.addWidget(self._text_browser)
self._button_layout = QHBoxLayout()
self._layout.addLayout(self._button_layout)
# layout = QVBoxLayout(self._widget)
# layout.addWidget(self.button)
self._widget.setObjectName('QuestionDialogPluginUI')
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() +
(' (%d)' % context.serial_number()))
context.add_widget(self._widget)
# Setup service provider
self.service = rospy.Service('question_dialog', QuestionDialog,
self.service_callback)
self.response_ready = False
self.response = None
self.buttons = []
self.text_label = None
self.text_input = None
self.connect(self._widget, SIGNAL("update"), self.update)
self.connect(self._widget, SIGNAL("timeout"), self.timeout)
def shutdown_plugin(self):
self.service.shutdown()
def service_callback(self, req):
self.response_ready = False
self.request = req
self._widget.emit(SIGNAL("update"))
# Start timer against wall clock here instead of the ros clock.
start_time = time.time()
while not self.response_ready:
if req.timeout != QuestionDialogRequest.NO_TIMEOUT:
current_time = time.time()
if current_time - start_time > req.timeout:
self._widget.emit(SIGNAL("timeout"))
return QuestionDialogResponse(
QuestionDialogRequest.TIMED_OUT, "")
time.sleep(0.2)
return self.response
def update(self):
self.clean()
req = self.request
self._text_browser.setText(req.message)
if req.type == QuestionDialogRequest.DISPLAY:
# All done, nothing more too see here.
self.response = QuestionDialogResponse(
QuestionDialogRequest.NO_RESPONSE, "")
self.response_ready = True
elif req.type == QuestionDialogRequest.CHOICE_QUESTION:
for index, options in enumerate(req.options):
button = QPushButton(options, self._widget)
button.clicked.connect(partial(self.handle_button, index))
self._button_layout.addWidget(button)
self.buttons.append(button)
elif req.type == QuestionDialogRequest.TEXT_QUESTION:
self.text_label = QLabel("Enter here: ", self._widget)
self._button_layout.addWidget(self.text_label)
self.text_input = QLineEdit(self._widget)
self.text_input.editingFinished.connect(self.handle_text)
self._button_layout.addWidget(self.text_input)
def timeout(self):
self._text_browser.setText("Oh no! The request timed out.")
self.clean()
def clean(self):
while self._button_layout.count():
item = self._button_layout.takeAt(0)
item.widget().deleteLater()
self.buttons = []
self.text_input = None
self.text_label = None
def handle_button(self, index):
self.response = QuestionDialogResponse(index, "")
self.clean()
self.response_ready = True
def handle_text(self):
self.response = QuestionDialogResponse(
QuestionDialogRequest.TEXT_RESPONSE,
self.text_input.text())
self.clean()
self.response_ready = True
#.........这里部分代码省略.........
示例11: ArmGUI
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class ArmGUI(Plugin):
joint_sig = Signal(JointState)
def __init__(self, context):
super(ArmGUI, self).__init__(context)
self.setObjectName('ArmGUI')
self._widget = QWidget()
self._widget.setFixedSize(525, 300)
self.arm_db = ArmDB()
# Action/service/message clients or servers
switch_srv_name = 'pr2_controller_manager/switch_controller'
rospy.loginfo('Waiting for switch controller service...')
rospy.wait_for_service(switch_srv_name)
self.switch_service_client = rospy.ServiceProxy(switch_srv_name,
SwitchController)
self.r_joint_names = ['r_shoulder_pan_joint',
'r_shoulder_lift_joint',
'r_upper_arm_roll_joint',
'r_elbow_flex_joint',
'r_forearm_roll_joint',
'r_wrist_flex_joint',
'r_wrist_roll_joint']
self.l_joint_names = ['l_shoulder_pan_joint',
'l_shoulder_lift_joint',
'l_upper_arm_roll_joint',
'l_elbow_flex_joint',
'l_forearm_roll_joint',
'l_wrist_flex_joint',
'l_wrist_roll_joint']
self.all_joint_names = []
self.all_joint_poses = []
self.saved_r_arm_pose = None
self.saved_l_arm_pose = None
self.lock = threading.Lock()
rospy.Subscriber('joint_states', JointState, self.joint_states_cb)
# Create a trajectory action client
r_traj_controller_name = '/r_arm_controller/joint_trajectory_action'
self.r_traj_action_client = SimpleActionClient(r_traj_controller_name, JointTrajectoryAction)
rospy.loginfo('Waiting for a response from the trajectory action server for RIGHT arm...')
self.r_traj_action_client.wait_for_server()
l_traj_controller_name = '/l_arm_controller/joint_trajectory_action'
self.l_traj_action_client = SimpleActionClient(l_traj_controller_name, JointTrajectoryAction)
rospy.loginfo('Waiting for a response from the trajectory action server for LEFT arm...')
self.l_traj_action_client.wait_for_server()
QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
self.joint_sig.connect(self.joint_sig_cb)
large_box = QtGui.QVBoxLayout()
arm_box = QtGui.QHBoxLayout()
right_arm_box = QtGui.QVBoxLayout()
left_arm_box = QtGui.QVBoxLayout()
left_arm_box.addItem(QtGui.QSpacerItem(50,50))
right_arm_box.addItem(QtGui.QSpacerItem(50,50))
right_arm_box.addWidget(self.create_button('Relax right arm'))
right_arm_box.addWidget(self.create_button('Freeze right arm'))
left_arm_box.addWidget(self.create_button('Relax left arm'))
left_arm_box.addWidget(self.create_button('Freeze left arm'))
left_arm_box.addItem(QtGui.QSpacerItem(50,20))
right_arm_box.addItem(QtGui.QSpacerItem(50,20))
left_pose_saver = PoseSaver(PoseSaver.LEFT, self)
right_pose_saver = PoseSaver(PoseSaver.RIGHT, self)
left_arm_box.addWidget(self.create_button("Create left arm pose",
left_pose_saver.create_closure()))
right_arm_box.addWidget(self.create_button("Create right arm pose",
right_pose_saver.create_closure()))
left_arm_box.addItem(QtGui.QSpacerItem(50,20))
right_arm_box.addItem(QtGui.QSpacerItem(50,20))
# Dropdown boxes for saved poses
left_pose_loader = PoseLoader(PoseLoader.LEFT, self)
right_pose_loader = PoseLoader(PoseLoader.RIGHT, self)
self.combo_box_left = left_pose_loader.create_button()
self.combo_box_right = right_pose_loader.create_button()
left_arm_box.addWidget(self.combo_box_left)
right_arm_box.addWidget(self.combo_box_right)
left_pose_option_box = QtGui.QHBoxLayout()
right_pose_option_box = QtGui.QHBoxLayout()
right_pose_option_box.addWidget(self.create_button('Move to pose (R)'))
left_pose_option_box.addWidget(self.create_button('Move to pose (L)'))
# Buttons for deleting poses for left/right arms
left_pose_option_box.addWidget(self.create_button('Delete pose (L)'))
right_pose_option_box.addWidget(self.create_button('Delete pose (R)'))
left_arm_box.addLayout(left_pose_option_box)
#.........这里部分代码省略.........
示例12: Overview
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class Overview(Plugin):
setImageSignal = pyqtSignal(Image)
setBaseMaskSignal = pyqtSignal(Image)
setBatteryMaskSignal = pyqtSignal(Image)
setCupMaskSignal = pyqtSignal(Image)
def __init__(self, context):
super(Overview, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('rqt_calibration_blob')
self.__imageTopic = "/camera/rgb/image_rect_color"
self.__pickedColour = None
self.__lastHSVimage = None
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-i", "--imageTopic", dest="imageTopic", help="set image topic")
args, unknowns = parser.parse_known_args(context.argv())
if args.imageTopic:
self.__imageTopic = args.imageTopic
else:
self.__imageTopic = "/object_detection_blob_node/object_detection_blob_node/lightCorrected"
self.__imageSub = rospy.Subscriber(self.__imageTopic, Image, self.imageCallback)
self.__baseMaskSub = rospy.Subscriber("/object_detection_blob_node/object_detection_blob_node/base_mask", Image, self.baseMaskCallback)
self.__batteryMaskSub = rospy.Subscriber("/object_detection_blob_node/object_detection_blob_node/battery_mask", Image, self.batteryMaskCallback)
self.__cupMaskSub = rospy.Subscriber("/object_detection_blob_node/object_detection_blob_node/cup_mask", Image, self.cupMaskCallback)
self.__cvBridge = CvBridge()
# Create QWidget
self._widget = QWidget()
# Get path to UI file which should be in the "resource" folder of this node
ui_file = os.path.join(rospkg.RosPack().get_path('object_detection_blob'), 'src', 'rqt_calibration_gui', 'resource', 'overview.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('CalibrationUI')
# Show _widget.windowTitle on left-top of each plugin (when
# it's set in _widget). This is useful when you open multiple
# plugins at once. Also if you open multiple instances of your
# plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
self.__colorImageScene = ClickableGraphicsScene()
self.__baseImageScene = ClickableGraphicsScene()
self.__batteryImageScene = ClickableGraphicsScene()
self.__cupImageScene = ClickableGraphicsScene()
self.__colorImageScene.clicked.connect(self.readImageColour)
self.__baseImageScene.clicked.connect(self.readImageColour)
self.__batteryImageScene.clicked.connect(self.readImageColour)
self.__cupImageScene.clicked.connect(self.readImageColour)
self._widget.setBaseButton.clicked.connect(self.setBaseCallback)
self._widget.setBatteryButton.clicked.connect(self.setBatteryCallback)
self._widget.setCupButton.clicked.connect(self.setCupCallback)
self._widget.subscribeButton.clicked.connect(self.subscribeToImage)
self._widget.setMinButton.clicked.connect(self.setMinColour)
self._widget.setMaxButton.clicked.connect(self.setMaxColour)
# Connect signal so we can refresh widgets from the main thread
self.setImageSignal.connect(self.updateImage)
self.setBaseMaskSignal.connect(self.updateBaseMask)
self.setBatteryMaskSignal.connect(self.updateBatteryMask)
self.setCupMaskSignal.connect(self.updateCupMask)
# Add widget to the user interface
context.add_widget(self._widget)
rospy.loginfo("initialized")
def readImageColour(self, pos):
if self.__lastHSVimage is not None:
self.__pickedColour = self.__lastHSVimage[pos[1], pos[0]] # x, y is swapped in opencv
self._widget.colourLabel.setText("hue {0} sat {1} val {2}".format(self.__pickedColour[0], self.__pickedColour[1], self.__pickedColour[2]))
rospy.loginfo("picked color %s", self.__pickedColour)
def setMinColour(self):
if self.__pickedColour is not None:
self._widget.hueMinEdit.setText(str(self.__pickedColour[0]))
self._widget.satMinEdit.setText(str(self.__pickedColour[1]))
self._widget.valMinEdit.setText(str(self.__pickedColour[2]))
def setMaxColour(self):
if self.__pickedColour is not None:
self._widget.hueMaxEdit.setText(str(self.__pickedColour[0]))
self._widget.satMaxEdit.setText(str(self.__pickedColour[1]))
self._widget.valMaxEdit.setText(str(self.__pickedColour[2]))
def updateImage(self, img):
try:
img.encoding = "bgr8" # no, it's not but cv_bridge can't handle hsv
image = self.__cvBridge.imgmsg_to_cv2(img) # Convert ROS' sensor_msgs/Image to cv2 image
self.__lastHSVimage = image.copy()
image = cv2.cvtColor(image, cv2.COLOR_HSV2RGB)
height, width = image.shape[:2]
frame = QImage(image.data, width, height, QImage.Format_RGB888)
self.__colorImageScene.clear()
self.__colorImageScene.addPixmap(QPixmap.fromImage(frame))
self.__colorImageScene.update()
self._widget.lightCorrectedGraphicsView.setScene(self.__colorImageScene)
self._widget.lightCorrectedGraphicsView.ensureVisible(self.__colorImageScene.sceneRect());
#.........这里部分代码省略.........
示例13: LogicalMarkerPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class LogicalMarkerPlugin(Plugin):
def __init__(self, context):
super(LogicalMarkerPlugin, self).__init__(context)
# Create an image for the original map. This will never change.
try:
self.map_yaml_file_str = rospy.get_param("~map_file")
self.data_directory = rospy.get_param("~data_directory")
except KeyError:
rospy.logfatal("~map_file and ~data_directory need to be set to use the logical marker")
return
map_image_location = getImageFileLocation(self.map_yaml_file_str)
map = loadMapFromFile(self.map_yaml_file_str)
locations_file = getLocationsFileLocationFromDataDirectory(self.data_directory)
doors_file = getDoorsFileLocationFromDataDirectory(self.data_directory)
objects_file = getObjectsFileLocationFromDataDirectory(self.data_directory)
# Give QObjects reasonable names
self.setObjectName('LogicalMarkerPlugin')
# Create QWidget
self.master_widget = QWidget()
self.master_layout = QVBoxLayout(self.master_widget)
# Main Functions - Doors, Locations, Objects
self.function_layout = QHBoxLayout()
self.master_layout.addLayout(self.function_layout)
self.function_buttons = []
self.current_function = None
for button_text in ['Locations', 'Doors', 'Objects']:
button = QPushButton(button_text, self.master_widget)
button.clicked[bool].connect(self.handle_function_button)
button.setCheckable(True)
self.function_layout.addWidget(button)
self.function_buttons.append(button)
self.function_layout.addStretch(1)
self.master_layout.addWidget(self.get_horizontal_line())
# Subfunction toolbar
self.subfunction_layout = QHBoxLayout()
clearLayoutAndFixHeight(self.subfunction_layout)
self.master_layout.addLayout(self.subfunction_layout)
self.current_subfunction = None
self.master_layout.addWidget(self.get_horizontal_line())
self.image = MapImage(map_image_location, self.master_widget)
self.master_layout.addWidget(self.image)
self.master_layout.addWidget(self.get_horizontal_line())
# Configuration toolbar
self.configuration_layout = QHBoxLayout()
clearLayoutAndFixHeight(self.configuration_layout)
self.master_layout.addLayout(self.configuration_layout)
# Add a stretch at the bottom.
self.master_layout.addStretch(1)
self.master_widget.setObjectName('LogicalMarkerPluginUI')
if context.serial_number() > 1:
self.master_widget.setWindowTitle(self.master_widget.windowTitle() + (' (%d)' % context.serial_number()))
context.add_widget(self.master_widget)
# Activate the functions
self.functions = {}
self.functions['Locations'] = LocationFunction(locations_file,
map,
self.master_widget,
self.subfunction_layout,
self.configuration_layout,
self.image)
self.functions['Doors'] = DoorFunction(doors_file,
map,
self.functions['Locations'],
self.master_widget,
self.subfunction_layout,
self.configuration_layout,
self.image)
self.functions['Objects'] = ObjectFunction(objects_file,
map,
self.functions['Locations'],
self.master_widget,
self.subfunction_layout,
self.configuration_layout,
self.image)
def construct_layout(self):
pass
def get_horizontal_line(self):
"""
http://stackoverflow.com/questions/5671354/how-to-programmatically-make-a-horizontal-line-in-qt
"""
hline = QFrame()
hline.setFrameShape(QFrame.HLine)
hline.setFrameShadow(QFrame.Sunken)
#.........这里部分代码省略.........
示例14: ChooseControllerPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class ChooseControllerPlugin(Plugin):
# for controller state
ctr_st = pyqtSignal(numpy.ndarray)
# ---------------------------------------------- #
# ---------------------------------------------- #
# Necessary constants
# size of vectors: INTEGER
Size_Vector = 100
def __init__(self, context,namespace = None):
# it is either "" or the input given at creation of plugin
self.namespace = self._parse_args(context.argv())
super(ChooseControllerPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('ChooseControllerPlugin')
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
# Create QWidget
self._widget = QWidget()
# Get path to UI file which is a sibling of this file
# in this example the .ui and .py file are in the same folder
ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ChooseController.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('ChooseControllerUi')
# Show _widget.windowTitle on left-top of each plugin (when
# it's set in _widget). This is useful when you open multiple
# plugins at once. Also if you open multiple instances of your
# plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
# ---------------------------------------------- #
# ---------------------------------------------- #
# BUTTON TO SET DESIRED CONTROLLER
self._widget.SetControllerButton.clicked.connect(self.SetController)
# BUTTON TO SET DESIRED TRAJECTORY
self._widget.Reset_Int_XY.clicked.connect(self.RESET_xy_PID)
# BUTTON TO SET DESIRED TRAJECTORY
self._widget.Reset_Int_Z.clicked.connect(self.RESET_z_PID)
# ------------------------------------------------------------------#
# ------------------------------------------------------------------#
# get some values from launch file if theyre available
wn = 1
xsi = numpy.sqrt(2)/2
kv = rospy.get_param("kv",2.0*xsi*wn)
kp = rospy.get_param("kp",wn*wn)
Throttle_neutral = rospy.get_param("Throttle_neutral_ctr",1484.0)
# ------------------------------------------------------------------#
# ------------------------------------------------------------------#
# Default values for buttons: PD Controller
self._widget.PgainXY.setValue(kp)
self._widget.DgainXY.setValue(kv)
self._widget.PgainZ.setValue(kp)
self._widget.DgainZ.setValue(kv)
self._widget.ThrottleNeutral.setValue(Throttle_neutral)
# Default values for buttons: PID Controller
self._widget.PgainXY_PID.setValue(kp)
self._widget.DgainXY_PID.setValue(kv)
self._widget.IgainXY_PID.setValue(0.0)
self._widget.PgainZ_PID.setValue(kp)
self._widget.DgainZ_PID.setValue(kv)
self._widget.DgainXY_PID.setValue(kv)
self._widget.IgainZ_PID.setValue(0.0)
self._widget.ThrottleNeutral_PID.setValue(Throttle_neutral)
#.........这里部分代码省略.........
示例15: Dot
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setObjectName [as 别名]
class Dot(Plugin):
def __init__(self, context):
super(Dot, self).__init__(context)
self._dotcode_sub = None
# Give QObjects reasonable names
self.setObjectName('Dot')
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
# Create QWidget
self._widget = QWidget()
# Get path to UI file which is a sibling of this file
# in this example the .ui and .py file are in the same folder
ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rqt_dot.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('DotPluginUi')
# Show _widget.windowTitle on left-top of each plugin (when
# it's set in _widget). This is useful when you open multiple
# plugins at once. Also if you open multiple instances of your
# plugin at once, these lines add number to make it easy to
# tell from pane to pane.
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
# Add widget to the user interface
context.add_widget(self._widget)
palette = QPalette ()
palette.setColor(QPalette.Background, Qt.white)
self._widget.setPalette(palette)
self._widget.subscribe_button.setCheckable(True)
self._widget.subscribe_button.clicked[bool].connect(self._handle_subscribe_clicked)
def shutdown_plugin(self):
# TODO unregister all publishers here
pass
def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.set_value(k, v)
pass
def restore_settings(self, plugin_settings, instance_settings):
# TODO restore intrinsic configuration, usually using:
# v = instance_settings.value(k)
pass
#def trigger_configuration(self):
# Comment in to signal that the plugin has a way to configure
# This will enable a setting button (gear icon) in each dock widget title bar
# Usually used to open a modal configuration dialog
def _handle_subscribe_clicked(self, checked):
if checked:
topic_name = self._widget.topic_name.text()
if len(topic_name) > 0:
self._dotcode_sub = rospy.Subscriber(
topic_name,
std_msgs.msg.String,
self._dotcode_msg_cb)
else:
return False
else:
if self._dotcode_sub:
self._dotcode_sub.unregister()
self._dotcode_sub = None
def _dotcode_msg_cb(self, msg):
self._widget.xdot_widget.set_dotcode(msg.data)