Esempio n. 1
0
    def __init__(self):

        om.init()
        self.view = PythonQt.dd.ddQVTKWidgetView()

        # init grid
        self.gridObj = vis.showGrid(self.view, parent='scene')
        self.gridObj.setProperty('Surface Mode', 'Surface with edges')
        self.gridObj.setProperty('Color', [0,0,0])
        self.gridObj.setProperty('Alpha', 0.1)

        # init view options
        self.viewOptions = vis.ViewOptionsItem(self.view)
        om.addToObjectModel(self.viewOptions, parentObj=om.findObjectByName('scene'))
        self.viewOptions.setProperty('Background color', [0.3, 0.3, 0.35])
        self.viewOptions.setProperty('Background color 2', [0.95,0.95,1])

        # setup camera
        applogic.setCameraTerrainModeEnabled(self.view, True)
        applogic.resetCamera(viewDirection=[-1, 0, -0.3], view=self.view)

        # add view behaviors
        viewBehaviors = viewbehaviors.ViewBehaviors(self.view)
        applogic._defaultRenderView = self.view

        self.mainWindow = QtGui.QMainWindow()
        self.mainWindow.setCentralWidget(self.view)
        self.mainWindow.resize(768 * (16/9.0), 768)
        self.mainWindow.setWindowTitle('Drake Visualizer')
        self.mainWindow.setWindowIcon(QtGui.QIcon(':/images/drake_logo.png'))
        self.mainWindow.show()

        self.drakeVisualizer = DrakeVisualizer(self.view)
        self.lcmglManager = lcmgl.LCMGLManager(self.view) if lcmgl.LCMGL_AVAILABLE else None

        self.screenGrabberPanel = ScreenGrabberPanel(self.view)
        self.screenGrabberDock = self.addWidgetToDock(self.screenGrabberPanel.widget, QtCore.Qt.RightDockWidgetArea)
        self.screenGrabberDock.setVisible(False)

        self.cameraBookmarksPanel = camerabookmarks.CameraBookmarkWidget(self.view)
        self.cameraBookmarksDock = self.addWidgetToDock(self.cameraBookmarksPanel.widget, QtCore.Qt.RightDockWidgetArea)
        self.cameraBookmarksDock.setVisible(False)

        model = om.getDefaultObjectModel()
        model.getTreeWidget().setWindowTitle('Scene Browser')
        model.getPropertiesPanel().setWindowTitle('Properties Panel')
        model.setActiveObject(self.viewOptions)

        self.sceneBrowserDock = self.addWidgetToDock(model.getTreeWidget(), QtCore.Qt.LeftDockWidgetArea)
        self.propertiesDock = self.addWidgetToDock(self.wrapScrollArea(model.getPropertiesPanel()), QtCore.Qt.LeftDockWidgetArea)
        self.sceneBrowserDock.setVisible(False)
        self.propertiesDock.setVisible(False)

        applogic.addShortcut(self.mainWindow, 'Ctrl+Q', self.applicationInstance().quit)
        applogic.addShortcut(self.mainWindow, 'F1', self._toggleObjectModel)
        applogic.addShortcut(self.mainWindow, 'F2', self._toggleScreenGrabber)
        applogic.addShortcut(self.mainWindow, 'F3', self._toggleCameraBookmarks)
        applogic.addShortcut(self.mainWindow, 'F8', applogic.showPythonConsole)
