Skip to content

Commit 0314237

Browse files
authored
Merge pull request #12 from RobotLocomotion/pipeline-updates
Pipeline updates
2 parents 4ca848e + 37e470c commit 0314237

File tree

9 files changed

+38
-147
lines changed

9 files changed

+38
-147
lines changed

config/object_data.yaml

Lines changed: 0 additions & 72 deletions
This file was deleted.

config/registration_result.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/pipeline.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Automated arm setup
3838
- double click on kuka-driver and edit command to be: :code:`kuka_driver -fri_port 30201` (or different port)
3939
- start :code:`iiwa-drivers` group
4040

41-
Same as above but we will use the kuka arm to move the xtion around. Set :code:`useCorlDev = True` in :code:`iiwaManipApp.py`. This launches director with :code:`dc = DataCollection` object constructed.
41+
Same as above but we will use the kuka arm to move the xtion around. Set :code:`useLabelFusionDev = True` in :code:`iiwaManipApp.py`. This launches director with :code:`dc = DataCollection` object constructed.
4242

4343
- Spawning a table frame. With the measurement panel activated make three clicks in openni point cloud. First on front edge of table, second in middle of table in a direction perpendicular to the front edge, the third should be above the able. Then :code:`dc.spawnTableFrame()`.
4444

@@ -117,9 +117,9 @@ Now rename::
117117
5. Global Object Pose Fitting
118118
-----------------------------
119119

120-
The class that handles segmentation and registration is in :code:`modules/corl/registration.py` and :code:`modules/corl/objectalignmenttool.py`. Launch the standard :code:`corlApp` to run it::
120+
The class that handles segmentation and registration is in :code:`modules/labelfusion/registration.py` and :code:`modules/labelfusion/objectalignmenttool.py`. Launch the standard :code:`labelFusionApp` to run it::
121121

122-
directorPython scripts/corlApp.py --logFolder logs/test --bot-config $SPARTAN_SOURCE_DIR/apps/iiwa/iiwaManip.cfg
122+
directorPython $LABELFUSION_SOURCE_DIR/scripts/labelFusionApp.py --bot-config $LABELFUSION_SOURCE_DIR/config/bot_frames.cfg --logFolder scenes/2017-06-15-70
123123

124124
The :code:`GlobalRegistration` object is in the global namespace as :code:`globalRegistration`, or :code:`gr` for short. The first step is to align the reconstructed point cloud so it is right-side-up:
125125

