def handle_line_sensor(regObj):
    
    if en_debug:
        print ("line follower!")
        
    sensors = {}
    explanation = [
    "Completely to the left", 
    "Way to the left",
    "Going left",
    "Slightly to the left",
    "Center", 
    "Slightly to the right",
    "Going right",
    "Way to the right",
    "Completely to the right",
    "Reading black everywhere",
    "Reading white everywhere",
    "Technical difficulties"
    ]
    try:
        import sys
        # NOTE: for now te line follower is still kept in the GoPiGo folder
        sys.path.insert(0, '/home/pi/Dexter/GoPiGo/Software/Python/line_follower')
        # import line_sensor
        import scratch_line

    except ImportError:
        print ("Line sensor libraries not found")
        return({'line':-3,'line explanation': "technical difficulties"})

    try:
        line=scratch_line.line_sensor_val_scratch()
        time.sleep(0.01)
        line=scratch_line.line_sensor_val_scratch()
        if en_debug:
            print ("Line Sensor Readings: {}".format(str(line)))
        sensors["line follower"] = line
        sensors["line explanation"] = explanation[line+4]

    except Exception as e:
        if debug:
            print ("Error reading Line sensor: {}",format(str(e)))
        sensors["line"] = -3
    
    return sensors
def handle_line_sensor(regObj):
    
    if en_debug:
        print ("line follower!")
        
    sensors = {}
    explanation = [
    "Completely to the left", 
    "Way to the left",
    "Going left",
    "Slightly to the left",
    "Center", 
    "Slightly to the right",
    "Going right",
    "Way to the right",
    "Completely to the right",
    "Reading black everywhere",
    "Reading white everywhere",
    "Technical difficulties"
    ]
    try:
        import sys
        # NOTE: for now te line follower is still kept in the GoPiGo folder
        sys.path.insert(0, '/home/pi/Dexter/GoPiGo/Software/Python/line_follower')
        # import line_sensor
        import scratch_line

    except ImportError:
        print ("Line sensor libraries not found")
        return({'line':-3,'line explanation': "technical difficulties"})

    try:
        line=scratch_line.line_sensor_val_scratch()
        time.sleep(0.01)
        line=scratch_line.line_sensor_val_scratch()
        if en_debug:
            print ("Line Sensor Readings: {}".format(str(line)))
        sensors["line follower"] = line
        sensors["line explanation"] = explanation[line+4]

    except Exception as e:
        if debug:
            print ("Error reading Line sensor: {}",format(str(e)))
        sensors["line"] = -3
    
    return sensors
Example #3
0
				s.sensorupdate({'ir':a})
				
		# Get the value from the Dexter Industries line sensor
		elif msg.lower()=="LINE".lower():
			try:
				import sys
				sys.path.insert(0, '/home/pi/Dexter/GoPiGo/Software/Python/line_follower')
				# import line_sensor
				import scratch_line
			except ImportError:
				print "Line sensor libraries not found"
				s.sensorupdate({'line':-3})
			if en_debug:
				print "LINE!"
			try:
				line=scratch_line.line_sensor_val_scratch()
			except:
				if en_debug:
					e = sys.exc_info()[1]
					print "Error reading Line sensor: " + str(e)
			if en_debug:
				print "Line Sensor Readings: " + str(line)
			if en_gpg:
				s.sensorupdate({'line':line})	
		
		elif msg.lower()=="READ_IR".lower():
			print "READ_IR!" 
			if en_ir_sensor==0:
				import lirc
				sockid = lirc.init("keyes", blocking = False)
				en_ir_sensor=1