Esempio n. 2
0
    def initMainWindow(self, fields):

        organizationName = "RobotLocomotion"
        applicationName = "DirectorMainWindow"
        windowTitle = "Director App"

        if hasattr(fields, "organizationName"):
            organizationName = fields.organizationName
        if hasattr(fields, "applicationName"):
            applicationName = fields.applicationName
        if hasattr(fields, "windowTitle"):
            windowTitle = fields.windowTitle

        MainWindowApp.applicationInstance().setOrganizationName(
            organizationName)
        MainWindowApp.applicationInstance().setApplicationName(applicationName)

        app = MainWindowApp()

        app.mainWindow.setCentralWidget(fields.view)
        app.mainWindow.setWindowTitle(windowTitle)
        app.mainWindow.setWindowIcon(QtGui.QIcon(":/images/drake_logo.png"))

        sceneBrowserDock = app.addWidgetToDock(
            fields.objectModel.getTreeWidget(),
            QtCore.Qt.LeftDockWidgetArea,
            visible=True,
        )
        propertiesDock = app.addWidgetToDock(
            app.wrapScrollArea(fields.objectModel.getPropertiesPanel()),
            QtCore.Qt.LeftDockWidgetArea,
            visible=True,
        )

        app.addViewMenuSeparator()

        def toggleObjectModelDock():
            newState = not sceneBrowserDock.visible
            sceneBrowserDock.setVisible(newState)
            propertiesDock.setVisible(newState)

        applogic.addShortcut(app.mainWindow, "F1", toggleObjectModelDock)
        # applogic.addShortcut(app.mainWindow, 'F8', app.showPythonConsole)

        return FieldContainer(
            app=app,
            mainWindow=app.mainWindow,
            sceneBrowserDock=sceneBrowserDock,
            propertiesDock=propertiesDock,
            toggleObjectModelDock=toggleObjectModelDock,
            commandLineArgs=drcargs.args(),
        )
Esempio n. 3
0
    def initMainWindow(self, fields):

        from director import viewcolors

        organizationName = 'RobotLocomotion'
        applicationName = 'DirectorMainWindow'
        windowTitle = 'Director App'

        if hasattr(fields, 'organizationName'):
            organizationName = fields.organizationName
        if hasattr(fields, 'applicationName'):
            applicationName = fields.applicationName
        if hasattr(fields, 'windowTitle'):
            windowTitle = fields.windowTitle

        MainWindowApp.applicationInstance().setOrganizationName(organizationName)
        MainWindowApp.applicationInstance().setApplicationName(applicationName)


        app = MainWindowApp()

        app.mainWindow.setCentralWidget(fields.view)
        app.mainWindow.setWindowTitle(windowTitle)
        app.mainWindow.setWindowIcon(QtGui.QIcon(':/images/drake_logo.png'))

        sceneBrowserDock = app.addWidgetToDock(fields.objectModel.getTreeWidget(),
                              QtCore.Qt.LeftDockWidgetArea, visible=True)
        propertiesDock = app.addWidgetToDock(app.wrapScrollArea(fields.objectModel.getPropertiesPanel()),
                              QtCore.Qt.LeftDockWidgetArea, visible=True)

        app.addViewMenuSeparator()

        def toggleObjectModelDock():
            newState = not sceneBrowserDock.visible
            sceneBrowserDock.setVisible(newState)
            propertiesDock.setVisible(newState)

        applogic.addShortcut(app.mainWindow, 'F1', toggleObjectModelDock)
        #applogic.addShortcut(app.mainWindow, 'F8', app.showPythonConsole)



        return FieldContainer(
          app=app,
          mainWindow=app.mainWindow,
          sceneBrowserDock=sceneBrowserDock,
          propertiesDock=propertiesDock,
          toggleObjectModelDock=toggleObjectModelDock,
          commandLineArgs=drcargs.args()
          )
Esempio n. 4
0
    def showObjectModel(self):

        if not self.objectModelWidget:
            w = QtGui.QWidget()
            l = QtGui.QVBoxLayout(w)
            model = om.getDefaultObjectModel()
            l.addWidget(model.getTreeWidget())
            l.addWidget(model.getPropertiesPanel())
            applogic.addShortcut(w, 'Ctrl+Q', self.quit)
            self.objectModelWidget = w
            self.objectModelWidget.resize(350, 700)

        self.objectModelWidget.show()
        self.objectModelWidget.raise_()
        self.objectModelWidget.activateWindow()
        return self.objectModelWidget
Esempio n. 5
0
    def showObjectModel(self):

        if not self.objectModelWidget:
            w = QtGui.QWidget()
            l = QtGui.QVBoxLayout(w)
            model = om.getDefaultObjectModel()
            l.addWidget(model.getTreeWidget())
            l.addWidget(model.getPropertiesPanel())
            applogic.addShortcut(w, "Ctrl+Q", self.quit)
            self.objectModelWidget = w
            self.objectModelWidget.resize(350, 700)

        self.objectModelWidget.show()
        self.objectModelWidget.raise_()
        self.objectModelWidget.activateWindow()
        return self.objectModelWidget
