Exemplo n.º 1
0
    def addHistory(self, ruleName, imageBytes=None, imageType=None):
        """ updates the action history table, blocking until all data is retrieved and stored """
        """ returns true on successful update """

        from Robots.robotFactory import Factory
        cob = Factory.getCurrentRobot()
        dao = DataAccess()
        dateNow = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        location = dao.getRobotByName(cob.name)['locationId']

        historyId = dao.saveHistory(dateNow, ruleName, location)

        if (historyId > 0):
            dao.saveSensorHistory(historyId)

            if imageType == None:
                imageType = ActionHistory._defaultImageType

            if imageBytes == None:
                imageBytes = cob.getImage(retFormat=imageType)

            if imageBytes != None:
                dao.saveHistoryImage(historyId, imageBytes, imageType)

        return historyId > 0
Exemplo n.º 2
0
    def addHistory(self, ruleName, imageBytes=None, imageType=None):
        """ updates the action history table, blocking until all data is retrieved and stored """
        """ returns true on successful update """

        from Robots.robotFactory import Factory

        cob = Factory.getCurrentRobot()
        dao = DataAccess()
        dateNow = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        location = dao.getRobotByName(cob.name)["locationId"]

        historyId = dao.saveHistory(dateNow, ruleName, location)

        if historyId > 0:
            dao.saveSensorHistory(historyId)

            if imageType == None:
                imageType = ActionHistory._defaultImageType

            if imageBytes == None:
                imageBytes = cob.getImage(retFormat=imageType)

            if imageBytes != None:
                dao.saveHistoryImage(historyId, imageBytes, imageType)

        return historyId > 0
Exemplo n.º 3
0
 def __init__(self):
     self._dao = DataAccess()
     self._preferences = self._dao.users.getUserPreferences()
     self._robot = Factory.getCurrentRobot()
     self._threadLights = myThreadLights(1, "Thread-Lights", self._robot)
     self._threadHead = myThreadHead(2, "Thread-Head", self._robot)
     self._threadBase = myThreadBase(3, "Thread-BaseDirect", self._robot)
     self._threadTray = myThreadTray(4, "Thread-Tray", self._robot)
Exemplo n.º 4
0
    def __init__(self, robot=None):
        super(RobotLocationProcessor, self).__init__()
        if robot == None:
            from Robots.robotFactory import Factory
            self._robot = Factory.getCurrentRobot()
        else:
            self._robot = robot

        robId = self._dao.getRobotByName(self._robot.name)['robotId']
        self._targetName = self._robot.name
        self._storedLoc = lambda: self._dao.getRobot(robId)
        self._curLoc = lambda: self._robot.getLocation(False)        
        self._updateLoc = lambda locid, x, y, orientation: self._dao.saveRobotLocation(robId, locid, x, y, orientation)
Exemplo n.º 5
0
    def __init__(self, robot=None):
        super(RobotLocationProcessor, self).__init__()
        if robot == None:
            from Robots.robotFactory import Factory
            self._robot = Factory.getCurrentRobot()
        else:
            self._robot = robot

        robId = self._dao.getRobotByName(self._robot.name)['robotId']
        self._targetName = self._robot.name
        self._storedLoc = lambda: self._dao.getRobot(robId)
        self._curLoc = lambda: self._robot.getLocation(False)        
        self._updateLoc = lambda locid, x, y, orientation: self._dao.saveRobotLocation(robId, locid, x, y, orientation)
Exemplo n.º 6
0
    def __init__(self, robot=None):
        super(RobotLocationProcessor, self).__init__()
        if robot == None:
            from Robots.robotFactory import Factory
            self._robot = Factory.getCurrentRobot()
        else:
            self._robot = robot

        robot = self._dao.getRobotByName(self._robot.name)
        if robot:
                robId = robot['robotId']
        else:
            raise ValueError("Error retrieving %s from the database" % self._robot.name)
        self._targetName = self._robot.name
        self._storedLoc = lambda: self._dao.getRobot(robId)
        self._curLoc = lambda: self._robot.getLocation(False)        
        self._updateLoc = lambda locid, x, y, orientation: self._dao.saveRobotLocation(robId, locid, x, y, orientation)
