Пример #1
0
    def __init__(self,
                 port = None, 
                 simulator = 0,
                 rate = None,
                 subtype = "Roomba"):
        # simulator = 0 makes it real
        Robot.__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:
                    try:
                        port = config.get('Roomba', 'port')
                    except:
                        pass
                if port == None:
                    port = "/dev/rfcomm0"
                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)
            self.sc = Serial(port, baudrate=rate) #, xonxoff=0, rtscts=0)
            self.sc.setTimeout(0.5)
            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.supportedFeatures.append( "continuous-movement" )
        self.supportedFeatures.append( "range-sensor" )
        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.supportedFeatures.append( "mono-sound" )
	self.supportedFeatures.append( "visual-feedback" )
	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
     Robot.__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:
                 try:
                     port = config.get('Roomba', 'port')
                 except:
                     pass
             if port == None:
                 port = "/dev/rfcomm0"
             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)
         self.sc = Serial(port, baudrate=rate)  #, xonxoff=0, rtscts=0)
         self.sc.setTimeout(0.5)
         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.supportedFeatures.append("continuous-movement")
     self.supportedFeatures.append("range-sensor")
     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.supportedFeatures.append("mono-sound")
     self.supportedFeatures.append("visual-feedback")
     self.builtinDevices = ["ir", "bumper", "battery"]
     for name in self.builtinDevices:
         self.startDevice(name)
     self.update()
     print "Done loading Roomba."
Пример #3
0
    def __init__(self,
                 port = None,
                 simulator = 0,
                 rate = None,
                 subtype = "IntelliBrainBot"):
        # simulator = 0 makes it real
        Robot.__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 == "IntelliBrainBot":
                if port == None:
                    try:
                        port = config.get('IntelliBrainBot', 'port')
                    except:
                        pass
                if port == None:
                    port = "/dev/ttyUSB0"
                if rate == None:
                    rate = 38400
            print "IntelliBrain opening port", port, "..."
            self.sc = Serial(port, baudrate=rate) #, xonxoff=0, rtscts=0)
            self.sc.setTimeout(0)
            self.sc.readlines() # to clear out the line
	self.lastTranslate = 0
   	self.lastRotate = 0
	self.currSpeed = [0, 0]
        
	# This could go as high as 127, but I am keeping it small
        # to be on the same scale as larger robots. -DSB
	self.translateFactor = 9
        self.dataTypes = {'n' : 'ir',
                          'o' : 'light'
                          }
        self.rawData = {}
	self.rawData['position'] = [0] * 3
        self.rawData['ir'] = [0] * 2
        self.rawData['light'] = [0] * 2
        self.subtype = subtype
        self.radius = .06 #meters
        self.builtinDevices = ['ir', 'light']
        self._newline = "\r"

        self.startDevice("ir")
        self.range = self.ir[0]
        self.startDevice("light")

        self.rawData["position"] = 0, 0
        # self.sendMsg('B') # version
        # self.sendMsg('j') # extensionDevices

        self.x = 0.0
        self.y = 0.0
        self.thr = 0.0
        self.th = 0.0
        self.w0 = self.rawData['position'][0]
        self.w1 = self.rawData['position'][1]
        self.type = "IntelliBrain"
        self.port = port
        self.simulated = simulator
        self.supportedFeatures.append( "continuous-movement" )
        self.supportedFeatures.append( "range-sensor" )
	self.supportedFeatures.append( "light-sensor" )
	self.supportedFeatures.append( "mono-sound" )
	self.supportedFeatures.append( "visual-feedback" )
	self.update() 
        print "Done loading IntelliBrain."
