Exemplo n.º 1
0
	gyro = SensorITG3200(1,0x68)
	gyro.default_init()
	zeroX,zeroY,zeroZ = gyro.calibrate(1000,0.002)
	print 'Compass Initialization ... [Ok]'
	compass = SensorHMC5338L(1,0x1e)	
		
	# Accelerometer:
	# adxl(i2c_adapter,bus_nr,resolution)
	# resolution:      [0,1,2,3] for [2g,4g,8g,16g]

    	adx = Adxl(1,0x53,0)
	helpInfo()	
	
	while not shutdown == 1:
		data = []
		data.append(adx.getRoll())
		data.append(adx.getPitch())
		data.append(compass.getBearing())
		time.sleep(0.1)
		send_array(conn, data)
		continue		

		axes = adx.getAxes()
		gx,gy,gz = gyro.read_data_calib()
		mx,my,mz = compass.read_data()
		data.append(axes['x'])
		data.append(axes['y'])
		data.append(axes['z'])
		data.append(gx)
		data.append(gy)
		data.append(gz)
Exemplo n.º 2
0
    gyro = SensorITG3200(1, 0x68)
    gyro.default_init()
    zeroX, zeroY, zeroZ = gyro.calibrate(1000, 0.002)
    print 'Compass Initialization ... [Ok]'
    compass = SensorHMC5338L(1, 0x1e)

    # Accelerometer:
    # adxl(i2c_adapter,bus_nr,resolution)
    # resolution:      [0,1,2,3] for [2g,4g,8g,16g]

    adx = Adxl(1, 0x53, 0)
    helpInfo()

    while not shutdown == 1:
        data = []
        data.append(adx.getRoll())
        data.append(adx.getPitch())
        data.append(compass.getBearing())
        time.sleep(0.1)
        send_array(conn, data)
        continue

        axes = adx.getAxes()
        gx, gy, gz = gyro.read_data_calib()
        mx, my, mz = compass.read_data()
        data.append(axes['x'])
        data.append(axes['y'])
        data.append(axes['z'])
        data.append(gx)
        data.append(gy)
        data.append(gz)
Exemplo n.º 3
0
		if input == 'q':
			exit()
		if input == 'a':
			axes = adx.getAxes()
	                axesG = adx.toG(axes)
        	        print "\n\nAcc X: ", axes['x'] , "m/s^2"
               		print "Acc X: ", axesG['x'], "G\t"

	                print "\n\nAcc Y: ", axes['y'] , "m/s^2"
	                print "Acc Y: ", axesG['y'], "G\t"

        	        print "\n\nAcc Z: ", axes['z'] , "m/s^2"
	                print "Acc Z: ", axesG['z'], "G\t"

		if input == 'r':
        	        print "\n\nx rotation: " , adx.getRoll()
		if input == 'p':
	                print "y rotation: " , adx.getPitch()
		if input == 'm':
			print "Bearing: ", compass.getBearing()
		if input == 'h':
			helpInfo()
		if input == 'b':
			tempPress = bmp085.read_temperature_and_pressure()	
			print 'T\t%.2f\nP\t%.2f\nA\t%f' % (tempPress[0],tempPress[1],bmp085.readAltitude())
		if input == 't':
			print "All data from the IMU: "
			tempPress = bmp085.read_temperature_and_pressure()	
			gx,gy,gz = gyro.read_data_calib()
			print 'T\t%.2f\nP\t%.2f\nA\t%f' % (tempPress[0],tempPress[1],bmp085.readAltitude(1016101610161016101610161016101610161016))
			print 'gx:\t%d\ngy:\t%d\ngz:\t%d' % (gx,gy,gz)