Exemplo n.º 7
0
    def POST(self, *args, **kwargs):
        
        request = json.loads(cherrypy.request.body.read())
        
        # Send the robot to certain location
        if request.has_key('location'):
            object = self._dao.getLocationByName(request['location']);
            robot = Factory.getCurrentRobot();

            robot.setComponentState('tray', request['tray'])
            robot.setComponentState('base', [object['xCoord'], object['yCoord'], object['orientation']])

        # Send voice command to the robot (espeak software required)        
        elif request.has_key('speech'):

            if self._dao.getUserPreferences()[0]['voice'] == 1:
                import subprocess
                #subprocess.call(['C:\\Program Files (x86)\\eSpeak\\command_line\\espeak.exe', request['speech']]) #Windows
                subprocess.call(['espeak', request['speech']]); #Linux
        else:      
            raise cherrypy.HTTPError(400)      
Exemplo n.º 8
0
    def addHistory(self, ruleName, imageBytes=None, imageType=None):
        
        from Robots.robotFactory import Factory
        cob = Factory.getCurrentRobot()
        dao = DataAccess()
        dateNow = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        location = dao.getRobotByName(cob.name)['locationId']
        
        historyId = dao.saveHistory(dateNow, ruleName, location)
        
        if(historyId > 0):
            dao.saveSensorHistory(historyId)

            if imageType == None:
                imageType = ActionHistory._defaultImageType

            if imageBytes == None:
                imageBytes = cob.getImage(retFormat=imageType)

            if imageBytes != None:
                dao.saveHistoryImage(historyId, imageBytes, imageType)
        
        return historyId > 0
Exemplo n.º 9
0
    def addHistoryComplete(self, ruleName, imageBytes=None, imageType=None, imageOverheadBytes=None, imageOverheadType=None):
        """ updates the action history table, blocking until all data is retrieved and stored """
        """ returns true on successful update """
        
        from Robots.robotFactory import Factory
        cob = Factory.getCurrentRobot()
        dao = DataAccess()
        dateNow = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        location = dao.getRobotByName(cob.name)['locationId']
        user = self._dao.users.getActiveUser['userId']

        historyId = dao.saveHistoryComplete(dateNow, ruleName, location, user)
        
        if(historyId > 0):
            #dao.saveSensorHistory(historyId)

            if imageType == None:
                imageType = ActionHistory._defaultImageType

            if imageBytes == None:
                imageBytes = cob.getImage(retFormat=imageType)

            if imageBytes != None:
                dao.saveHistoryImage(historyId, imageBytes, imageType)

            #the same but for the overhead camera image

            if imageOverheadType == None:
                imageOverheadType = ActionHistory._defaultImageType

            if imageOverheadBytes == None:
                imageOverheadBytes = cob.getImageOverhead(retFormat=imageOverheadType)

            if imageOverheadBytes != None:
                dao.saveHistoryImageOverhead(historyId, imageOverheadBytes, imageOverheadType)
        
        return historyId > 0
Exemplo n.º 10
0
                                                                                target.pose.position.z,
                                                                                math.degrees(yaw)))
                    location = [target.pose.position.x, target.pose.position.y, yaw]
                    print location
                    ret = self._robot.setComponentState('base', location)
                    print "++++++++++++++++++++++++++++++++++"
                    print "setComponentState of base returned", ret
                    print "++++++++++++++++++++++++++++++++++"
                    if ret == "SUCCEEDED":
                        print "returning true for base vs location check"
                        return True

        except self._rospy.ServiceException, e:
            print "Service did not process request: %s" % str(e)
        
        return False

if __name__ == "__main__":
    from optparse import OptionParser
    parser = OptionParser('proxemics.py userId userPosture X(m) Y(m) Orientation(deg) taskId')
    (_, args) = parser.parse_args()
    if(len(args) != 6):
        parser.error("incorrect number of arguments")
        
    from Robots.robotFactory import Factory
    r = Factory.getCurrentRobot()
    if r != None:
        p = ProxemicMover(r)
        p.gotoTarget(int(args[0]), int(args[1]), float(args[2]), float(args[3]), float(args[4]), int(args[5]))    
    
Exemplo n.º 11
0
                        "Response is: x=%f, y=%f, z=%f yaw=%f" %
                        (target.pose.position.x, target.pose.position.y,
                         target.pose.position.z, math.degrees(yaw)))
                    location = [
                        target.pose.position.x, target.pose.position.y, yaw
                    ]
                    if self._robot.setComponentState(
                            'base', location) in [3, 'SUCCEEDED']:
                        return True

        except self._rospy.ServiceException, e:
            print "Service did not process request: %s" % str(e)

        return False


