How to use the regions.RegionFileInterface function in regions

To help you get started, we’ve selected a few regions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VerifiableRobotics / LTLMoP / src / lib / handlers / robots / CSharpRobot / CSharpRobotSensor.py View on Github external
def run(self):
        import regions
        print "running..."
        self.notStarted = False
        map_number = 1
        data = []
        while True:
            if self.gotNewMap and not self.mapReady:
                self.processing = True
                print "GOTnEWmAP!@"
                self.rfi = regions.RegionFileInterface(transitions=[])

                self.rfi.regions = []
                # first convert the map from PythonRequestMsg to a list of regions
                for reg in self.new_map:
                    # transform the points to map coordinates
                    # convert each region
                    r = regions.Region()
                    r.type = 1
                    r.pointArray = []
                    r.name = reg.name
                    count = 0
                    #print 'regions in new map:',len(reg.points)
                    print 'regions in new map name:',r.name,len(reg.points)
                    for p in reg.points: # add all the points of the region in lab coordinates
                        transformed_p = self.coordmap_lab2map(regions.Point(p.x,p.y))
                        r_pos = r.position
github VerifiableRobotics / LTLMoP / src / lib / specCompiler.py View on Github external
For Slurp

        region, sensors, actuators, customs are lists of strings representing props
        adj is a list of tuples [(region1,region2),...]
        """

        if outputfile == "":
            logging.error("Need to specify output filename")
            return

        self.proj.compile_options['decompose'] = False
        self.proj.project_root = os.path.abspath(os.path.dirname(os.path.expanduser(outputfile)))
        self.proj.project_basename, ext = os.path.splitext(os.path.basename(outputfile))
        self.proj.specText=text
        # construct a list of region objects with given names
        self.proj.rfi = regions.RegionFileInterface()
        for rname in regionList:
            self.proj.rfi.regions.append(regions.Region(name=rname))

        self.proj.enabled_sensors = sensors
        self.proj.enabled_actuators = actuators
        self.proj.all_customs = customs

        # construct adjacency matrix
        self.proj.rfi.transitions= [[[] for j in range(len(self.proj.rfi.regions))] for i in range(len(self.proj.rfi.regions))]
        for tran in adj:
            idx0 = self.proj.rfi.indexOfRegionWithName(tran[0])
            idx1 = self.proj.rfi.indexOfRegionWithName(tran[1])
            self.proj.rfi.transitions[idx0][idx1] = [(0,0)] # fake trans face
            self.proj.rfi.transitions[idx1][idx0] = [(0,0)]
github VerifiableRobotics / LTLMoP / src / lib / project.py View on Github external
Returns a Region File Interface object corresponding to the regions file referenced in the spec file
        """

        #### Load in the region file

        if decomposed:
            regf_name = self.getFilenamePrefix() + "_decomposed.regions"
        else:
            try:
                regf_name = os.path.join(self.project_root, self.spec_data['SETTINGS']['RegionFile'][0])
            except (IndexError, KeyError):
                logging.warning("Region file undefined")
                return None

        logging.info("Loading region file %s..." % regf_name)
        rfi = regions.RegionFileInterface()

        if not rfi.readFile(regf_name):
            if not self.silent:
                logging.error("Could not load region file %s!"  % regf_name)
                if decomposed:
                    logging.error("Are you sure you compiled your specification?")
            return None

        logging.info("Found definitions for %d regions." % len(rfi.regions))

        return rfi
github VerifiableRobotics / LTLMoP / src / lib / simGUI.py View on Github external
def loadRegionFile(self, filename):
        self.proj.rfi = regions.RegionFileInterface()
        self.proj.rfi.readFile(filename)

        self.Bind(wx.EVT_SIZE, self.onResize, self)
        self.onResize()