Пример #4
0
    def __init__(self,
                 port = None,
                 simulator = 0,
                 rate = None,
                 subtype = "IntelliBrainBot"):
        # simulator = 0 makes it real
        Robot.__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 == "IntelliBrainBot":
                if port == None:
                    try:
                        port = config.get('IntelliBrainBot', 'port')
                    except:
                        pass
                if port == None:
                    port = "/dev/ttyUSB0"
                if rate == None:
                    rate = 38400
            print "IntelliBrain opening port", port, "..."
            self.sc = Serial(port, baudrate=rate) #, xonxoff=0, rtscts=0)
            self.sc.setTimeout(0)
            self.sc.readlines() # to clear out the line
	self.lastTranslate = 0
   	self.lastRotate = 0
	self.currSpeed = [0, 0]
        
	# This could go as high as 127, but I am keeping it small
        # to be on the same scale as larger robots. -DSB
	self.translateFactor = 9
        self.dataTypes = {'n' : 'ir',
                          'o' : 'light'
                          }
        self.rawData = {}
	self.rawData['position'] = [0] * 3
        self.rawData['ir'] = [0] * 2
        self.rawData['light'] = [0] * 2
        self.subtype = subtype
        self.radius = .06 #meters
        self.builtinDevices = ['ir', 'light']
        self._newline = "\r"

        self.startDevice("ir")
        self.range = self.ir[0]
        self.startDevice("light")

        self.rawData["position"] = 0, 0
        # self.sendMsg('B') # version
        # self.sendMsg('j') # extensionDevices

        self.x = 0.0
        self.y = 0.0
        self.thr = 0.0
        self.th = 0.0
        self.w0 = self.rawData['position'][0]
        self.w1 = self.rawData['position'][1]
        self.type = "IntelliBrain"
        self.port = port
        self.simulated = simulator
        self.supportedFeatures.append( "continuous-movement" )
        self.supportedFeatures.append( "range-sensor" )
	self.supportedFeatures.append( "light-sensor" )
	self.supportedFeatures.append( "mono-sound" )
	self.supportedFeatures.append( "visual-feedback" )
	self.update() 
        print "Done loading IntelliBrain."
Пример #5
0
    def __init__(self,
                 port = None,
                 simulator = 0,
                 rate = None,
                 subtype = "Khepera"):
        # simulator = 0 makes it real
        Robot.__init__(self) # robot constructor
        self.lock = threading.Lock()
        self.buffer = ''
        self.debug = 0
        self.pause = 0.1 # for hemisson to keep from swamping the wireless
        if simulator == 1:
            raise AttributeError, "simulator no longer supported"
        else:
            if subtype == "Khepera":
                if port == None:
                    try:
                        port = config.get('khepera', 'port')
                    except:
                        pass
                if port == None:
                    port = "/dev/ttyS0"
                if rate == None:
                    rate = 38400
            else:
                if port == None:
                    try:
                        port = config.get('hemisson', 'port')
                    except:
                        pass
                if port == None:
                    port = "/dev/rfcomm0"
                if rate == None:
                    rate = 115200
            print "K-Team opening port", port, "..."
            self.sc = Serial(port, baudrate=rate) #, xonxoff=0, rtscts=0)
            self.sc.setTimeout(0)
            self.sc.readlines() # to clear out the line
        self.stallTolerance = 0.25
        self.stallHistoryPos = 0
        self.stallHistorySize = 5
        self.stallHistory = [0] * self.stallHistorySize
        self.lastTranslate = 0
        self.lastRotate = 0
        self.currSpeed = [0, 0]
        # This could go as high as 127, but I am keeping it small
        # to be on the same scale as larger robots. -DSB
        self.translateFactor = 12
        self.rotateFactor = 12
        self.dataTypes = {'n': 'ir',
                          'h' : 'position',
                          'o' : 'light',
                          'k' : 'stall',
                          'e' : 'speed',
                          'b' : 'version',
                          'j' : 'extensionDevices',
                          't1b'  : 'gripper software',
                          't1f'  : 'gripper resistivity',
                          't1g'  : 'gripper beam state',
                          't1h1' : 'gripper arm position',
                          't1h0' : 'gripper state',
                          't1j'  : 'gripper jumpers'
                          }
        self.rawData = {}
        self.rawData['position'] = [0] * 3
        self.rawData['ir'] = [0] * 6
        self.rawData['light'] = [0] * 6
        self.rawData['stall'] = [0] * 6
        self.subtype = subtype
        if subtype == "Hemisson":
            self.radius = .06 #meters
            self.builtinDevices = ['ir', 'light', 'audio']
            self._newline = "\r"
        elif subtype == "Khepera":
            self.radius = .03 #meters
            self.builtinDevices = ['ir', 'light', 'gripper']
            self._newline = "\n"
        else:
            raise TypeError, "invalid K-Team subtype: '%s'" % subtype
        self.startDevice("ir")
        self.range = self.ir[0]
        self.startDevice("light")
        if subtype == "Khepera":
            self.sendMsg('H') # position
        else:
            self.rawData["position"] = 0, 0
            self.sendMsg('B') # version
            self.sendMsg('j') # extensionDevices
        self.x = 0.0
        self.y = 0.0
        self.thr = 0.0
        self.th = 0.0
        try:
            self.w0 = self.rawData['position'][0]
            self.w1 = self.rawData['position'][1]
        except:
            raise "KTeamConnectionError"
        self.type = "K-Team"
        self.port = port
        self.simulated = simulator
        # ----- Updatable things:
        self.stall = self.isStall()
        self.x = 0.0
        self.y = 0.0
        self.z = 0.0
        self.th = 0.0
        self.thr = 0.0
        self.supportedFeatures.append( "odometry" )
        self.supportedFeatures.append( "continuous-movement" )
        self.supportedFeatures.append( "range-sensor" )
	self.update() 
        print "Done loading K-Team robot."