@@ -129,7 +129,7 @@ The :code:`GlobalRegistration` object is in the global namespace as :code:`globa
129129

130130
gr.rotateReconstructionToStandardOrientation()
131131

132-
- Close the corlApp application (ctrl + c) and reopen
132+
- Close the labelFusionApp application (ctrl + c) and reopen
133133

134134
The second step is to segment the pointcloud above the table
135135

@@ -140,7 +140,7 @@ The second step is to segment the pointcloud above the table
140140
gr.segmentTable()
141141
gr.saveAboveTablePolyData()
142142

143-
- Close the corlApp application (ctrl + c) and reopen
143+
- Close the labelFusionApp application (ctrl + c) and reopen
144144

145145
Now, we are ready to align each object. Press F8 in the app to open Director's Python terminal and run::
146146

@@ -162,7 +162,7 @@ Issues:
162162

163163

164164
.. commented out below
165-
.. We need environment variables in order for the scripts to be able to find the binaries for these global fitting routines. Please fill in the variables like :code:`FGR_BASE_DIR` in :code:`setup_environment.sh` to point to your local binaries. The relevant python file is :code:`module/corl/registration.py`. To run an example::
165+
.. We need environment variables in order for the scripts to be able to find the binaries for these global fitting routines. Please fill in the variables like :code:`FGR_BASE_DIR` in :code:`setup_environment.sh` to point to your local binaries. The relevant python file is :code:`module/labelfusion/registration.py`. To run an example::
166166
167167
.. drake-visualizer --script scripts/registration/testRegistration.py
168168
@@ -178,7 +178,7 @@ Issues:
178178
179179
6. Extract Images from LCM log
180180
------------------------------
181-
The class that is used is is :code:`modules/corl/imagecapture.py`. To extract rgb images from the lcm log run::
181+
The class that is used is is :code:`modules/labelfusion/imagecapture.py`. To extract rgb images from the lcm log run::
182182

183183
directorPython scripts/extractImagesFromLog.py --logFolder logs/moving-camera --bot-config $SPARTAN_SOURCE_DIR/apps/iiwa/iiwaManip.cfg
184184

@@ -188,7 +188,7 @@ This will save the images in :code:`data/logFolder`. The original images will be
188188
7. Generate Labeled Images
189189
--------------------------
190190

191-
The class that is used to render labeled images is :code:`modules/corl/rendertrainingimages.py`. Usage::
191+
The class that is used to render labeled images is :code:`modules/labelfusion/rendertrainingimages.py`. Usage::
192192

193193
directorPython scripts/renderTrainingImages.py --bot-config $SPARTAN_SOURCE_DIR/apps/iiwa/iiwaManip.cfg --logFolder logs/moving-camera
194194

@@ -198,13 +198,13 @@ Optionally you can pass :code:`--logFolder <logFolder>` on the command line wher
198198
Misc
199199
====
200200

201-
Director with Corl Modules
201+
Director with LabelFusion Modules
202202
--------------------------
203-
There is a standalone app for launching a director with corl modules::
203+
There is a standalone app for launching a director with labelfusion modules::
204204

205-
directorPython scripts/corlApp.py --logFolder logs/moving-camera --bot-config $SPARTAN_SOURCE_DIR/apps/iiwa/iiwaManip.cfg
205+
directorPython $LABELFUSION_SOURCE_DIR/scripts/labelFusionApp.py --logFolder logs/moving-camera --bot-config $SPARTAN_SOURCE_DIR/apps/iiwa/iiwaManip.cfg
206206

207-
The :code:`--logFolder` option specifies which logFolder to use relative to Corl data directory.
207+
The :code:`--logFolder` option specifies which logFolder to use relative to LabelFusion data directory.
208208

209209
Visualizing RGBD Data
210210
---------------------

modules/labelfusion/imagecapture.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ def readFromLogFile(lcmLogFilename, fileSaveLocation, channelName="OPENNI_FRAME"
119119
return
120120

121121
def captureImages(logFolder, saveDepth):
122-
corlPaths = utils.getFilenames(logFolder)
122+
dataPaths = utils.getFilenames(logFolder)
123123

124124
if saveDepth:
125-
ImageCapture.readFromLogFile(corlPaths['lcmlog'], corlPaths['images'], cameraName="OPENNI_FRAME_DEPTH_MM_ZIPPED", saveDepth=True)
125+
ImageCapture.readFromLogFile(dataPaths['lcmlog'], dataPaths['images'], cameraName="OPENNI_FRAME_DEPTH_MM_ZIPPED", saveDepth=True)
126126

127-
ImageCapture.readFromLogFile(corlPaths['lcmlog'], corlPaths['images'], cameraName="OPENNI_FRAME_LEFT")
127+
ImageCapture.readFromLogFile(dataPaths['lcmlog'], dataPaths['images'], cameraName="OPENNI_FRAME_LEFT")
128128

129129

130130
def test():

modules/labelfusion/objectalignmenttool.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ def makeAlignmentTool(cameraView, pathDict, objectName='phone'):
261261

262262
pointCloud = ioUtils.readPolyData(pathDict['reconstruction'])
263263
pointCloud = filterUtils.transformPolyData(pointCloud, firstFrameToWorldTransform)
264-
objectMeshFilename = utils.getObjectMeshFilename(objectName)
265-
objectMesh = ioUtils.readPolyData(objectMeshFilename)
264+
objectMesh = utils.getObjectPolyData(utils.loadObjectData(), objectName)
266265

267266
alignmentTool = ObjectAlignmentTool(cameraView, modelPolyData=objectMesh, pointCloud=pointCloud)
268267

modules/labelfusion/registration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, view, cameraView, measurementPanel, affordanceManager,
3030
firstFrameToWorldTransform=None):
3131
self.view = view
3232
self.cameraView = cameraView
33+
self.objectData = utils.loadObjectData()
3334
self.objectToWorldTransform = dict()
3435
self.measurementPanel = measurementPanel
3536
self.affordanceManager = affordanceManager
@@ -48,7 +49,6 @@ def initializeFields(self):
4849
self.logFolder = "logs/scratch"
4950

5051
self.pathDict = utils.getFilenames(self.logFolder)
51-
self.objectData = utils.getObjectDataYamlFile()
5252
self.objectAlignmentResults = dict() # stores results of object alignment tool
5353
self.objectAlignmentTool = None
5454

@@ -74,7 +74,7 @@ def loadStoredObjects(self):
7474
for objName, data in registrationResult.iteritems():
7575
objectMeshFilename = data['filename'] # should be relative to getLabelFusionDataDir()
7676
if len(objectMeshFilename) == 0:
77-
objectMeshFilename = utils.getObjectMeshFilename(objName)
77+
objectMeshFilename = utils.getObjectMeshFilename(self.objectData, objName)
7878
else:
7979
objectMeshFilename = os.path.join(utils.getLabelFusionDataDir(), objectMeshFilename)
8080

@@ -98,7 +98,7 @@ def fitObjectToPointcloud(self, objectName, pointCloud=None, downsampleObject=Tr
9898

9999
if objectPolyData is None:
100100
if filename is None:
101-
filename = utils.getObjectMeshFilename(objectName)
101+
filename = utils.getObjectMeshFilename(self.objectData, objectName)
102102

103103
objectPolyData = ioUtils.readPolyData(filename)
104104

@@ -281,7 +281,7 @@ def launchObjectAlignment(self, objectName, useAboveTablePointcloud=True):
281281

282282
pointCloud = self.aboveTablePolyData
283283
# pointCloud = om.findObjectByName('reconstruction').polyData
284-
objectPolyData = utils.getObjectPolyData(objectName)
284+
objectPolyData = utils.getObjectPolyData(self.objectData, objectName)
285285
resultsDict = dict()
286286
self.objectAlignmentResults[objectName] = resultsDict
287287
parent = om.getOrCreateContainer('global registration')

modules/labelfusion/rendertrainingimages.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, view, viewOptions, pathDict):
2525
self.view = view
2626
self.viewOptions = viewOptions
2727
self.pathDict = pathDict
28+
self.objectData = utils.loadObjectData()
2829
self.storedColors = {}
2930
self.colors = cm.nipy_spectral(np.linspace(0, 1, 12))
3031
self.colors = np.append(self.colors, [[0.5, 0.5, 0.5, 1.0]], axis=0)
@@ -62,7 +63,7 @@ def disableLighting(self):
6263

6364
for obj in om.findObjectByName('data files').children():
6465
objName = obj.getProperty('Name')
65-
objLabel = utils.getObjectLabel(objName)
66+
objLabel = utils.getObjectLabel(self.objectData, objName)
6667
obj.actor.GetProperty().LightingOff()
6768
self.storedColors[obj.getProperty('Name')] = list(obj.getProperty('Color'))
6869
obj.setProperty('Color', [objLabel / 255.0] * 3)
@@ -154,7 +155,7 @@ def getCameraPoseAtUTime(self, utime):
154155
return transformUtils.transformFromPose(pos, quat)
155156

156157
def getColorFromIndex(self, objName):
157-
objLabel = utils.getObjectLabel(objName)
158+
objLabel = utils.getObjectLabel(self.objectData, objName)
158159
return self.colors[objLabel][:3]
159160

160161
def loadObjectMeshes(self):
@@ -166,7 +167,7 @@ def loadObjectMeshes(self):
166167

167168
filename = data['filename']
168169
if len(filename) == 0:
169-
filename = utils.getObjectMeshFilename(objName)
170+
filename = utils.getObjectMeshFilename(self.objectData, objName)
170171
else:
171172
filename = os.path.join(utils.getLabelFusionDataDir(), filename)
172173

@@ -245,7 +246,7 @@ def saveObjectPoses(self, imageFilename, cameraToCameraStart, baseName):
245246
continue
246247
if val > 0:
247248
cameraStartToCamera = cameraToCameraStart.GetLinearInverse()
248-
objectName = utils.getObjectName(index)
249+
objectName = utils.getObjectName(self.objectData, index)
249250
target.write(objectName + ":")
250251
target.write("\n")
251252
target.write(" label: " + str(index))

modules/labelfusion/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def setupLabelFusionDirector(affordanceManager, openniDepthPointCloud, logFolder
5858

5959

6060
def testStartup(robotSystem, affordanceManager, openniDepthPointCloud, logFolder="logs/moving-camera", globalsDict=None):
61-
objectData = utils.getObjectDataYamlFile()
61+
objectData = utils.loadObjectData()
6262

6363
for objectName, data in objectData.iteritems():
6464
utils.loadObjectMesh(affordanceManager, objectName, visName=objectName)

modules/labelfusion/utils.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def printObjectPose(name):
6969
def loadObjectMesh(affordanceManager, objectName, visName=None, pose=None):
7070
if visName is None:
7171
visName = objectName + "_raw"
72-
filename = getObjectMeshFilename(objectName)
72+
filename = getObjectMeshFilename(loadObjectData(), objectName)
7373

7474
if pose is None:
7575
pose = [[0,0,0],[1,0,0,0]]
@@ -99,7 +99,7 @@ def loadObjectMeshes(affordanceManager, registrationResultFilename,
9999
for objName, data in registrationResult.iteritems():
100100
objectMeshFilename = data['filename'] # should be relative to getLabelFusionDataDir()
101101
if len(objectMeshFilename) == 0:
102-
objectMeshFilename = getObjectMeshFilename(objName)
102+
objectMeshFilename = getObjectMeshFilename(loadObjectData(), objName)
103103
else:
104104
objectMeshFilename = os.path.join(getLabelFusionDataDir(), objectMeshFilename)
105105

@@ -138,20 +138,16 @@ def getGRBaseDir():
138138
return os.getenv('FGR_BASE_DIR')
139139

140140
def getObjectDataFilename():
141-
return os.path.join(getLabelFusionBaseDir(), 'config/object_data.yaml')
141+
return os.path.join(getLabelFusionDataDir(), 'object_data.yaml')
142142

143-
def getObjectDataYamlFile():
144-
stream = file(getObjectDataFilename())
145-
return yaml.load(stream)
143+
def loadObjectData():
144+
return getDictFromYamlFilename(getObjectDataFilename())
146145

147146
def getDictFromYamlFilename(filename):
148147
stream = file(filename)
149148
return yaml.load(stream)
150149

151-
objectDataFilename = os.path.join(getLabelFusionBaseDir(), 'config/object_data.yaml')
152-
objectData = yaml.load(file(objectDataFilename))
153-
154-
def getObjectMeshFilename(objectName):
150+
def getObjectMeshFilename(objectData, objectName):
155151
"""
156152
Returns the filename of mesh corresponding to this object.
157153
Filename is relative to getLabelFusionDataDir()
@@ -162,11 +158,13 @@ def getObjectMeshFilename(objectName):
162158

163159
return os.path.join(getLabelFusionDataDir(), objectData[objectName]['mesh'])
164160

165-
def getObjectPolyData(objectName):
166-
filename = getObjectMeshFilename(objectName)
161+
162+
def getObjectPolyData(objectData, objectName):
163+
filename = getObjectMeshFilename(objectData, objectName)
167164
return ioUtils.readPolyData(filename)
168165

169-
def getObjectLabel(objectName):
166+
167+
def getObjectLabel(objectData, objectName):
170168
"""
171169
Returns the object label specified in object_data.yaml
172170
:param objectName:
@@ -178,7 +176,7 @@ def getObjectLabel(objectName):
178176

179177
return objectData[objectName]['label']
180178

181-
def getObjectName(objectLabel):
179+
def getObjectName(objectData, objectLabel):
182180
"""
183181
Returns the object label specified in object_data.yaml
184182
:param objectLabel:
@@ -213,11 +211,6 @@ def evalFileAsString(filename):
213211
return eval(open(filename, 'r').read(), context)
214212

215213

216-
def getResultsConfig():
217-
filename = getLabelFusionRelativePath('config/registration_result.py')
218-
return evalFileAsString(filename)
219-
220-
221214
def loadElasticFusionReconstruction(filename, transform=None):
222215
"""
223216
Loads reconstructed pointcloud into director view

0 commit comments

Comments
 (0)