Пример #1
0
def on_the_truck_cost(cf):
    state, am = waverly_state_truck()
    print state.orientation
    #state.orientation = 3.14/6
    cf.initialize_state(state)

    extractor = Extractor()
    esdcs = extractor.extractEsdcs("next to the truck.")

    place_esdc = esdcs[0]
    place_esdc.type = "PLACE"
    truck_esdc = place_esdc.l[0]
    print "place", place_esdc, place_esdc.type
    print "truck", truck_esdc

    searcher = BeamSearch(cf)
    annotation = initial_annotation(state, esdcs[0])

    truck = [
        state.getGroundableById(o) for o in state.getObjectsSet()
        if 'flatbed' in state.getGroundableById(o).tags
    ][0]

    annotation.setGrounding(truck_esdc, truck)
    annotation.setGrounding("sequence", [(state, None)])

    obj = prism_from_point(0,
                           0,
                           truck.centroid3d[2] + .2,
                           truck.centroid3d[2] + .5,
                           width=0.5)

    #axes = p.axes()
    featureBrowser = crfFeatureWeights.MainWindow()
    featureBrowser.show()
    axes = featureBrowser.axes
    for o in state.getObjectsSet():
        drawObject(axes, state.getGroundableById(o))

    drawPlaceCostMap(featureBrowser, obj, place_esdc, annotation, searcher, -5,
                     10, 25, 40, .2)
    #p.axes().set_aspect('equal')
    #p.show()
    state, gggs = annotation_to_ggg_map(annotation)
    ggg = gggs[place_esdc]
    #ggg = ggg_from_esdc(esdcs[0])
    factor = ggg.esdc_to_factor(place_esdc)
    print "factor", factor, factor.id
    print "cache", cf.factor_to_cost
    factor_to_cost = cf.factor_to_cost[factor]

    print "cache", factor_to_cost
    featureBrowser.load(cf.lccrf, factor_to_cost)
Пример #2
0
def approach_the_truck_cost_path(cf):
    state, am = waverly_state_truck()
    cf.initialize_state(state)

    extractor = Extractor()
    esdcs = extractor.extractEsdcs("Approach the truck.")
    event_esdc = esdcs[0]
    truck_esdc = event_esdc.l[0]
    annotation = initial_annotation(state, esdcs[0])

    truck = [o for o in state.objects if 'flatbed' in o.tags][0]

    annotation.setGrounding(truck_esdc, truck)
    featureBrowser = crfFeatureWeights.MainWindow()
    featureBrowser.show()
    ggg = drawAgentPathCostMap(featureBrowser, [event_esdc], annotation, cf,
                               -15, 25, 15, 50, 1)
    factor = ggg.esdc_to_factor(event_esdc)
    featureBrowser.load(annotation.context, cf, factor)
Пример #3
0
    def __init__(self, describer):
        QMainWindow.__init__(self)
        self.setupUi(self)
        self.describer = describer
        self.cf = self.describer.cf

        self.figure = mpl.figure()
        self.axes = self.figure.gca()
        self.axes.set_aspect("equal")
        self.oldParent = self.figure.canvas.parent()
        self.figure.canvas.setParent(self)
        self.matplotlibFrame.layout().addWidget(self.figure.canvas)
        self.toolbar = NavigationToolbar2QT(self.figure.canvas, self)
        self.addToolBar(self.toolbar)

        self.crfFeatureWeights = crfFeatureWeights.MainWindow()
        self.crfFeatureWeights.setWindowTitle(
            "CRF Feature Weights" + " created by " +
            str(self.crfFeatureWeights.windowTitle()))
        self.crfFeatureWeights.show()

        self.draw()
Пример #4
0
def pick_up_the_pallet_cost_pickup(cf):
    state, am = waverly_state_truck()
    cf.initialize_state(state)

    extractor = Extractor()
    esdcs = extractor.extractEsdcs("Pick up the tire pallet.")
    event_esdc = esdcs[0]
    print 'event', event_esdc
    #    pickup_esdc = event_esdc.r
    #    print 'pickup', pickup_esdc
    pallet_esdc = event_esdc.l[0]
    print "pallet", pallet_esdc
    annotation = initial_annotation(state, esdcs[0])

    pallet = [o for o in state.objects if 'tire' in o.tags][0]

    annotation.setGrounding(pallet_esdc, pallet)
    featureBrowser = crfFeatureWeights.MainWindow()
    featureBrowser.show()
    ggg = drawObjectPathCostMap(featureBrowser, pallet_esdc, [event_esdc],
                                annotation, cf, -20, 40, 15, 50, 1)
    factor = ggg.esdc_to_factor(event_esdc)
    featureBrowser.load(annotation.context, cf, factor)
