def main(): '''Entrypoint to the program.''' # PARAMETERS ===================================================================================== # system randomSeed = 0 # environment removeTable = True # objects objectHeight = [0.005, 0.020] objectRadius = [0.040, 0.060] nObjects = 1000 # view viewCenter = array([0,0,0]) viewKeepout = 0.60 viewWorkspace = [(-1.0,1.0),(-1.0,1.0),(-1.0,1.0)] voxelSize = 0.002 # visualization/saving showViewer = False showSteps = False plotImages = False # INITIALIZATION ================================================================================= params = locals() seed(randomSeed) rlEnv = RlEnvironment(params) # RUN TEST ======================================================================================= for objIdx in xrange(nObjects): # Generate mesh, save mesh, and get points. objectName = "coaster-{}".format(objIdx) obj = rlEnv.GenerateCylinderMesh(objectHeight, objectRadius, objectName) cloud = rlEnv.GetFullCloud(viewCenter, viewKeepout, viewWorkspace, add45DegViews=False, computeNormals=False, voxelSize=voxelSize) # Compute object bounding box workspace = array([[min(cloud[:, 0]), max(cloud[:, 0])], [min(cloud[:, 1]), max(cloud[:, 1])], [min(cloud[:, 2]), max(cloud[:, 2])]]) # Save metadata. data = {"cloud":cloud, "workspace":workspace, "height":obj.height, "radius":obj.radius} savemat(objectName + ".mat", data) # Optional visualization for debugging. rlEnv.PlotCloud(cloud) if plotImages: point_cloud.Plot(cloud) if showSteps: raw_input("Placed " + objectName + ".") # Remove the object before loading the next one. rlEnv.RemoveObjectSet([obj])
def main(): '''Entrypoint to the program.''' # PARAMETERS ===================================================================================== # system randomSeed = 0 # environment removeTable = True # objects objectHeight = [0.01, 0.02] objectRadius = [0.03, 0.06] nObjects = 1000 # view viewCenter = array([0, 0, 0]) viewKeepout = 0.60 viewWorkspace = [(-1.0, 1.0), (-1.0, 1.0), (-1.0, 1.0)] voxelSize = 0.002 # visualization/saving showViewer = False showSteps = False plotImages = False # INITIALIZATION ================================================================================= params = locals() seed(randomSeed) rlEnv = RlEnvironmentPegsOnDisks(params) # RUN TEST ======================================================================================= for objIdx in xrange(nObjects): obj = rlEnv.GenerateCylinderMesh(objectHeight, objectRadius, "disk-{}".format(objIdx)) cloud = rlEnv.GetFullCloud(viewCenter, viewKeepout, viewWorkspace, False, voxelSize) data = {"cloud": cloud, "height": obj.height, "radius": obj.radius} savemat("disk-{}.mat".format(objIdx), data) rlEnv.PlotCloud(cloud) if plotImages: point_cloud.Plot(cloud) if showSteps: raw_input("Placed disk-{}.".format(objIdx)) rlEnv.RemoveObjectSet([obj])
def main(): '''Entrypoint to the program.''' # PARAMETERS ===================================================================================== # system gpuId = 0 # objects objectHeight = [0.007, 0.013] objectRadius = [0.030, 0.045] nObjects = 1000 # view viewCenter = array([0, 0, 0]) viewKeepout = 0.60 viewWorkspace = [(-1.0, 1.0), (-1.0, 1.0), (-1.0, 1.0)] # visualization/saving showViewer = False showSteps = False plotImages = False # INITIALIZATION ================================================================================= rlEnv = RlEnvironment(showViewer, removeTable=True) rlAgent = RlAgent(rlEnv, gpuId) # RUN TEST ======================================================================================= for objIdx in xrange(nObjects): obj = rlEnv.PlaceCylinderAtOrigin(objectHeight, objectRadius, "cylinder-{}".format(objIdx), True) cloud, normals = rlAgent.GetFullCloudAndNormals( viewCenter, viewKeepout, viewWorkspace) point_cloud.SaveMat("cylinder-{}.mat".format(objIdx), cloud, normals) rlAgent.PlotCloud(cloud) if plotImages: point_cloud.Plot(cloud, normals, 2) if showSteps: raw_input("Placed cylinder-{}.".format(objIdx)) rlEnv.RemoveObjectSet([obj])
def main(): '''Entrypoint to the program.''' # PARAMETERS ===================================================================================== # system gpuId = 0 # objects objectScale = [0.09, 0.17] nObjects = 1000 directory = "/home/mgualti/Data/3DNet/Cat200_ModelDatabase/plate/" # view viewCenter = array([0, 0, 0]) viewKeepout = 0.60 viewWorkspace = [(-1.0, 1.0), (-1.0, 1.0), (-1.0, 1.0)] # visualization/saving showViewer = False showSteps = False plotImages = False # INITIALIZATION ================================================================================= rlEnv = RlEnvironment(showViewer, removeTable=True) rlAgent = RlAgent(rlEnv, gpuId) # RUN TEST ======================================================================================= for objIdx in xrange(nObjects): obj = rlEnv.Place3DNetObjectAtOrigin(directory, objectScale, "plate-{}".format(objIdx), True) cloud, normals = rlAgent.GetFullCloudAndNormals( viewCenter, viewKeepout, viewWorkspace, False) point_cloud.SaveMat("plate-{}.mat".format(objIdx), cloud, normals) rlAgent.PlotCloud(cloud) if plotImages: point_cloud.Plot(cloud, normals, 2) if showSteps: raw_input("Placed plate-{}.".format(objIdx)) rlEnv.RemoveObjectSet([obj])
def main(): '''Entrypoint to the program.''' # PARAMETERS ===================================================================================== # system randomSeed = 0 # environment removeTable = True # objects objectDirectory = "/home/mgualti/Data/3DNet/Cat10_ModelDatabase/bottle" objectsToSkip = ["8cf1cc180de4ecd0a826d25a0acb0476.ply"] # z-axis not up objectsToSkip += ["b0652a09588f293c7e95755f464f6241.ply", \ "91a1f4e7a5eab4eab05e5be75e72ca3c.ply", "70e77c09aca88d4cf76fe74de9d44699.ply"] # difficult to grasp objectScale = [0.10, 0.20] nObjects = 1000 # view viewCenter = array([0, 0, 0]) viewKeepout = 0.60 viewWorkspace = [(-1.0, 1.0), (-1.0, 1.0), (-1.0, 1.0)] voxelSize = 0.002 # visualization/saving showViewer = False showSteps = False plotImages = False # INITIALIZATION ================================================================================= params = locals() seed(randomSeed) rlEnv = RlEnvironment(params) # RUN TEST ======================================================================================= for objIdx in xrange(nObjects): # Load mesh, save mesh, and get points and normals. objectName = "bottle-{}".format(objIdx) obj = rlEnv.GenerateMeshFromMesh(objectDirectory, objectScale, objectsToSkip, objectName) cloud, normals = rlEnv.GetFullCloud(viewCenter, viewKeepout, viewWorkspace, add45DegViews=False, computeNormals=True, voxelSize=voxelSize) # Occasionally, the normals calculation fails. Replace with the nearest normal. if isnan(normals).any(): nanIdx = sum(isnan(normals), axis=1) > 0 notNanIdx = logical_not(nanIdx) nanFreeTree = cKDTree(cloud[notNanIdx, :]) d, nearestIdx = nanFreeTree.query(cloud[nanIdx, :]) normals[nanIdx, :] = normals[nearestIdx, :] # Compute object bounding box workspace = array([[min(cloud[:, 0]), max(cloud[:, 0])], [min(cloud[:, 1]), max(cloud[:, 1])], [min(cloud[:, 2]), max(cloud[:, 2])]]) # Save metadata. data = { "cloud": cloud, "normals": normals, "workspace": workspace, "scale": obj.scale } savemat(objectName + ".mat", data) # Optional visualization for debugging. rlEnv.PlotCloud(cloud) if plotImages: point_cloud.Plot(cloud, normals, 5) if showSteps: raw_input("Placed " + objectName + ".") # Remove the object before loading the next one. rlEnv.RemoveObjectSet([obj])