Ejemplo n.º 1
0
def onOpenGeometry(filename):

    if filename.lower().endswith("wrl"):
        onOpenVrml(filename)
        return

    polyData = io.readPolyData(filename)

    if not polyData or not polyData.GetNumberOfPoints():
        app.showErrorMessage("Failed to read any data from file: %s" %
                             filename,
                             title="Reader error")
        return

    vis.showPolyData(polyData, os.path.basename(filename), parent="files")
Ejemplo n.º 2
0
    def openGeometry(self, filename):

        if filename.lower().endswith("wrl"):
            self.onOpenVrml(filename)
            return

        polyData = ioutils.readPolyData(filename)

        if not polyData or not polyData.GetNumberOfPoints():
            self.app.showErrorMessage(
                "Failed to read any data from file: %s" % filename, title="Reader error"
            )
            return

        obj = vis.showPolyData(
            polyData, os.path.basename(filename), parent=self.getRootFolder()
        )
        vis.addChildFrame(obj)
Ejemplo n.º 3
0
    def updateGeometryFromProperties(self):
        filename = self.getProperty("Filename")

        if not filename:
            polyData = vtk.vtkPolyData()
        else:
            polyData = self.getMeshManager().get(filename)

        if not polyData:

            if not os.path.isabs(filename):
                filename = os.path.join(director.getDRCBaseDir(), filename)

            if os.path.isfile(filename):
                polyData = ioutils.readPolyData(filename)
            else:
                # use axes as a placeholder mesh
                d = DebugData()
                d.addFrame(vtk.vtkTransform(), scale=0.1, tubeRadius=0.005)
                polyData = d.getPolyData()

        self.setPolyData(polyData)
Ejemplo n.º 4
0
robot_config = drcargs.getRobotConfig()
urdf_path = os.path.join(robot_config.dirname,
                         robot_config['urdfConfig']['default'])
robotStateModel, robotStateJointController = roboturdf.loadRobotModel(
    'robot state model',
    view,
    parent='sensors',
    urdfFile=urdf_path,
    color=roboturdf.getRobotGrayColor(),
    visible=True)
segmentationroutines.SegmentationContext.initWithRobot(robotStateModel)

# load poly data
dataDir = app.getTestingDataDirectory()
polyData = ioutils.readPolyData(
    os.path.join(dataDir, 'misc/valve/valve-sparse-stereo.pcd'))
vis.showPolyData(polyData,
                 'pointcloud snapshot original',
                 colorByName='rgb_colors')
polyData = segmentationroutines.sparsifyStereoCloud(polyData)
vis.showPolyData(polyData, 'pointcloud snapshot')

# fit valve and lever
segmentation.segmentValveWallAuto(
    .2, mode='valve', removeGroundMethod=segmentation.removeGroundSimple)

if app.getTestingInteractiveEnabled():

    v = applogic.getCurrentView()
    v.camera().SetPosition([3, 3, 3])
    v.camera().SetFocalPoint([0, 0, 0])
Ejemplo n.º 5
0
    'robot state model',
    view,
    parent='sensors',
    urdfFile=urdf_path,
    color=roboturdf.getRobotGrayColor(),
    visible=True)
segmentationroutines.SegmentationContext.initWithRobot(robotStateModel)

# Move robot to near to table:
robotStateJointController.q[5] = math.radians(120)
robotStateJointController.q[0] = -1.5
robotStateJointController.q[1] = 2
robotStateJointController.q[2] = 0.95
robotStateJointController.push()

# load poly data
dataDir = app.getTestingDataDirectory()
polyData = ioutils.readPolyData(
    os.path.join(dataDir, 'misc/tabletop/table-and-bin-scene.vtp'))
vis.showPolyData(polyData, 'pointcloud snapshot')

p1 = [-1.58661389, 2.91242337, 0.79958105]
data = segmentation.segmentTableScene(polyData, p1)
vis.showClusterObjects(data.clusters, parent='segmentation')
segmentation.showTable(data.table, parent='segmentation')

if app.getTestingInteractiveEnabled():
    view.show()
    app.showObjectModel()
    app.start()
Ejemplo n.º 6
0
def loadTableTopPointCloud():
    dataDir = app.getTestingDataDirectory()
    polyData = ioutils.readPolyData(os.path.join(dataDir, 'tabletop/table-and-door-scene.vtp'))
    return vis.showPolyData(polyData, 'pointcloud snapshot')
Ejemplo n.º 7
0

app = ConsoleApp()

# create a view
view = app.createView()
segmentation._defaultSegmentationView = view

robot_config = drcargs.getRobotConfig()
urdf_path = os.path.join(robot_config.dirname, robot_config['urdfConfig']['default'])
robotStateModel, robotStateJointController = roboturdf.loadRobotModel('robot state model', view, parent='sensors', urdfFile = urdf_path, color=roboturdf.getRobotGrayColor(), visible=True)
segmentationroutines.SegmentationContext.initWithRobot(robotStateModel)