Пример #5
0
    def __init__(self,
                 limits,
                 taskPlanner=None,
                 initialState=True,
                 show_gui=True,
                 merging_mode="merge_none",
                 start_command=None):

        QMainWindow.__init__(self)
        self.setupUi(self)

        self.windowManager = WindowManager(self.windowsMenu)
        self.artists = []
        self.extractor = None
        self.taskPlanner = taskPlanner
        self.plansDict = None
        self.currAnnotation = None
        self.save_state_tree = True
        self.allow_null_action = False

        self.command = ""
        if start_command:
            self.command = start_command
            self.commandEdit.setPlainText(start_command)

        self.figure = mpl.figure()
        self.axes = self.figure.gca()
        self.axes.set_aspect("equal")
        self.oldParent = self.figure.canvas.parent()
        self.figure.canvas.setParent(self)
        self.matplotlibFrame.layout().addWidget(self.figure.canvas)
        self.toolbar = NavigationToolbar2QT(self.figure.canvas, self)
        self.addToolBar(self.toolbar)

        self.limits = limits

        self.restoreLimits()
        self.figure.canvas.mpl_connect('draw_event', self.updateLimits)

        self.esdcFeatureBrowser = esdcFeatureBrowser.MainWindow()
        self.esdcFeatureBrowser.setWindowTitle(
            str(self.esdcFeatureBrowser.windowTitle()) +
            " (ESDC Feature Browser)")

        self.contextWindow = context3d.MainWindow()
        self.contextWindow.setWindowTitle(self.contextWindow.windowTitle() +
                                          " - Cost Function Browser")

        self.windowManager.addWindow(self.contextWindow)

        self.gggWindow = gggBrowser.MainWindow()
        self.gggWindow.setWindowTitle(self.gggWindow.windowTitle() +
                                      "(GGG Visualizer)")
        self.windowManager.addWindow(self.gggWindow)

        self.crfFeatureWeights = crfFeatureWeights.MainWindow()
        self.crfFeatureWeights.setWindowTitle(
            str(self.crfFeatureWeights.windowTitle()) + " (CFB)")
        self.windowManager.addWindow(self.crfFeatureWeights)

        self.nodeFeatureWeights = nodeFeatureWeights.MainWindow()
        self.nodeFeatureWeights.setWindowTitle(
            str(self.nodeFeatureWeights.windowTitle()) + " (CFB)")
        self.windowManager.addWindow(self.nodeFeatureWeights)

        self.esdcModel = esdcTreeModel.Model(self.esdcView)
        self.plansModel = plansModel.Model(self.plansView)

        self.connect(self.submitButton, SIGNAL("clicked()"),
                     self.followCommandSelf)

        self.connect(
            self.esdcView.selectionModel(),
            SIGNAL("selectionChanged ( QItemSelection, QItemSelection )"),
            self.selectEsdc)

        self.connect(
            self.plansView.selectionModel(),
            SIGNAL("selectionChanged ( QItemSelection, QItemSelection )"),
            self.selectPlan)

        self.connect(self.esdcParserComboBox,
                     SIGNAL("currentIndexChanged( QString)"),
                     self.selectEsdcExtractor)

        self.connect(self.esdcParserModelButton, SIGNAL("clicked()"),
                     self.askForEsdcParserModel)

        self.connect(self.actionLoadContext, SIGNAL("triggered()"),
                     self.loadContext)
        self.connect(self.actionSaveState, SIGNAL("triggered()"),
                     self.saveState)
        self.connect(self.actionLoadState, SIGNAL("triggered()"),
                     self.loadState)

        self.connect(self.actionGroundingProbabilityGraph,
                     SIGNAL("triggered()"), self.groundingProbabilityGraph)

        self.esdcParserModelButton.setText(
            "%s/data/directions/direction_training/annotation/models/crf_discrete_esdcs_1.5.pck"
            % SLU_HOME)

        self.esdcs = []
        self.factors_to_esdcs = None
        self.gggs = None

        #self.selectEsdcExtractor()

        self.merging_mode = merging_mode