Exemple #1
0
 def appendSensorMetadata(self, sensorList, transform):
     """adds location and type data to a list of sensors"""
     """this REALLY needs to go in the database"""
     from xml.etree import ElementTree as et
     from SensorMap.processor import CoordinateConvertor
     import os
     cc = CoordinateConvertor(transform)
     sensors = et.parse(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sensor_metadata.xml'))
     for sensor in sensorList:
         meta = None
         if sys.version_info >= (2, 7):
             meta = sensors.getroot().find("./sensor[@id='%s']" % (sensor['id']))
         else:
             for s in sensors.getroot().findall('sensor'):
                 if long(s.attrib['id']) == sensor['id']:
                     meta = s
                     break
         if meta == None:
             sensor['location'] = cc.toRobotHouse((0, 0, 0))
             sensor['type'] = 'unknown'
             continue
         x = float(meta.get('x', 0))
         y = float(meta.get('y', 0))
         d = float(meta.get('direction', 0))
         sensor['location'] = (x, y, '%sd' % (d))
         sensor['type'] = meta.get('type', '')
     
     return sensorList
Exemple #2
0
 def appendSensorMetadata(self, sensorList):
     """adds location and type data to a list of sensors"""
     """this data eventually needs to go in the database"""
     from xml.etree import ElementTree as et
     from SensorMap.processor import CoordinateConvertor
     import os
     cc = CoordinateConvertor()
     sensors = et.parse(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sensor_metadata.xml'))
     for sensor in sensorList:
         meta = None
         if sys.version_info >= (2,7):
             meta = sensors.getroot().find("./sensor[@id='%s']" % (sensor['id']))
         else:
             for s in sensors.getroot().findall('sensor'):
                 if long(s.attrib['id']) == sensor['id']:
                     meta = s
                     break
         if meta == None:
             sensor['location'] = cc.toRobotHouse((0,0,0))
             sensor['type'] = 'unknown'
             continue
         x = float(meta.get('x', 0))
         y = float(meta.get('y', 0))
         d = float(meta.get('direction', 0))
         sensor['location'] = (x, y, '%sd' % (d))
         sensor['type'] = meta.get('type', '')
     
     return sensorList
Exemple #3
0
 def _alterMetaData(self):
     from xml.etree import ElementTree as et
     from SensorMap.processor import CoordinateConvertor
     import os, math
     cc = CoordinateConvertor()
     sensors = et.parse(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sensor_metadata.xml.bak'))
     for sensor in sensors.getroot().findall("./sensor"):
         x = float(sensor.get('x', 0))
         y = 728 - float(sensor.get('y', 0))
         d = float(sensor.get('direction', 0))
         (x, y, d) = cc.toRobotHouse((x, y, d))
         sensor.attrib['x'] = str(x)
         sensor.attrib['y'] = str(y)
         d = math.degrees(d)
         d = d % 360
         sensor.attrib['direction'] = str(d)
         
     sensors.write('sensor_metadata.xml')
Exemple #4
0
 def _alterMetaData(self):
     from xml.etree import ElementTree as et
     from SensorMap.processor import CoordinateConvertor
     import os, math
     cc = CoordinateConvertor()
     sensors = et.parse(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sensor_metadata.xml.bak'))
     for sensor in sensors.getroot().findall("./sensor"):
         x = float(sensor.get('x', 0))
         y = 728 - float(sensor.get('y', 0))
         d = float(sensor.get('direction', 0))
         (x, y, d) = cc.toRobotHouse((x, y, d))
         sensor.attrib['x'] = str(x)
         sensor.attrib['y'] = str(y)
         d = math.degrees(d)
         d = d % 360
         sensor.attrib['direction'] = str(d)
         
     sensors.write('sensor_metadata.xml')