Esempio n. 6
0
    def initMainWindow(self, fields):

        from director import viewcolors

        organizationName = 'RobotLocomotion'
        applicationName = 'DirectorMainWindow'

        if hasattr(fields, 'organizationName'):
            organizationName = fields.organizationName
        if hasattr(fields, 'applicationName'):
            applicationName = fields.applicationName

        MainWindowApp.applicationInstance().setOrganizationName(
            organizationName)
        MainWindowApp.applicationInstance().setApplicationName(applicationName)

        app = MainWindowApp()

        app.mainWindow.setCentralWidget(fields.view)
        app.mainWindow.setWindowTitle('Director App')
        app.mainWindow.setWindowIcon(QtGui.QIcon(':/images/drake_logo.png'))

        sceneBrowserDock = app.addWidgetToDock(
            fields.objectModel.getTreeWidget(),
            QtCore.Qt.LeftDockWidgetArea,
            visible=True)
        propertiesDock = app.addWidgetToDock(app.wrapScrollArea(
            fields.objectModel.getPropertiesPanel()),
                                             QtCore.Qt.LeftDockWidgetArea,
                                             visible=True)

        app.addViewMenuSeparator()

        def toggleObjectModelDock():
            newState = not sceneBrowserDock.visible
            sceneBrowserDock.setVisible(newState)
            propertiesDock.setVisible(newState)

        applogic.addShortcut(app.mainWindow, 'F1', toggleObjectModelDock)
        #applogic.addShortcut(app.mainWindow, 'F8', app.showPythonConsole)

        return FieldContainer(app=app,
                              mainWindow=app.mainWindow,
                              sceneBrowserDock=sceneBrowserDock,
                              propertiesDock=propertiesDock,
                              toggleObjectModelDock=toggleObjectModelDock)
Esempio n. 7
0
    def showObjectModel(self):

        if not self.objectModelWidget:
            w = QtGui.QSplitter(QtCore.Qt.Vertical)
            model = om.getDefaultObjectModel()
            w.addWidget(model.getTreeWidget())
            sw = QtGui.QScrollArea()
            sw.setWidget(model.getPropertiesPanel())
            sw.setWidgetResizable(True)
            w.addWidget(sw)
            applogic.addShortcut(w, 'Ctrl+Q', self.quit)
            self.objectModelWidget = w
            self.objectModelWidget.resize(350, 700)
            w.setSizes([350, 350])

        self.objectModelWidget.show()
        self.objectModelWidget.raise_()
        self.objectModelWidget.activateWindow()
        return self.objectModelWidget
Esempio n. 8
0
    def showObjectModel(self):

        if not self.objectModelWidget:
            w = QtGui.QSplitter(QtCore.Qt.Vertical)
            model = om.getDefaultObjectModel()
            w.addWidget(model.getTreeWidget())
            sw = QtGui.QScrollArea()
            sw.setWidget(model.getPropertiesPanel())
            sw.setWidgetResizable(True)
            w.addWidget(sw)
            applogic.addShortcut(w, 'Ctrl+Q', self.quit)
            self.objectModelWidget = w
            self.objectModelWidget.resize(350, 700)
            w.setSizes([350, 350])

        self.objectModelWidget.show()
        self.objectModelWidget.raise_()
        self.objectModelWidget.activateWindow()
        return self.objectModelWidget
Esempio n. 9
0
    def createView(self, useGrid=True):
        view = PythonQt.dd.ddQVTKWidgetView()
        view.resize(600, 400)

        applogic.setCameraTerrainModeEnabled(view, True)
        if useGrid:
            self.gridObj = vis.showGrid(view, parent='scene')

        self.viewOptions = vis.ViewOptionsItem(view)
        om.addToObjectModel(self.viewOptions, parentObj=om.findObjectByName('scene'))

        applogic.resetCamera(viewDirection=[-1,-1,-0.3], view=view)
        self.viewBehaviors = viewbehaviors.ViewBehaviors(view)
        applogic._defaultRenderView = view

        applogic.addShortcut(view, 'Ctrl+Q', self.quit)
        applogic.addShortcut(view, 'F8', self.showPythonConsole)
        applogic.addShortcut(view, 'F1', self.showObjectModel)

        view.setWindowIcon(om.Icons.getIcon(om.Icons.Robot))
        view.setWindowTitle('View')

        return view
