Ejemplo n.º 1
0
    def __init__(self, view, _robotSystem):
        self.view = view
        self.viewBehaviors = viewbehaviors.ViewBehaviors(view)
        self.robotViewBehaviors = RobotViewEventFilter(self, view)
        self.robotName = _robotSystem.robotName

        self.robotSystem = _robotSystem
        self.robotModel = self.robotSystem.robotStateModel
        if app.getMainWindow() is not None:
            self.robotLinkSelector = RobotLinkSelector()

        viewbehaviors.registerContextMenuActions(self.getRobotActions)
Ejemplo n.º 2
0
    def __init__(self, view, _robotSystem):
        self.view = view
        self.viewBehaviors = viewbehaviors.ViewBehaviors(view)
        self.logCommander = KeyPressLogCommander(view)
        self.robotViewBehaviors = RobotViewEventFilter(view)

        global robotSystem, robotModel, handFactory, footstepsDriver, neckDriver, robotLinkSelector

        robotSystem = _robotSystem
        robotModel = robotSystem.robotStateModel
        handFactory = robotSystem.handFactory
        footstepsDriver = robotSystem.footstepsDriver
        neckDriver = robotSystem.neckDriver
        if app.getMainWindow() is not None:
            robotLinkSelector = RobotLinkSelector()
Ejemplo n.º 3
0
    def __init__(self, robotSystem, cameraView):

        self.meshPoints = None
        self.imagePoints = None
        self.cameraView = cameraView

        self.robotMesh = vtk.vtkPolyData()
        robotSystem.robotStateModel.model.getModelMesh(self.robotMesh)
        self.robotBaseFrame = robotSystem.robotStateModel.getLinkFrame('base')

        self.view = PythonQt.dd.ddQVTKWidgetView()
        vis.showPolyData(self.robotMesh, 'robot mesh', view=self.view)

        self.imageFitter = ImageFitter(self)

        vis.showPolyData(self.imageFitter.getPointCloud(),
                         'pointcloud',
                         view=self.view,
                         colorByName='rgb_colors',
                         visible=False)

        self.picker = pointpicker.PointPicker(self.view)
        self.picker.pickType = 'cells'
        self.picker.numberOfPoints = 3
        self.picker.annotationName = 'mesh annotation'
        self.picker.annotationFunc = self.onPickPoints
        self.picker.start()

        self.widget = QtGui.QWidget()
        layout = QtGui.QHBoxLayout(self.widget)
        layout.addWidget(self.cameraView.view)
        layout.addWidget(self.view)
        self.widget.resize(800, 400)
        self.widget.setWindowTitle('Camera Alignment Tool')
        self.widget.show()

        self.viewBehaviors = viewbehaviors.ViewBehaviors(self.view)
        applogic.resetCamera(viewDirection=[0, 1, 0], view=self.view)
        applogic.setCameraTerrainModeEnabled(self.view, True)
Ejemplo n.º 4
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')
Ejemplo n.º 6
0
 def initViewBehaviors(self, fields):
     from director import viewbehaviors
     viewBehaviors = viewbehaviors.ViewBehaviors(fields.view)
     return FieldContainer(viewBehaviors=viewBehaviors)
Ejemplo n.º 7
0
    def __init__(self, cameraView, modelPolyData=None, pointCloud=None, resultsDict=None, visualize=True, callback=None):
        self.modelPolyData = modelPolyData
        self.pointCloud = pointCloud
        self.resultsDict = resultsDict
        self.visualize = visualize
        self.callback = callback
        self.parent = om.getOrCreateContainer('object alignment')

        self.meshPoints = None
        self.imagePoints = None
        self.cameraView = cameraView

        # viewer for the object
        self.view = PythonQt.dd.ddQVTKWidgetView()

        # add some special logic to show colors if they exist
        colorByName = 'RGB255'
        if not self.modelPolyData.GetPointData().GetArray(colorByName):
            colorByName = None
        vis.showPolyData(self.modelPolyData, 'object poly data', view=self.view,
                         parent=self.parent, colorByName=colorByName)

        self.imageFitter = ImageFitter(self, pointCloud)



        self.picker = pointpicker.PointPicker(self.view)
        self.picker.pickType = 'cells' # might need to change this
        self.picker.numberOfPoints = 3
        self.picker.annotationName = 'mesh annotation'
        self.picker.annotationFunc = self.onPickPoints
        self.picker.start()

        # viewer for the pointcloud
        self.sceneView = PythonQt.dd.ddQVTKWidgetView()
        vis.showPolyData(self.pointCloud, 'pointcloud', view=self.sceneView, colorByName='RGB', parent=self.parent)
        self.scenePicker = pointpicker.PointPicker(self.sceneView)
        self.scenePicker.pickType = 'points'  # might need to change this
        self.scenePicker.numberOfPoints = 3
        self.scenePicker.annotationName = 'pointcloud annotation'
        self.scenePicker.annotationFunc = self.onScenePickPoints
        self.scenePicker.start()

        # workaround bug in PointPicker implementation
        for name in [self.picker.annotationName, self.scenePicker.annotationName]:
            om.removeFromObjectModel(om.findObjectByName(name))

        self.widget = QtGui.QWidget()
        layout = QtGui.QHBoxLayout(self.widget)
        # layout.addWidget(self.cameraView.view)
        layout.addWidget(self.sceneView)
        layout.addWidget(self.view)
        # self.widget.resize(800, 400)
        self.widget.showMaximized()
        self.widget.setWindowTitle('Camera Alignment Tool')
        self.widget.show()

        self.viewBehaviors = viewbehaviors.ViewBehaviors(self.view)
        applogic.resetCamera(viewDirection=[0,1,0], view=self.view)
        applogic.setCameraTerrainModeEnabled(self.view, True)

        self.sceneViewBehaviors = viewbehaviors.ViewBehaviors(self.sceneView)
        applogic.resetCamera(viewDirection=[0, 1, 0], view=self.sceneView)
        applogic.setCameraTerrainModeEnabled(self.sceneView, True)