Пример #6
0
 def __init__(self, port=None, simulator=0, rate=None, subtype="Khepera"):
     # simulator = 0 makes it real
     Robot.__init__(self)  # robot constructor
     self.lock = threading.Lock()
     self.buffer = ''
     self.debug = 0
     self.pause = 0.1  # for hemisson to keep from swamping the wireless
     if simulator == 1:
         raise AttributeError, "simulator no longer supported"
     else:
         if subtype == "Khepera":
             if port == None:
                 try:
                     port = config.get('khepera', 'port')
                 except:
                     pass
             if port == None:
                 port = "/dev/ttyS0"
             if rate == None:
                 rate = 38400
         else:
             if port == None:
                 try:
                     port = config.get('hemisson', 'port')
                 except:
                     pass
             if port == None:
                 port = "/dev/rfcomm0"
             if rate == None:
                 rate = 115200
         print "K-Team opening port", port, "..."
         self.sc = Serial(port, baudrate=rate)  #, xonxoff=0, rtscts=0)
         self.sc.setTimeout(0)
         self.sc.readlines()  # to clear out the line
     self.stallTolerance = 0.25
     self.stallHistoryPos = 0
     self.stallHistorySize = 5
     self.stallHistory = [0] * self.stallHistorySize
     self.lastTranslate = 0
     self.lastRotate = 0
     self.currSpeed = [0, 0]
     # This could go as high as 127, but I am keeping it small
     # to be on the same scale as larger robots. -DSB
     self.translateFactor = 12
     self.rotateFactor = 12
     self.dataTypes = {
         'n': 'ir',
         'h': 'position',
         'o': 'light',
         'k': 'stall',
         'e': 'speed',
         'b': 'version',
         'j': 'extensionDevices',
         't1b': 'gripper software',
         't1f': 'gripper resistivity',
         't1g': 'gripper beam state',
         't1h1': 'gripper arm position',
         't1h0': 'gripper state',
         't1j': 'gripper jumpers'
     }
     self.rawData = {}
     self.rawData['position'] = [0] * 3
     self.rawData['ir'] = [0] * 6
     self.rawData['light'] = [0] * 6
     self.rawData['stall'] = [0] * 6
     self.subtype = subtype
     if subtype == "Hemisson":
         self.radius = .06  #meters
         self.builtinDevices = ['ir', 'light', 'audio']
         self._newline = "\r"
     elif subtype == "Khepera":
         self.radius = .03  #meters
         self.builtinDevices = ['ir', 'light', 'gripper']
         self._newline = "\n"
     else:
         raise TypeError, "invalid K-Team subtype: '%s'" % subtype
     self.startDevice("ir")
     self.range = self.ir[0]
     self.startDevice("light")
     if subtype == "Khepera":
         self.sendMsg('H')  # position
     else:
         self.rawData["position"] = 0, 0
         self.sendMsg('B')  # version
         self.sendMsg('j')  # extensionDevices
     self.x = 0.0
     self.y = 0.0
     self.thr = 0.0
     self.th = 0.0
     try:
         self.w0 = self.rawData['position'][0]
         self.w1 = self.rawData['position'][1]
     except:
         raise "KTeamConnectionError"
     self.type = "K-Team"
     self.port = port
     self.simulated = simulator
     # ----- Updatable things:
     self.stall = self.isStall()
     self.x = 0.0
     self.y = 0.0
     self.z = 0.0
     self.th = 0.0
     self.thr = 0.0
     self.supportedFeatures.append("odometry")
     self.supportedFeatures.append("continuous-movement")
     self.supportedFeatures.append("range-sensor")
     self.update()
     print "Done loading K-Team robot."