Пример #1
0
    def __init__(self,
                 port = None, 
                 simulator = 0,
                 rate = None,
                 subtype = "Roomba"):
        # simulator = 0 makes it real
        PyroRobot.__init__(self) # robot constructor
        self.lock = threading.Lock()
        self.buffer = ''
        self.debug = 0
        if simulator == 1:
            raise AttributeError, "simulator no longer supported"
        else:
            if subtype == "Roomba":
                if port == None:
                    port = ask("Port", useCache = 1)
                if rate == None:
                    rate = 57600
            if type(port) == str and port.lower().startswith("com"):
                portnum = int(port[3:])
                if portnum >= 10:
                    port = r'\\.\COM%d' % (portnum)
            print "Roomba opening port '%s' with baudrate %s ..." % (port, rate)
            try:
                myro.globvars.robot.sc.close()
            except KeyboardInterrupt:
                raise
            except:
                pass
            self.sc = serial.Serial(port) #, xonxoff=0, rtscts=0)
            self.sc.setTimeout(0.5)
	    self.sc.baudrate = rate
            self.sc.readlines() # to clear out the line
	self.lastTranslate = 0
	self.lastRotate = 0
	self.subtype = subtype
        self.radius = .16 #meters
        self._newline = "\r"
        self.type = "Roomba"
        self.port = port
        self.simulated = simulator
        self.sendMsg('\x80') #Start Sci
	self.sendMsg('\x82') #Give user control
	self.sendMsg('\x8E\x02') # reset sensors, useful for distance
	self.sensorData = {} # Holds all of the sensor data
	self.builtinDevices = ["ir", "bumper", "battery"]
	for name in self.builtinDevices:
            self.startDevice(name)
	self.update() 
        print "Done loading Roomba."
Пример #2
0
    def __init__(self,
                 port = None, 
                 simulator = 0,
                 rate = None,
                 subtype = "Roomba"):
        # simulator = 0 makes it real
        PyroRobot.__init__(self) # robot constructor
        self.lock = threading.Lock()
        self.buffer = ''
        self.debug = 0
        if simulator == 1:
            raise AttributeError, "simulator no longer supported"
        else:
            if subtype == "Roomba":
                if port == None:
                    port = ask("Port", useCache = 1)
                if rate == None:
                    rate = 57600
            if type(port) == str and port.lower().startswith("com"):
                portnum = int(port[3:])
                if portnum >= 10:
                    port = r'\\.\COM%d' % (portnum)
            print "Roomba opening port '%s' with baudrate %s ..." % (port, rate)
            try:
                myro.globvars.robot.sc.close()
            except KeyboardInterrupt:
                raise
            except:
                pass
            self.sc = serial.Serial(port) #, xonxoff=0, rtscts=0)
            self.sc.setTimeout(0.5)
	    self.sc.baudrate = rate
            self.sc.readlines() # to clear out the line
	self.lastTranslate = 0
	self.lastRotate = 0
	self.subtype = subtype
        self.radius = .16 #meters
        self._newline = "\r"
        self.type = "Roomba"
        self.port = port
        self.simulated = simulator
        self.sendMsg('\x80') #Start Sci
	self.sendMsg('\x82') #Give user control
	self.sendMsg('\x8E\x02') # reset sensors, useful for distance
	self.sensorData = {} # Holds all of the sensor data
	self.builtinDevices = ["ir", "bumper", "battery"]
	for name in self.builtinDevices:
            self.startDevice(name)
	self.update() 
        print "Done loading Roomba."
Пример #3
0
 def __init__(self, host, port, startDevices=1):
     Robot.__init__(self)
     self.lock = threading.Lock()
     # Set the socket parameters
     self.host = host
     self.port = port
     self.addr = (host, port)
     self.type = "Pyrobot"
     # Create socket
     self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     try:
         self.socket.settimeout(1)
     except:
         print "WARN: entering deadlock zone; upgrade to Python 2.3 to avoid"
     done = 0
     while not done:
         try:
             self.socket.connect(self.addr)
             done = 1
         except:
             print "Waiting on PyrobotSimulator..."
             time.sleep(1)
     self.connectionNum = self.getItem("connectionNum:%d" % self.port)
     self.init(startDevices)
Пример #4
0
 def __init__(self, host, port, startDevices=1):
     Robot.__init__(self)
     self.lock = threading.Lock()
     # Set the socket parameters
     self.host = host
     self.port = port
     self.addr = (host, port)
     self.type = "Pyrobot"
     # Create socket
     self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     try:
         self.socket.settimeout(1)
     except:
         print "WARN: entering deadlock zone; upgrade to Python 2.3 to avoid"
     done = 0
     while not done:
         try:
             self.socket.connect(self.addr)
             done = 1
         except:
             print "Waiting on PyrobotSimulator..."
             time.sleep(1)
     self.connectionNum = self.getItem("connectionNum:%d" % self.port)
     self.init(startDevices)
Пример #5
0
    def update(self):
        PyroRobot.update(self)
        self.readData()

	''' Attempt at adjusting for straight travel
Пример #6
0
 def __init__(self, simulator, port, connectionNum, startDevices=1):
     Robot.__init__(self)
     self.simulator = simulator
     self.connectionNum = connectionNum
     self.port = port
     self.init(startDevices)
Пример #7
0
 def __init__(self, simulator, port, connectionNum, startDevices=1):
     Robot.__init__(self)
     self.simulator = simulator
     self.connectionNum = connectionNum
     self.port = port
     self.init(startDevices)
Пример #8
0
    def update(self):
        PyroRobot.update(self)
        self.readData()

	''' Attempt at adjusting for straight travel