def __init__(self): super(HumanLocationProcessor, self).__init__() from Robots.rosHelper import ROS, Transform self._ros = ROS() self._topic = '/trackedHumans' self._tm = None self._transform = Transform(toTopic='/map', fromTopic='/camera_frame') self._targetName = "Humans" self._storedLoc = self._getStoredLoc self._curLoc = self._getCurrentLoc self._updateLoc = lambda locid, x, y, orientation: self._update(locid, x, y, orientation)
class HumanLocationProcessor(LocationProcessor): def __init__(self): super(HumanLocationProcessor, self).__init__() from Robots.rosHelper import ROS, Transform self._ros = ROS() self._topic = '/trackedHumans' self._tm = None self._transform = Transform(toTopic='/map', fromTopic='/room_frame') self._targetName = "Humans" self._storedLoc = self._getStoredLoc self._curLoc = self._getCurrentLoc self._updateLoc = lambda locid, x, y, orientation: self._update(locid, x, y, orientation) @property def _transformMatrix(self): if self._tm == None: ((x, y, _), rxy) = self._transform.getTransform() if x == None or y == None: return ('', (None, None, None)) angle = round(math.degrees(rxy)) self._tm = (round(x, 3), round(y, 3), angle) return self._tm def _update(self, locid, x, y, theta): #kept for legacy support self._dao.locations.saveLocation(999, 999, x, y, theta, server_config['mysql_location_table'], 'locationId') user = self._dao.users.getActiveUser() user['xCoord'] = x user['yCoord'] = y user['orientation'] = theta self._dao.users.updateUser(user) def _getCurrentLoc(self): locs = self._ros.getSingleMessage(self._topic) if len(locs.trackedHumans) > 0: loc = locs.trackedHumans[0] else: return ('', (None, None, None)) x = loc.location.point.x + self._transformMatrix[0] y = loc.location.point.y + self._transformMatrix[1] angle = 0 + self._transformMatrix[2] print "Using human location from id: %s" % loc.id pos = (round(x, 3), round(y, 3), angle) return Locations.resolveLocation(pos) def _getStoredLoc(self): user = self._dao.users.getActiveUser() loc = self._dao.getLocation(user['locationId']) loc['locationName'] = loc['name'] return loc
def __init__(self): super(HumanLocationProcessor, self).__init__() from Robots.rosHelper import ROS, Transform self._ros = ROS() self._topic = '/trackedHumans' self._tm = None self._transform = Transform(toTopic='/map', fromTopic='/room_frame') self._targetName = "Humans" self._storedLoc = self._getStoredLoc self._curLoc = self._getCurrentLoc self._updateLoc = lambda locid, x, y, orientation: self._update(locid, x, y, orientation)
class HumanLocationProcessor(LocationProcessor): """Update the location of the most likely tracked human in the database""" """This updates both the user table (based on CurrentUser) and the location table for the location 'Current user location' """ """The idea, going forward, is to phase out the special location from the locations table, in order to eventually provide """ """ support for multiple simultaneous user tracking. This, however, requires the integration of user tagging with the """ """ location tracker, and consistency upgrades to the tracked human id coming from the tracker.""" def __init__(self): super(HumanLocationProcessor, self).__init__() from Robots.rosHelper import ROS, Transform self._ros = ROS() self._topic = '/trackedHumans' self._tm = None self._transform = Transform(toTopic='/map', fromTopic='/room_frame') self._targetName = "Humans" self._storedLoc = self._getStoredLoc self._curLoc = self._getCurrentLoc self._updateLoc = lambda locid, x, y, orientation: self._update(locid, x, y, orientation) @property def _transformMatrix(self): if self._tm == None: ((x, y, _), rxy) = self._transform.getTransform() if x == None or y == None: return ('', (None, None, None)) angle = round(math.degrees(rxy)) self._tm = (round(x, 3), round(y, 3), angle) return self._tm def _update(self, locid, x, y, theta): #kept for legacy support self._dao.locations.saveLocation(999, 999, x, y, theta, server_config['mysql_location_table'], 'locationId') user = self._dao.users.getActiveUser() user['xCoord'] = x user['yCoord'] = y user['orientation'] = theta self._dao.users.updateUser(user) def _getCurrentLoc(self): locs = self._ros.getSingleMessage(self._topic) if locs == None: print "No message recieved from %s" % self._topic return ('', (None, None, None)) loc = None for human in locs.trackedHumans: if human.specialFlag == 1: loc = human break if loc == None: print "No human returned from location tracker" return ('', (None, None, None)) x = loc.location.point.x + self._transformMatrix[0] y = loc.location.point.y + self._transformMatrix[1] angle = 0 + self._transformMatrix[2] print "Using human location from id: %s" % loc.id pos = (round(x, 3), round(y, 3), angle) return Locations.resolveLocation(pos) def _getStoredLoc(self): user = self._dao.users.getActiveUser() loc = self._dao.getLocation(user['locationId']) loc['locationName'] = loc['name'] return loc
class HumanLocationProcessor(LocationProcessor): """Update the location of the most likely tracked human in the database""" """This updates both the user table (based on CurrentUser) and the location table for the location 'Current user location' """ """The idea, going forward, is to phase out the special location from the locations table, in order to eventually provide """ """ support for multiple simultaneous user tracking. This, however, requires the integration of user tagging with the """ """ location tracker, and consistency upgrades to the tracked human id coming from the tracker.""" def __init__(self): super(HumanLocationProcessor, self).__init__() from Robots.rosHelper import ROS, Transform self._ros = ROS() self._topic = '/trackedHumans' self._tm = None self._transform = Transform(toTopic='/map', fromTopic='/camera_frame') self._targetName = "Humans" self._storedLoc = self._getStoredLoc self._curLoc = self._getCurrentLoc self._updateLoc = lambda locid, x, y, orientation: self._update(locid, x, y, orientation) @property def _transformMatrix(self): if self._tm == None: ((x, y, _), rxy) = self._transform.getTransform() if x == None or y == None: return (None, None, None) angle = round(math.degrees(rxy)) self._tm = (round(x, 3), round(y, 3), angle) return self._tm def _update(self, locid, x, y, theta): #kept for legacy support self._dao.locations.saveLocation(999, 999, x, y, theta, server_config['mysql_location_table'], 'locationId') user = self._dao.users.getActiveUser() user['xCoord'] = x user['yCoord'] = y user['orientation'] = theta user['locationId'] = locid self._dao.users.updateUser(user) def _getCurrentLoc(self): locs = self._ros.getSingleMessage(self._topic) if locs == None: print "No message recieved from %s" % self._topic return ('', (None, None, None)) loc = None for human in locs.trackedHumans: if human.specialFlag == 1: loc = human break if loc == None: print "No human returned from location tracker" return ('', (None, None, None)) #tm = self._transformMatrix #loc.header.frame_id is 'usually' /camera_frame (x, y, _) = self._transform.transformPoint(loc.location, toTopic='/map', fromTopic=loc.location.header.frame_id) if x == None or y == None: print "Error getting transform" return ('', (None, None, None)) #else: # angle = 0 #TODO: UVA Orientation # print "Using human location from id: %s" % loc.id pos = (round(x, 3), round(y, 3), 0) return Locations.resolveLocation(pos) def _getStoredLoc(self): user = self._dao.users.getActiveUser() loc = self._dao.getLocation(user['locationId']) loc['locationName'] = loc['name'] return loc