本文整理汇总了Python中python_qt_binding.QtCore.QTimer.start方法的典型用法代码示例。如果您正苦于以下问题:Python QTimer.start方法的具体用法?Python QTimer.start怎么用?Python QTimer.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtCore.QTimer
的用法示例。
在下文中一共展示了QTimer.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PropStatus
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class PropStatus(Plugin):
def __init__(self, context):
super(PropStatus, self).__init__(context)
self.setObjectName('Status')
self._widget = QWidget()
loadUi(os.path.join(uipath, 'propagatorstatus.ui'), self._widget)
context.add_widget(self._widget)
rospy.Subscriber('/thrusters/info',ThrusterInfo,motordriver_callback)
rospy.Subscriber('/skytraq_serial',SerialPacket,gps_callback)
rospy.Subscriber('/imu/data_raw',Imu,imu_callback)
rospy.Subscriber('/scan',LaserScan,lidar_callback)
rospy.Subscriber('/mv_bluefox_camera_node/image_raw',Image,camera_callback)
rospy.Timer(rospy.Duration(2),kill)
self._update_timer = QTimer(self._widget)
self._update_timer.timeout.connect(self._on_update)
self._update_timer.start(100)
def _on_update(self):
self._widget.findChild(QListWidget, 'list').clear()
for i in ['FR','FL','BR','BL','GPS','IMU','LIDAR','CAMERA']:
pItem = QListWidgetItem(i);
if i in active:
pItem.setBackground(Qt.green);
else:
pItem.setBackground(Qt.red);
self._widget.findChild(QListWidget, 'list').addItem(pItem)
示例2: MicoButtonsWidget
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class MicoButtonsWidget(QWidget):
def __init__(self, widget):
super(MicoButtonsWidget, self).__init__()
rospkg_pack = rospkg.RosPack()
ui_file = os.path.join(rospkg_pack.get_path('mico_controller'), 'resource', 'MicoButtons.ui')
loadUi(ui_file, self)
self.start_arm_srv = rospy.ServiceProxy('mico_arm_driver/in/start', MicoStart)
self.stop_arm_srv = rospy.ServiceProxy('mico_arm_driver/in/stop', MicoStop)
self.home_arm_srv = rospy.ServiceProxy('mico_arm_driver/in/home_arm', MicoHome)
self._updateTimer = QTimer(self)
self._updateTimer.timeout.connect(self.timeout_callback)
def start(self):
self._updateTimer.start(1000) # loop rate[ms]
def stop(self):
self._updateTimer.stop()
def timeout_callback(self):
pass
# rqt override
def save_settings(self, plugin_settings, instance_settings):
pass
# instance_settings.set_value('topic_name', self._topic_name)
def restore_settings(self, plugin_settings, instance_settings):
pass
# topic_name = instance_settings.value('topic_name')
# try:
# self._topic_name = eval(topic_name)
# except Exception:
# self._topic_name = self.TOPIC_NAME
def shutdown_plugin(self):
self.stop()
@Slot()
def on_qt_start_btn_clicked(self):
rospy.loginfo(self.start_arm_srv())
@Slot()
def on_qt_stop_btn_clicked(self):
rospy.loginfo(self.stop_arm_srv())
@Slot()
def on_qt_home_btn_clicked(self):
rospy.loginfo(self.home_arm_srv())
示例3: RosPlot
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class RosPlot(FigureCanvas):
"""Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
def __init__(self, parent, label_name,topic_name,topic_type,topic_field,buffer_size):
self.label_name= label_name
self.topic_type = topic_type
self.topic_name = topic_name
self.topic_field = topic_field
self.buffer_size = buffer_size
self.timer = QTimer()
self.timer.setInterval(100)
self.timer.timeout.connect(self.update_figure)
fig = Figure(figsize=(5, 4), dpi=100)
self.axes = fig.add_subplot(111)
# We want the axes cleared every time plot() is called
self.axes.hold(False)
self.compute_initial_figure()
self.buffer = collections.deque(maxlen=self.buffer_size)
FigureCanvas.__init__(self, fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.subscriber = RosHelper.create_subscriber_from_type(self.topic_name,self.topic_type,self.on_message)
self.timer.start()
def compute_initial_figure(self):
pass
def on_message(self,msg):
r = msg
for subfields in self.topic_field.split(".")[1:]:
r = getattr(r,subfields)
self.buffer.append(r)
def update_figure(self):
x = np.array(range(0,len(self.buffer)))
y = np.array(self.buffer)
self.axes.plot(x, y.T, 'r')
self.draw()
示例4: ProblemViewerWidget
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class ProblemViewerWidget(QWidget):
_problem_text = ""
def __init__(self, plugin=None):
super(ProblemViewerWidget, self).__init__()
# Create QWidget
ui_file = os.path.join(rospkg.RosPack().get_path('rosplan_rqt'), 'resource', 'problem_viewer.ui')
loadUi(ui_file, self)
self.setObjectName('ROSPlanProblemViewer')
self._plugin = plugin
rospy.Subscriber("/kcl_rosplan/problem", String, self.refresh_problem)
# init and start update timers
self._timer_set_problem = QTimer(self)
self._timer_set_problem.timeout.connect(self.set_problem)
self.start()
def start(self):
self._timer_set_problem.start(1000)
"""
updating problem view
"""
def refresh_problem(self, msg):
self._problem_text = msg.data
def set_problem(self):
self.textEdit.setPlainText(self._problem_text)
"""
Qt methods
"""
def shutdown_plugin(self):
pass
def save_settings(self, plugin_settings, instance_settings):
pass
def restore_settings(self, plugin_settings, instance_settings):
pass
示例5: TopicDataWidget
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class TopicDataWidget(DataDialog):
def __init__(self, plugin):
super(TopicDataWidget, self).__init__()
rospkgPack = rospkg.RosPack()
self._plugin = plugin
self._topicName = TOPIC_NAME
self._subscriber = None
self._updateTimer = QTimer(self)
self._updateTimer.timeout.connect(self.timeoutCallback)
self._updateTimer.start(40)
self.subscribeTopic(self._topicName)
# rqt override
def save_settings(self, plugin_settings, instance_settings):
instance_settings.set_value('topic_name', self._topicName)
def restore_settings(self, plugin_settings, instance_settings):
topicName = instance_settings.value('topic_name')
try:
self._topicName = eval(topicName)
except Exception:
topicName = None
def shutdown_plugin(self):
self.unregister_topic()
# subscribe topic
def subscribeTopic(self, topicName):
# msgClass, self._topicName, _ = get_topic_class(topicName)
self._subscriber = rospy.Subscriber(TOPIC_NAME, MSG_CLASS, self.messageCallback)
def messageCallback(self, msg):
self.setDisplayedData(msg.data, TOPIC_NAME)
def unregisterTopic(self):
if self._subscriber:
self._subscriber.unregister()
def timeoutCallback(self):
pass
示例6: BaseFilter
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class BaseFilter(QObject):
"""
Contains basic functions common to all filters.
Handles enabled logic and change notification.
"""
filter_changed_signal = Signal()
def __init__(self):
super(BaseFilter, self).__init__()
self._enabled = True
self._timer = QTimer(self)
self._timer.setSingleShot(True)
self._timer.timeout.connect(self.filter_changed_signal.emit)
def start_emit_timer(self, msec=None):
"""
Starts a timer to emit a signal to refresh the filters after the filter is changed
:param msec: number of msecs to wait before emitting the signal to change the filter ''int''
"""
if msec is None:
self._timer.start(10)
else:
self._timer.start(msec)
def is_enabled(self):
return self._enabled
def set_enabled(self, checked):
"""
Setter for _enabled
:param checked: boolean flag to set ''bool''
:emits filter_changed_signal: Always
"""
self._enabled = checked
self.start_emit_timer(200)
def has_filter(self):
raise NotImplementedError()
def test_message(self, message):
raise NotImplementedError()
示例7: ParamCheckThread
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class ParamCheckThread(threading.Thread):
def __init__(self, parent, signal_tobe_emitted, params_monitored):
"""
@type params_monitored: str[]
"""
super(ParamCheckThread, self).__init__()
self._parent = parent
self._signal = signal_tobe_emitted
self._params_monitored = params_monitored
self._timer = QTimer()
self._timer.timeout.connect(self._monitor_param)
def run(self):
self._timer.start(300)
def _monitor_param(self):
for param in self._params_monitored:
has_param = rospy.has_param(param)
self._signal.emit(has_param, param)
示例8: NodeMonitorThread
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class NodeMonitorThread(threading.Thread):
def __init__(self, parent, signal_tobe_emitted, nodes_monitored):
"""
@type nodes_monitored: str[]
"""
super(NodeMonitorThread, self).__init__()
self._parent = parent
self._signal = signal_tobe_emitted
self._nodes_monitored = nodes_monitored
self._timer = QTimer()
self._timer.timeout.connect(self._monitor_nodes)
def run(self):
self._timer.start(500)
def _monitor_nodes(self):
for nodename in self._nodes_monitored:
is_node_running = rosnode_ping(nodename, 1)
#TODO: segfault occurs here most of every time the plugin shut down
self._signal.emit(is_node_running, nodename)
示例9: Engineering_Plant
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class Engineering_Plant(Plugin):
def __init__(self, context):
super(Engineering_Plant, self).__init__(context)
self.setObjectName('Engineering_Plant')
self._widget = QWidget()
loadUi(os.path.join(uipath, 'engineering_plant.ui'), self._widget)
context.add_widget(self._widget)
self._widget.findChild(QPushButton, 'Kill').clicked.connect(self.Kill)
self._widget.findChild(QPushButton, 'UnKill').clicked.connect(self.Un_kill)
rospy.Subscriber('/power_router/status',prstatus,data_update)
self.killservice = rospy.ServiceProxy('/power_router/setkill', SetKill)
self._update_timer = QTimer(self._widget)
self._update_timer.timeout.connect(self._on_update)
self._update_timer.start(1000)
def _on_update(self):
global computer_current, motor_current, temperature, battery
compratio = int(float(computer_current/300.0)*100)
self._widget.findChild(QProgressBar, 'ComputerCurrent').setValue(compratio)
motorratio = int(float(motor_current/9000.0)*100)
self._widget.findChild(QProgressBar, 'MotorCurrent').setValue(motorratio)
#tempratio = int(float(temperature/150)*100)
self._widget.findChild(QLCDNumber, 'tempLCD').display(temperature)
battratio = int(float(battery/100)*100)
self._widget.findChild(QProgressBar, 'Battery').setValue(battratio)
def Kill(self):
self.killservice(True)
def Un_kill(self):
self.killservice(False)
示例10: Plot3DWidget
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class Plot3DWidget(QWidget):
_redraw_interval = 40
def __init__(self, initial_topics=None, start_paused=False,
buffer_length=100, use_poly=True, no_legend=False):
super(Plot3DWidget, self).__init__()
self.setObjectName('Plot3DWidget')
self._buffer_length = buffer_length
self._initial_topics = initial_topics
rp = rospkg.RosPack()
ui_file = os.path.join(rp.get_path('jsk_rqt_plugins'),
'resource', 'plot3d.ui')
loadUi(ui_file, self)
self.subscribe_topic_button.setIcon(QIcon.fromTheme('add'))
self.remove_topic_button.setIcon(QIcon.fromTheme('remove'))
self.pause_button.setIcon(QIcon.fromTheme('media-playback-pause'))
self.clear_button.setIcon(QIcon.fromTheme('edit-clear'))
self.data_plot = MatDataPlot3D(self, self._buffer_length,
use_poly, no_legend)
self.data_plot_layout.addWidget(self.data_plot)
self.data_plot.autoscroll(self.autoscroll_checkbox.isChecked())
self.data_plot.dropEvent = self.dropEvent
self.data_plot.dragEnterEvent = self.dragEnterEvent
self.subscribe_topic_button.setEnabled(False)
if start_paused:
self.pause_button.setChecked(True)
self._topic_completer = TopicCompleter(self.topic_edit)
self._topic_completer.update_topics()
self.topic_edit.setCompleter(self._topic_completer)
self._start_time = rospy.get_time()
self._rosdata = {}
self._remove_topic_menu = QMenu()
# init and start update timer for plot
self._update_plot_timer = QTimer(self)
self._update_plot_timer.timeout.connect(self.update_plot)
if self._initial_topics:
for topic_name in self._initial_topics:
self.add_topic(topic_name)
self._initial_topics = None
@Slot('QDragEnterEvent*')
def dragEnterEvent(self, event):
# get topic name
if not event.mimeData().hasText():
if not hasattr(event.source(), 'selectedItems') or len(event.source().selectedItems()) == 0:
qWarning('Plot.dragEnterEvent(): not hasattr(event.source(), selectedItems) or len(event.source().selectedItems()) == 0')
return
item = event.source().selectedItems()[0]
topic_name = item.data(0, Qt.UserRole)
if topic_name == None:
qWarning('Plot.dragEnterEvent(): not hasattr(item, ros_topic_name_)')
return
else:
topic_name = str(event.mimeData().text())
# check for numeric field type
is_numeric, is_array, message = is_slot_numeric(topic_name)
if is_numeric and not is_array:
event.acceptProposedAction()
else:
qWarning('Plot.dragEnterEvent(): rejecting: "%s"' % (message))
@Slot('QDropEvent*')
def dropEvent(self, event):
if event.mimeData().hasText():
topic_name = str(event.mimeData().text())
else:
droped_item = event.source().selectedItems()[0]
topic_name = str(droped_item.data(0, Qt.UserRole))
self.add_topic(topic_name)
@Slot(str)
def on_topic_edit_textChanged(self, topic_name):
# on empty topic name, update topics
if topic_name in ('', '/'):
self._topic_completer.update_topics()
is_numeric, is_array, message = is_slot_numeric(topic_name)
self.subscribe_topic_button.setEnabled(is_numeric and not is_array)
self.subscribe_topic_button.setToolTip(message)
@Slot()
def on_topic_edit_returnPressed(self):
if self.subscribe_topic_button.isEnabled():
self.add_topic(str(self.topic_edit.text()))
@Slot()
def on_subscribe_topic_button_clicked(self):
self.add_topic(str(self.topic_edit.text()))
@Slot(bool)
def on_pause_button_clicked(self, checked):
self.enable_timer(not checked)
@Slot(bool)
#.........这里部分代码省略.........
示例11: PoseViewWidget
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class PoseViewWidget(QWidget):
def __init__(self, plugin):
super(PoseViewWidget, self).__init__()
rp = rospkg.RosPack()
ui_file = os.path.join(rp.get_path('rqt_pose_view'), 'resource', 'PoseViewWidget.ui')
loadUi(ui_file, self)
self._plugin = plugin
self._position = (2.0, 2.0, 2.0)
self._orientation = quaternion_about_axis(0.0, (1.0, 0.0, 0.0))
self._topic_name = None
self._subscriber = None
# create GL view
self._gl_view = GLWidget()
self._gl_view.setAcceptDrops(True)
# backup and replace original paint method
self._gl_view.paintGL_original = self._gl_view.paintGL
self._gl_view.paintGL = self._gl_view_paintGL
# backup and replace original mouse release method
self._gl_view.mouseReleaseEvent_original = self._gl_view.mouseReleaseEvent
self._gl_view.mouseReleaseEvent = self._gl_view_mouseReleaseEvent
# add GL view to widget layout
self.layout().addWidget(self._gl_view)
# init and start update timer with 40ms (25fps)
self._update_timer = QTimer(self)
self._update_timer.timeout.connect(self.update_timeout)
self._update_timer.start(40)
def save_settings(self, plugin_settings, instance_settings):
view_matrix_string = repr(self._gl_view.get_view_matrix())
instance_settings.set_value('view_matrix', view_matrix_string)
def restore_settings(self, plugin_settings, instance_settings):
view_matrix_string = instance_settings.value('view_matrix')
try:
view_matrix = eval(view_matrix_string)
except Exception:
view_matrix = None
if view_matrix is not None:
self._gl_view.set_view_matrix(view_matrix)
else:
self._set_default_view()
def _set_default_view(self):
self._gl_view.makeCurrent()
self._gl_view.reset_view()
self._gl_view.rotate((0, 0, 1), 45)
self._gl_view.rotate((1, 0, 0), -65)
self._gl_view.translate((0, -3, -15))
def update_timeout(self):
self._gl_view.makeCurrent()
self._gl_view.updateGL()
def _gl_view_paintGL(self):
self._gl_view.paintGL_original()
self._paintGLGrid()
self._paintGLCoorsystem()
self._paintGLBox()
def _paintGLBox(self):
# FIXME: add user configurable setting to allow use of translation as well
self._position = (2.0, 2.0, 2.0) # Set fixed translation for now
glTranslatef(*self._position) # Translate Box
matrix = quaternion_matrix(self._orientation) # convert quaternion to translation matrix
glMultMatrixf(matrix) # Rotate Box
glBegin(GL_QUADS) # Start Drawing The Box
glColor3f(0.0, 1.0, 0.0)
glVertex3f(1.0, 1.0, -1.0) # Top Right Of The Quad (Top)
glVertex3f(-1.0, 1.0, -1.0) # Top Left Of The Quad (Top)
glVertex3f(-1.0, 1.0, 1.0) # Bottom Left Of The Quad (Top)
glVertex3f(1.0, 1.0, 1.0) # Bottom Right Of The Quad (Top)
glColor3f(0.5, 1.0, 0.5)
glVertex3f(1.0, -1.0, 1.0) # Top Right Of The Quad (Bottom)
glVertex3f(-1.0, -1.0, 1.0) # Top Left Of The Quad (Bottom)
glVertex3f(-1.0, -1.0, -1.0) # Bottom Left Of The Quad (Bottom)
glVertex3f(1.0, -1.0, -1.0) # Bottom Right Of The Quad (Bottom)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(1.0, 1.0, 1.0) # Top Right Of The Quad (Front)
glVertex3f(-1.0, 1.0, 1.0) # Top Left Of The Quad (Front)
glVertex3f(-1.0, -1.0, 1.0) # Bottom Left Of The Quad (Front)
glVertex3f(1.0, -1.0, 1.0) # Bottom Right Of The Quad (Front)
glColor3f(0.5, 0.5, 1.0)
glVertex3f(1.0, -1.0, -1.0) # Bottom Left Of The Quad (Back)
glVertex3f(-1.0, -1.0, -1.0) # Bottom Right Of The Quad (Back)
glVertex3f(-1.0, 1.0, -1.0) # Top Right Of The Quad (Back)
#.........这里部分代码省略.........
示例12: Top
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class Top(Plugin):
NODE_FIELDS = [ 'pid', 'get_cpu_percent', 'get_memory_percent', 'get_num_threads']
OUT_FIELDS = ['node_name', 'pid', 'cpu_percent', 'memory_percent', 'num_threads' ]
FORMAT_STRS = ['%s', '%s', '%0.2f', '%0.2f', '%s' ]
NODE_LABELS = ['Node', 'PID', 'CPU %', 'Mem %', 'Num Threads' ]
SORT_TYPE = [str, str, float, float, float ]
TOOLTIPS = {
0: ('cmdline', lambda x: '\n'.join(textwrap.wrap(' '.join(x)))),
3: ('memory_info', lambda x: ('Resident: %0.2f MiB, Virtual: %0.2f MiB' % (x[0]/2**20, x[1]/2**20)))
}
_node_info = NodeInfo()
name_filter = re.compile('')
def __init__(self, context):
super(Top, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('Top')
# 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
self._selected_node = ''
self._selected_node_lock = RLock()
# Setup the toolbar
self._toolbar = QToolBar()
self._filter_box = QLineEdit()
self._regex_box = QCheckBox()
self._regex_box.setText('regex')
self._toolbar.addWidget(QLabel('Filter'))
self._toolbar.addWidget(self._filter_box)
self._toolbar.addWidget(self._regex_box)
self._filter_box.returnPressed.connect(self.update_filter)
self._regex_box.stateChanged.connect(self.update_filter)
# Create a container widget and give it a layout
self._container = QWidget()
self._container.setWindowTitle('Process Monitor')
self._layout = QVBoxLayout()
self._container.setLayout(self._layout)
self._layout.addWidget(self._toolbar)
# Create the table widget
self._table_widget = QTreeWidget()
self._table_widget.setObjectName('TopTable')
self._table_widget.setColumnCount(len(self.NODE_LABELS))
self._table_widget.setHeaderLabels(self.NODE_LABELS)
self._table_widget.itemClicked.connect(self._tableItemClicked)
self._table_widget.setSortingEnabled(True)
self._table_widget.setAlternatingRowColors(True)
self._layout.addWidget(self._table_widget)
context.add_widget(self._container)
# Add a button for killing nodes
self._kill_button = QPushButton('Kill Node')
self._layout.addWidget(self._kill_button)
self._kill_button.clicked.connect(self._kill_node)
# Update twice since the first cpu% lookup will always return 0
self.update_table()
self.update_table()
self._table_widget.resizeColumnToContents(0)
# Start a timer to trigger updates
self._update_timer = QTimer()
self._update_timer.setInterval(1000)
self._update_timer.timeout.connect(self.update_table)
self._update_timer.start()
def _tableItemClicked(self, item, column):
with self._selected_node_lock:
self._selected_node = item.text(0)
def update_filter(self, *args):
if self._regex_box.isChecked():
expr = self._filter_box.text()
else:
expr = re.escape(self._filter_box.text())
self.name_filter = re.compile(expr)
self.update_table()
def _kill_node(self):
self._node_info.kill_node(self._selected_node)
#.........这里部分代码省略.........
示例13: CalibWidget
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class CalibWidget(QWidget):
_sub_pattern_detections = None
_sub_calibration_output = None
_num_pattern_detections = 0
_calibration_output = ""
_update_required = True
def __init__(self):
print('constructor')
# Init QWidget
super(CalibWidget, self).__init__()
self.setObjectName('CalibWidget')
# load UI
ui_file = os.path.join(rospkg.RosPack().get_path('dvs_calibration_gui'), 'resource', 'widget.ui')
loadUi(ui_file, self)
# init and start update timer for data, the timer calls the function update_info all 40ms
self._update_info_timer = QTimer(self)
self._update_info_timer.timeout.connect(self.update_info)
self._update_info_timer.start(40)
self.button_reset.pressed.connect(self.on_button_reset_pressed)
self.button_start.pressed.connect(self.on_button_start_calibration_pressed)
self.button_save.pressed.connect(self.on_button_save_calibration_pressed)
self._sub_pattern_detections = rospy.Subscriber('dvs_calibration/pattern_detections', Int32, self.pattern_detections_cb)
self._sub_calibration_output = rospy.Subscriber('dvs_calibration/output', String, self.calibration_output_cb)
print('reset')
self.on_button_reset_pressed()
print('reset done')
def unregister(self):
print('Nothing to do')
def pattern_detections_cb(self, msg):
self._num_pattern_detections = msg.data
if (self._num_pattern_detections > 0):
self.button_start.setEnabled( True )
self._update_required = True
def calibration_output_cb(self, msg):
self._calibration_output = msg.data
self._update_required = True
def update_info(self):
if (self._update_required):
self.numDetectionsLabel.setText(str(self._num_pattern_detections))
self.calibrationResultText.setPlainText(self._calibration_output)
self._update_required = False
@Slot(bool)
def on_button_reset_pressed(self):
self._num_pattern_detections = 0
self._calibration_output = ""
self._update_required = True
self.button_start.setEnabled( False )
try:
rospy.wait_for_service('dvs_calibration/reset', 1)
try:
reset_service = rospy.ServiceProxy('dvs_calibration/reset', Empty)
resp = reset_service()
except rospy.ServiceException, e:
print "Service call failed: %s"%e
except:
print "service not available..."
pass
@Slot(bool)
def on_button_start_calibration_pressed(self):
self.button_start.setEnabled( False )
try:
rospy.wait_for_service('dvs_calibration/start', 1)
try:
start_calibration_service = rospy.ServiceProxy('dvs_calibration/start', Empty)
resp = start_calibration_service()
except rospy.ServiceException, e:
print "Service call failed: %s"%e
except:
print "service not available..."
pass
@Slot(bool)
def on_button_save_calibration_pressed(self):
try:
rospy.wait_for_service('dvs_calibration/save', 1)
try:
save_calibration_service = rospy.ServiceProxy('dvs_calibration/save', Empty)
resp = save_calibration_service()
except rospy.ServiceException, e:
print "Service call failed: %s"%e
except:
#.........这里部分代码省略.........
示例14: print
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
)
except:
print (
"Will attempt to start SpeakEasy in ROS mode. If fail, switch to local mode. Possibly a few seconds delay..."
)
speakeasyController = SpeakEasyController(scriptDir, unix_sig_notify_read_socket=rsock, stand_alone=None)
else:
try:
rospy.loginfo(
"Will attempt to start SpeakEasy in ROS mode. If fail, switch to local mode. Possibly a few seconds delay..."
)
except:
print (
"Will attempt to start SpeakEasy in ROS mode. If fail, switch to local mode. Possibly a few seconds delay..."
)
speakeasyController = SpeakEasyController(scriptDir, unix_sig_notify_read_socket=rsock, stand_alone=None)
# Attach Unix signals USR1/USR2 to the sigusr1_2_handler().
# (These signals are separate from the Qt signals!):
signal.signal(signal.SIGUSR1, sigusr1_2_handler)
signal.signal(signal.SIGUSR2, sigusr1_2_handler)
# Unix signals are delivered to Qt only when Qt
# leaves its event loop. Force that to happen
# every half second:
timer = QTimer()
timer.start(500)
timer.timeout.connect(lambda: None)
# Enter Qt application main loop
sys.exit(app.exec_())
示例15: JointTrajectoryController
# 需要导入模块: from python_qt_binding.QtCore import QTimer [as 别名]
# 或者: from python_qt_binding.QtCore.QTimer import start [as 别名]
class JointTrajectoryController(Plugin):
"""
Graphical frontend for a C{JointTrajectoryController}.
There are two modes for interacting with a controller:
1. B{Monitor mode} Joint displays are updated with the state reported
by the controller. This is a read-only mode and does I{not} send
control commands. Every time a new controller is selected, it starts
in monitor mode for safety reasons.
2. B{Control mode} Joint displays update the control command that is
sent to the controller. Commands are sent periodically evan if the
displays are not being updated by the user.
To control the aggressiveness of the motions, the maximum speed of the
sent commands can be scaled down using the C{Speed scaling control}
This plugin is able to detect and keep track of all active controller
managers, as well as the JointTrajectoryControllers that are I{running}
in each controller manager.
For a controller to be compatible with this plugin, it must comply with
the following requisites:
- The controller type contains the C{JointTrajectoryController}
substring, e.g., C{position_controllers/JointTrajectoryController}
- The controller exposes the C{command} and C{state} topics in its
ROS interface.
Additionally, there must be a URDF loaded with a valid joint limit
specification, namely position (when applicable) and velocity limits.
A reference implementation of the C{JointTrajectoryController} is
available in the C{joint_trajectory_controller} ROS package.
"""
_cmd_pub_freq = 10.0 # Hz
_widget_update_freq = 30.0 # Hz
_ctrlrs_update_freq = 1 # Hz
_min_traj_dur = 5.0 / _cmd_pub_freq # Minimum trajectory duration
jointStateChanged = Signal([dict])
def __init__(self, context):
super(JointTrajectoryController, self).__init__(context)
self.setObjectName('JointTrajectoryController')
# Create QWidget and extend it with all the attributes and children
# from the UI file
self._widget = QWidget()
rp = rospkg.RosPack()
ui_file = os.path.join(rp.get_path('rqt_joint_trajectory_controller'),
'resource',
'joint_trajectory_controller.ui')
loadUi(ui_file, self._widget)
self._widget.setObjectName('JointTrajectoryControllerUi')
# Setup speed scaler
speed_scaling = DoubleEditor(1.0, 100.0)
speed_scaling.spin_box.setSuffix('%')
speed_scaling.spin_box.setValue(50.0)
speed_scaling.spin_box.setDecimals(0)
speed_scaling.setEnabled(False)
self._widget.speed_scaling_layout.addWidget(speed_scaling)
self._speed_scaling_widget = speed_scaling
speed_scaling.valueChanged.connect(self._on_speed_scaling_change)
self._on_speed_scaling_change(speed_scaling.value())
# 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 members
self._jtc_name = [] # Name of selected joint trajectory controller
self._cm_ns = [] # Namespace of the selected controller manager
self._joint_pos = {} # name->pos map for joints of selected controller
self._joint_names = [] # Ordered list of selected controller joints
self._robot_joint_limits = {} # Lazily evaluated on first use
# Timer for sending commands to active controller
self._update_cmd_timer = QTimer(self)
self._update_cmd_timer.setInterval(1000.0 / self._cmd_pub_freq)
self._update_cmd_timer.timeout.connect(self._update_cmd_cb)
# Timer for updating the joint widgets from the controller state
self._update_act_pos_timer = QTimer(self)
self._update_act_pos_timer.setInterval(1000.0 /
self._widget_update_freq)
self._update_act_pos_timer.timeout.connect(self._update_joint_widgets)
# Timer for controller manager updates
self._list_cm = ControllerManagerLister()
self._update_cm_list_timer = QTimer(self)
self._update_cm_list_timer.setInterval(1000.0 /
self._ctrlrs_update_freq)
self._update_cm_list_timer.timeout.connect(self._update_cm_list)
#.........这里部分代码省略.........