Ejemplo n.º 8
0
 def initPointCloudView(self):
     self.pointCloudView = PythonQt.dd.ddQVTKWidgetView()
     self.pointCloudView.setWindowTitle('Pointcloud')
     self.pointCloudViewBehaviors = viewbehaviors.ViewBehaviors(
         self.pointCloudView)
Ejemplo n.º 9
0
    def setup(self):

        args = self.parseArgs()
        imageManager = cameraview.ImageManager()
        self.imageManager = imageManager

        channel = args.channel
        imageType = args.imageType

        self.app = consoleapp.ConsoleApp()
        self.views = []

        if imageType == 'rgb':

            imageName = channel
            imageManager.queue.addCameraStream(channel, imageName, -1)
            imageManager.addImage(imageName)
            cameraView = cameraview.CameraImageView(
                imageManager, imageName, view=PythonQt.dd.ddQVTKWidgetView())
            cameraView.eventFilterEnabled = False
            cameraView.view.renderWindow().GetInteractor().SetInteractorStyle(
                vtk.vtkInteractorStyleImage())
            cameraView.view.resize(640, 480)
            self.views.append(cameraView.view)
            self.cameraView = cameraView

        elif imageType == 'rgbd':

            imageName = channel + '_LEFT'
            imageManager.queue.addCameraStream(channel, imageName, 0)
            imageManager.addImage(imageName)
            cameraView = cameraview.CameraImageView(
                imageManager, imageName, view=PythonQt.dd.ddQVTKWidgetView())
            cameraView.eventFilterEnabled = False
            cameraView.view.renderWindow().GetInteractor().SetInteractorStyle(
                vtk.vtkInteractorStyleImage())
            self.views.append(cameraView.view)

            imageName2 = channel + '_D'
            if args.disparity:
                imageManager.queue.addCameraStream(
                    channel, imageName2, lcmbotcore.images_t.DISPARITY_ZIPPED)
            else:
                imageManager.queue.addCameraStream(
                    channel, imageName2, lcmbotcore.images_t.DEPTH_MM_ZIPPED)
            imageManager.addImage(imageName2)
            cameraView2 = cameraview.CameraImageView(
                imageManager, imageName2, view=PythonQt.dd.ddQVTKWidgetView())
            cameraView2.eventFilterEnabled = False
            cameraView2.useImageColorMap = True
            cameraView2.view.renderWindow().GetInteractor().SetInteractorStyle(
                vtk.vtkInteractorStyleImage())
            self.views.append(cameraView2.view)

            if args.pointcloud:
                from director import segmentation
                cameraview.imageManager = imageManager
                pointCloudObj = segmentation.DisparityPointCloudItem(
                    'Point cloud', channel, imageName, imageManager)
                view = PythonQt.dd.ddQVTKWidgetView()
                pointCloudObj.addToView(view)
                om.addToObjectModel(pointCloudObj)
                pointCloudObj.setProperty('Visible', True)
                pointCloudObj.setProperty('Target FPS', 30)
                pointCloudObj.setProperty('Max Range', 30)
                pointCloudObj.setProperty('Remove Size', 0)
                viewBehaviors = viewbehaviors.ViewBehaviors(view)
                view.camera().SetPosition([0, 0, 0])
                view.camera().SetFocalPoint([0, 0, 1])
                view.camera().SetViewUp([0, -1, 0])
                view.camera().SetViewAngle(45)
                self.views.append(view)

            self.cameraView = cameraView
            self.cameraView2 = cameraView2

        w = QtGui.QWidget()
        l = QtGui.QHBoxLayout(w)
        for view in self.views:
            l.addWidget(view)
        l.setContentsMargins(0, 0, 0, 0)
        w.resize(640 * len(self.views), 480)
        w.show()
        self.addShortcuts(w)
        self.widget = w