# load poly data
dataDir = app.getTestingDataDirectory()
polyData = ioutils.readPolyData(os.path.join(dataDir, 'misc/amazon-pod/01-small-changes.vtp'))
vis.showPolyData(polyData, 'pointcloud snapshot', visible=False)

# remove ground and clip to just the pod:
groundPoints, polyData = segmentation.removeGround(polyData)
vis.showPolyData(polyData, 'scene', visible=False)
polyData = segmentation.addCoordArraysToPolyData(polyData)
polyData = segmentation.thresholdPoints(polyData, 'y', [1, 1.6])
polyData = segmentation.thresholdPoints(polyData, 'x', [-1.2, 0.5])
vis.showPolyData(polyData, 'clipped', visible=False)

# remove outliers
polyData = segmentation.labelOutliers(polyData, searchRadius=0.03, neighborsInSearchRadius=40)
polyData = segmentation.thresholdPoints(polyData, 'is_outlier', [0, 0])
vis.showPolyData(polyData, 'inliers', visible=False)
Ejemplo n.º 8
0
#robotStateJointController.q [0] = 1
#robotStateJointController.q [1] = 1

#robotStateJointController.q[2] = 0.85
#robotStateJointController.push()



groundHeight = 0.0
viewFrame = segmentation.transformUtils.frameFromPositionAndRPY([1, 1, groundHeight + 1.5], [0, 0, -120])

segmentationroutines.SegmentationContext.initWithUser(groundHeight, viewFrame)




# load poly data
dataDir = app.getTestingDataDirectory()
#polyData = ioUtils.readPolyData(os.path.join(dataDir, 'valve/valve-lever-scene.vtp'))
#polyData = ioUtils.readPolyData(os.path.join(dataDir, 'valve/valve-lever-scene-30.vtp'))
#polyData = ioUtils.readPolyData(os.path.join(dataDir, 'valve/valve-lever-scene-60.vtp'))
polyData = ioutils.readPolyData(os.path.join(dataDir, 'misc/valve/valve-lever-scene-90.vtp'))
vis.showPolyData(polyData, 'pointcloud snapshot')

segmentation.segmentValveWallAuto(.2, mode='both', removeGroundMethod=segmentation.removeGround )

if app.getTestingInteractiveEnabled():
    view.show()
    app.showObjectModel()
    app.start()
Ejemplo n.º 9
0
app = ConsoleApp()

# create a view
view = app.createView()
segmentation._defaultSegmentationView = view


# load poly data
dataDir = app.getTestingDataDirectory()

filename = os.path.join(dataDir, 'terrain/tilted_steps_lidar.pcd')
#filename = os.path.join(dataDir, 'BigBIRD/tapatio_hot_sauce/meshes/poisson.ply')
#filename = os.path.join(dataDir, 'BigBIRD/cheez_it_white_cheddar/meshes/poisson.ply')

name = 'terrain'
polyData = ioutils.readPolyData(filename)
vis.showPolyData(polyData, name, visible=False)


useTerrainOptions = True

if useTerrainOptions:
    removeGround = True
    useVoxelGrid = True
    reorientNormals = False
    testNormals = False
    showGlyphs = False
    testPlaneSegmentation = True

else:
    removeGround = False
Ejemplo n.º 10
0
robotStateJointController.q[0] = 0.728
robotStateJointController.q[1] = -0.7596
robotStateJointController.q[2] = 0.79788
robotStateJointController.q[33] = 0.5 # head down
robotStateJointController.push()
'''

groundHeight = 0.0
viewFrame = segmentation.transformUtils.frameFromPositionAndRPY(
    [1, -1, groundHeight + 1.5], [0, 0, -35])

segmentationroutines.SegmentationContext.initWithUser(groundHeight, viewFrame)

# load poly data
dataDir = app.getTestingDataDirectory()
polyData = ioutils.readPolyData(
    os.path.join(dataDir, 'misc/tabletop/table-sparse-stereo.vtp'))
vis.showPolyData(polyData,
                 'pointcloud snapshot original',
                 colorByName='rgb_colors')
#polyData = segmentationroutines.sparsifyStereoCloud( polyData )
vis.showPolyData(polyData, 'pointcloud snapshot')

# Use only returns near the robot:
polyData = segmentation.addCoordArraysToPolyData(polyData)
polyData = segmentation.thresholdPoints(polyData, 'distance_along_view_x',
                                        [0, 1.3])

# I removed segmentTableThenFindDrills() because it used a depreciated function:
#segmentation.segmentTableThenFindDrills(polyData, [1.2864902,  -0.93351376,  1.10208917])
objectClusters, tableData = segmentation.segmentTableSceneClusters(
    polyData, [1.2864902, -0.93351376, 1.10208917], clusterInXY=True)