Esempio n. 10
0
    def createView(self, useGrid=True):
        view = PythonQt.dd.ddQVTKWidgetView()
        view.resize(600, 400)

        applogic.setCameraTerrainModeEnabled(view, True)
        if useGrid:
            self.gridObj = vis.showGrid(view, parent='scene')

        self.viewOptions = vis.ViewOptionsItem(view)
        om.addToObjectModel(self.viewOptions, parentObj=om.findObjectByName('scene'))

        applogic.resetCamera(viewDirection=[-1,-1,-0.3], view=view)
        self.viewBehaviors = viewbehaviors.ViewBehaviors(view)
        applogic._defaultRenderView = view

        applogic.addShortcut(view, 'Ctrl+Q', self.quit)
        applogic.addShortcut(view, 'F8', self.showPythonConsole)
        applogic.addShortcut(view, 'F1', self.showObjectModel)

        view.setWindowIcon(om.Icons.getIcon(om.Icons.Robot))
        view.setWindowTitle('View')

        return view
    def __init__(self):

        self.applicationInstance().setOrganizationName('RobotLocomotionGroup')
        self.applicationInstance().setApplicationName('drake-visualizer')

        om.init()
        self.view = PythonQt.dd.ddQVTKWidgetView()

        # init grid
        self.gridObj = vis.showGrid(self.view, parent='scene')
        self.gridObj.setProperty('Surface Mode', 'Surface with edges')
        self.gridObj.setProperty('Color', [0, 0, 0])
        self.gridObj.setProperty('Alpha', 0.1)

        # init view options
        self.viewOptions = vis.ViewOptionsItem(self.view)
        om.addToObjectModel(self.viewOptions,
                            parentObj=om.findObjectByName('scene'))
        self.viewOptions.setProperty('Background color', [0.3, 0.3, 0.35])
        self.viewOptions.setProperty('Background color 2', [0.95, 0.95, 1])

        # setup camera
        applogic.setCameraTerrainModeEnabled(self.view, True)
        applogic.resetCamera(viewDirection=[-1, 0, -0.3], view=self.view)

        # This setting improves the near plane clipping resolution.
        # Drake often draws a very large ground plane which is detrimental to
        # the near clipping for up close objects.  The trade-off is Z buffer
        # resolution but in practice things look good with this setting.
        self.view.renderer().SetNearClippingPlaneTolerance(0.0005)

        # add view behaviors
        self.viewBehaviors = viewbehaviors.ViewBehaviors(self.view)
        applogic._defaultRenderView = self.view

        self.mainWindow = QtGui.QMainWindow()
        self.mainWindow.setCentralWidget(self.view)
        self.mainWindow.resize(768 * (16 / 9.0), 768)
        self.mainWindow.setWindowTitle('Drake Visualizer')
        self.mainWindow.setWindowIcon(QtGui.QIcon(':/images/drake_logo.png'))

        self.settings = QtCore.QSettings()

        self.fileMenu = self.mainWindow.menuBar().addMenu('&File')
        self.viewMenu = self.mainWindow.menuBar().addMenu('&View')
        self.viewMenuManager = PythonQt.dd.ddViewMenu(self.viewMenu)

        self.drakeVisualizer = DrakeVisualizer(self.view)
        self.lcmglManager = lcmgl.LCMGLManager(
            self.view) if lcmgl.LCMGL_AVAILABLE else None

        model = om.getDefaultObjectModel()
        model.getTreeWidget().setWindowTitle('Scene Browser')
        model.getPropertiesPanel().setWindowTitle('Properties Panel')

        self.sceneBrowserDock = self.addWidgetToDock(
            model.getTreeWidget(), QtCore.Qt.LeftDockWidgetArea, visible=False)
        self.propertiesDock = self.addWidgetToDock(
            self.wrapScrollArea(model.getPropertiesPanel()),
            QtCore.Qt.LeftDockWidgetArea,
            visible=False)

        self.addViewMenuSeparator()

        self.screenGrabberPanel = ScreenGrabberPanel(self.view)
        self.screenGrabberDock = self.addWidgetToDock(
            self.screenGrabberPanel.widget,
            QtCore.Qt.RightDockWidgetArea,
            visible=False)

        self.cameraBookmarksPanel = camerabookmarks.CameraBookmarkWidget(
            self.view)
        self.cameraBookmarksDock = self.addWidgetToDock(
            self.cameraBookmarksPanel.widget,
            QtCore.Qt.RightDockWidgetArea,
            visible=False)

        self.cameraControlPanel = cameracontrolpanel.CameraControlPanel(
            self.view)
        self.cameraControlDock = self.addWidgetToDock(
            self.cameraControlPanel.widget,
            QtCore.Qt.RightDockWidgetArea,
            visible=False)

        act = self.fileMenu.addAction('&Quit')
        act.setShortcut(QtGui.QKeySequence('Ctrl+Q'))
        act.connect('triggered()', self.applicationInstance().quit)

        self.fileMenu.addSeparator()

        act = self.fileMenu.addAction('&Open Data...')
        act.setShortcut(QtGui.QKeySequence('Ctrl+O'))
        act.connect('triggered()', self._onOpenDataFile)

        applogic.addShortcut(self.mainWindow, 'F1', self._toggleObjectModel)
        applogic.addShortcut(self.mainWindow, 'F8', applogic.showPythonConsole)
        self.applicationInstance().connect('aboutToQuit()',
                                           self._onAboutToQuit)

        for obj in om.getObjects():
            obj.setProperty('Deletable', False)

        self.mainWindow.show()
        self._saveWindowState('MainWindowDefault')
        self._restoreWindowState('MainWindowCustom')