if __name__ == "__main__":
    from optparse import OptionParser
    parser = OptionParser(
        'proxemics.py userId userPosture X(m) Y(m) Orientation(deg) taskId')
    (_, args) = parser.parse_args()
    if (len(args) != 6):
        parser.error("incorrect number of arguments")

    from Robots.robotFactory import Factory
    r = Factory.getCurrentRobot()
    if r != None:
        p = ProxemicMover(r)
        p.gotoTarget(int(args[0]), int(args[1]), float(args[2]),
                     float(args[3]), float(args[4]), int(args[5]))
Exemplo n.º 12
0
from Robots.robotFactory import Factory
import time

if __name__ == '__main__':
    c = Factory.getRobot('Care-O-Bot 3.2')
    time.sleep(10)

    # SEQ1
    # eyes up and torso left and up
    c.setComponentState('head', [[-2.84]], False)
    c.setComponentState('torso', [[0, 0, -0.2, 0.0]])
    time.sleep(4)
    # torso right and up
    c.setComponentState('torso', [[0, 0, 0.2, 0.0]])
    time.sleep(3)

    # SEQ2
    # eyes up and torso left and back
    c.setComponentState('torso', [[0, 0, -0.15, -0.15]])
    time.sleep(5)
    # torso right and up
    # c.setComponentState('torso', [[0,0,0.0,-0.15]])
    # for some reason crashes here
    c.setComponentState('torso', [[0, 0, 0.15, -0.15]])
    time.sleep(3)

    # SEQ3
    c.setComponentState('head', [[-3.04]], False)
    c.setComponentState('head', [[-2.84]], False)
    time.sleep(5)
    c.setComponentState('torso', [[0, 0, 0.2, 0]])
Exemplo n.º 13
0
from Robots.robotFactory import Factory
import time

if __name__ == '__main__':
    c = Factory.getRobot('Care-O-Bot 3.2')
    # base straight
    # c.setComponentState('base', [4.4,1,0])
    # base left
    c.setComponentState('base', [4.4, 1, -0.5])
    # base right
    c.setComponentState('base', [4.4, 1, 0.5])
    # torso and base straight
    c.setComponentState('base', [4.4, 1, -0.2])
    # torso down and left at table
    c.setComponentState('torso', [[0, 0, -0.2, 0.66]])
    # torso still down and right
    c.setComponentState('torso', [[0, 0, 0.2, 0.66]])
    # c.setComponentState('torso', [[0,0,0,0.35]])
    # torso down and center
    c.setComponentState('torso', [[0, 0, 0, 0.66]])
    # eyes up
    c.setComponentState('head', [[-2.84]], False)
    # time.sleep(1)
    # eyes down
    c.setComponentState('head', [[-3.14]], False)
    # time.sleep(1)
    # c.setComponentState('torso', 'right')
    # torso up
    # c.setComponentState('torso', 'left')
    
    # c.setComponentState('torso', 'home', False)
Exemplo n.º 14
0
 def __init__(self):
     self._dao = DataAccess()
     self._scenarios = Scenario()
     self._host = "nathan@sf1-1-pc1"
     self._robot = Factory.getCurrentRobot()
Exemplo n.º 15
0
from Robots.robotFactory import Factory
import time

if __name__ == "__main__":
    c = Factory.getRobot("Care-O-Bot 3.2")
    time.sleep(10)

    # SEQ1
    # eyes up and torso left and up
    c.setComponentState("head", [[-2.84]], False)
    c.setComponentState("torso", [[0, 0, -0.2, 0.0]])
    time.sleep(4)
    # torso right and up
    c.setComponentState("torso", [[0, 0, 0.2, 0.0]])
    time.sleep(3)

    # SEQ2
    # eyes up and torso left and back
    c.setComponentState("torso", [[0, 0, -0.15, -0.15]])
    time.sleep(5)
    # torso right and up
    # c.setComponentState('torso', [[0,0,0.0,-0.15]])
    # for some reason crashes here
    c.setComponentState("torso", [[0, 0, 0.15, -0.15]])
    time.sleep(3)

    # SEQ3
    c.setComponentState("head", [[-3.04]], False)
    c.setComponentState("head", [[-2.84]], False)
    time.sleep(5)
    c.setComponentState("torso", [[0, 0, 0.2, 0]])
Exemplo n.º 16
0
 def __init__(self):
     self._dao = DataAccess()
     self._robot = Factory.getRobot('UH Sunflower')
     self._thread1 = myThreadLights(1, "Thread-1", self._robot)
     self._thread2 = myThreadHead(2, "Thread-2", self._robot)