I am not able to run my python ros file which is in the form of qtdesigner4 and also I am not getting any error and the problem is my widget is not getting launched

asked 2019-03-15 01:52:57 -0500

updated 2019-03-15 04:14:23 -0500

#!/usr/bin/python import os import rospkg import rospy

from dof_pkg.msg import arm_msgs

from qt_gui.plugin import Plugin from python_qt_binding import loadUi from python_qt_binding.QtCore import Qt, QTimer, Slot from python_qt_binding.QtGui import QKeySequence from python_qt_binding.QtWidgets import QWidget

class dof(Plugin): slider_factor = 0.55 global var1 var1=None global var2 var2=None global var3 var3=None global var4 var4=None global var5 var5=None global dof6 var6=None global dofstrvalues

global dof_val

#global var1

#global var2

#global var3

#global var4

#global var5

#global var6

def __init__(self, context):
    super(dof, self).__init__(context)
    # Give QObjects reasonable names
    rp = rospkg.RosPack()

    # 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",
                  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(rp.get_path('dof_pkg'), 'resource', 'dofgui.ui')
    # Extend the widget with all attributes and children from UI file
    loadUi(ui_file, self._widget)
    # Give QObjects reasonable names
    # 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
    #self._update_parameter_timer = QTimer(self)
    #self.zero_cmd_sent = False

def _on_dof1_changed(self,dof1val):
    global var1
    var1 = int(dof1val)

def _on_dof2_changed(self,dof2val):
    global var2
    var2= int(dof2val)

def _on_dof3_changed(self,dof3val):
    global var3
    var3= int(dof3val)

def _on_dof4_changed(self,dof4val):
    global var4
    var4= int(dof4val)

def _on_dof5_changed(self,dof5val):
    global var5
    var5= int(dof5val)

def _on_dof6_changed(self,dof6val):
    global var6
    var6= int(dof6val)

def _on_button_clicked(self):
    global dof_val
    global dofstrvalues
    dofstrvalues = arm_msgs()

    dofstrvalues.dofvalues = [var1,var2,var3,var4,var5,var6]

        self._publisher = rospy.Publisher("test1", arm_msgs, queue_size=10)
    except TypeError:
        self._publisher = rospy.Publisher("test1", arm_msgs)

def shutdown_plugin(self):
    # TODO unregister all publishers here

def save_settings(self, plugin_settings, instance_settings):
    # TODO save intrinsic configuration, usually using:
    # instance_settings.set_value(k, v)

def restore_settings(self, plugin_settings, instance_settings):
    # TODO restore intrinsic configuration, usually using:
    # v = instance_settings.value(k)

#def trigger_configuration(self):
    # Comment ...
edit retag flag offensive close merge delete