Esempio n. 12
0
    def __init__(self):

        self.applicationInstance().setOrganizationName("RobotLocomotionGroup")
        self.applicationInstance().setApplicationName("drake-visualizer")

        om.init()
        self.view = PythonQt.dd.ddQVTKWidgetView()

        # init grid
        self.gridObj = vis.showGrid(self.view, parent="scene")
        self.gridObj.setProperty("Surface Mode", "Surface with edges")
        self.gridObj.setProperty("Color", [0, 0, 0])
        self.gridObj.setProperty("Alpha", 0.1)

        # init view options
        self.viewOptions = vis.ViewOptionsItem(self.view)
        om.addToObjectModel(self.viewOptions, parentObj=om.findObjectByName("scene"))
        self.viewOptions.setProperty("Background color", [0.3, 0.3, 0.35])
        self.viewOptions.setProperty("Background color 2", [0.95, 0.95, 1])

        # setup camera
        applogic.setCameraTerrainModeEnabled(self.view, True)
        applogic.resetCamera(viewDirection=[-1, 0, -0.3], view=self.view)

        # This setting improves the near plane clipping resolution.
        # Drake often draws a very large ground plane which is detrimental to
        # the near clipping for up close objects.  The trade-off is Z buffer
        # resolution but in practice things look good with this setting.
        self.view.renderer().SetNearClippingPlaneTolerance(0.0005)

        # add view behaviors
        self.viewBehaviors = viewbehaviors.ViewBehaviors(self.view)
        applogic._defaultRenderView = self.view

        self.mainWindow = QtGui.QMainWindow()
        self.mainWindow.setCentralWidget(self.view)
        self.mainWindow.resize(768 * (16 / 9.0), 768)
        self.mainWindow.setWindowTitle("Drake Visualizer")
        self.mainWindow.setWindowIcon(QtGui.QIcon(":/images/drake_logo.png"))

        self.settings = QtCore.QSettings()

        self.fileMenu = self.mainWindow.menuBar().addMenu("&File")
        self.viewMenu = self.mainWindow.menuBar().addMenu("&View")
        self.viewMenuManager = PythonQt.dd.ddViewMenu(self.viewMenu)

        self.drakeVisualizer = DrakeVisualizer(self.view)
        self.lcmglManager = lcmgl.LCMGLManager(self.view) if lcmgl.LCMGL_AVAILABLE else None

        model = om.getDefaultObjectModel()
        model.getTreeWidget().setWindowTitle("Scene Browser")
        model.getPropertiesPanel().setWindowTitle("Properties Panel")

        self.sceneBrowserDock = self.addWidgetToDock(model.getTreeWidget(), QtCore.Qt.LeftDockWidgetArea, visible=False)
        self.propertiesDock = self.addWidgetToDock(
            self.wrapScrollArea(model.getPropertiesPanel()), QtCore.Qt.LeftDockWidgetArea, visible=False
        )

        self.addViewMenuSeparator()

        self.screenGrabberPanel = ScreenGrabberPanel(self.view)
        self.screenGrabberDock = self.addWidgetToDock(
            self.screenGrabberPanel.widget, QtCore.Qt.RightDockWidgetArea, visible=False
        )

        self.cameraBookmarksPanel = camerabookmarks.CameraBookmarkWidget(self.view)
        self.cameraBookmarksDock = self.addWidgetToDock(
            self.cameraBookmarksPanel.widget, QtCore.Qt.RightDockWidgetArea, visible=False
        )

        self.cameraControlPanel = cameracontrolpanel.CameraControlPanel(self.view)
        self.cameraControlDock = self.addWidgetToDock(
            self.cameraControlPanel.widget, QtCore.Qt.RightDockWidgetArea, visible=False
        )

        act = self.fileMenu.addAction("&Quit")
        act.setShortcut(QtGui.QKeySequence("Ctrl+Q"))
        act.connect("triggered()", self.applicationInstance().quit)

        self.fileMenu.addSeparator()

        act = self.fileMenu.addAction("&Open Data...")
        act.setShortcut(QtGui.QKeySequence("Ctrl+O"))
        act.connect("triggered()", self._onOpenDataFile)

        applogic.addShortcut(self.mainWindow, "F1", self._toggleObjectModel)
        applogic.addShortcut(self.mainWindow, "F8", applogic.showPythonConsole)
        self.applicationInstance().connect("aboutToQuit()", self._onAboutToQuit)

        for obj in om.getObjects():
            obj.setProperty("Deletable", False)

        self.mainWindow.show()
        self._saveWindowState("MainWindowDefault")
        self._restoreWindowState("MainWindowCustom")
Esempio n. 13
0
            self.lc.publish("PD_CONFIG", msg.encode())
            time.sleep(self.ramp_up_time / 100.0)
        # store previous kp kd gains
        self.kp_ = msg.kp
        self.kd_ = msg.kd
        self.prev_pos_ = msg.desired_position

    def setState_clicked(self):
        self.lc.handle_timeout(100)
        self.lc.handle_timeout(100)  #twice to clear the buffer

    def state_handler(self, channel, data):
        msg = dairlib.lcmt_robot_output.decode(data)
        for idx_msg, joint in enumerate(msg.position_names):
            if joint in position_names:
                idx = position_names.index(joint)
                self.ledits[idx].setValue(msg.position[idx_msg])
                self.values[idx] = msg.position[idx_msg]
        print('message handled')
        print(msg.position[6])


panel = ControllerGui()
app.addWidgetToDock(panel, QtCore.Qt.RightDockWidgetArea)

import director.openscope as scope
import subprocess
view = applogic.getMainWindow()
applogic.addShortcut(view, 'Ctrl+I', scope.startSignalScope)
Esempio n. 14
0
 def addShortcuts(self, widget):
     applogic.addShortcut(widget, 'Ctrl+Q', consoleapp.ConsoleApp.quit)
     applogic.addShortcut(widget, 'F8',
                          consoleapp.ConsoleApp.showPythonConsole)
Esempio n. 15
0
 def addShortcuts(self, widget):
     applogic.addShortcut(widget, 'Ctrl+Q', consoleapp.ConsoleApp.quit)
     applogic.addShortcut(widget, 'F8', consoleapp.ConsoleApp.showPythonConsole)