Пример #1
0
	def __init__(self):
		from i2clibraries import i2c_hmc5883l
		from i2clibraries import i2c_adxl345
		from i2clibraries import i2c_itg3205
		i2c_port = 0  # different versions of the pi use different ports
		self.accelerometer = i2c_adxl345.i2c_adxl345(i2c_port)
		self.accelerometer.setScale(2)
		self.gyroscope = i2c_itg3205.i2c_itg3205(i2c_port, addr=0x68)
		self.magnetometer = i2c_hmc5883l.i2c_hmc5883l(i2c_port)
		self.magnetometer.setContinuousMode()
		self.magnetometer.setDeclination(1,43)  # magnetic declination in degrees west (degrees, minute)
		print("SEN10724 IMU initialised")
Пример #2
0
    def __init__(self):
        threading.Thread.__init__(self)
        self.init_log()
        self.cur_song = None
        self.rangeData = []
        self.curtime = 0
        self.rangeSecond = 5
        self.axisX = 0
        self.axisY = 1
        self.axisZ = 2

        self.sample_HZ = 100
        self.adxl345 = i2c_adxl345.i2c_adxl345(1)
        self.adxl345.setScale(2)
        self.song_sensor_data = None

        filepath = os.path.join(os.getcwd(), 'sensor_data')
        if (False == os.path.exists(filepath)):
            os.makedirs(filepath)
Пример #3
0
    def __init__(self):
        threading.Thread.__init__(self)
        self.init_log()
        self.cur_song=None
        self.rangeData=[]
        self.curtime=0
        self.rangeSecond=5
        self.axisX=0
        self.axisY=1
        self.axisZ=2

        self.sample_HZ=100
        self.adxl345 = i2c_adxl345.i2c_adxl345(1)
        self.adxl345.setScale(2)
        self.song_sensor_data=None

        
        filepath=os.path.join(os.getcwd(),'sensor_data')
        if (False == os.path.exists(filepath)):
            os.makedirs(filepath)
archivo.write("Inicio\n")

#Interface with the controller
gamepad = InputDevice("/dev/input/event0")
print(gamepad)

#Interface with the GPS
gps_connection = gps3.GPSDSocket(host='127.0.0.1')
gps_fix = gps3.Fix()

#Interface with the Compass
hmc5883l = i2c_hmc5883l.i2c_hmc5883l(1)
hmc5883l.setContinuousMode()
hmc5883l.setDeclination(8,0)

adxl345 = i2c_adxl345.i2c_adxl345(1)

direccionFinal = 1

#Instance of the API
api = Api("carroV1")

compassHeading = None
velocity = 0
manual = True

while True:    
    event = gamepad.read_one()
    x = api.Read()
    if(x == True):
        velocity = 0
Пример #5
0
from datetime import datetime
import time

import os
import random
import argparse

from configparser import ConfigParser
from collections import deque


# Declare ADXL345 class from adxl345 library
# generateZeroData is a debug tool to keep the script running if
# the ADXL does initialize due to some error
try:
	myADXL = i2c_adxl345.i2c_adxl345(1)
	generateZeroData = False
except:
	myADXL = 0
	generateZeroData = True
	
piID = "RPi_Unassigned"

# Testing

# Interval controls how often we retrieve axes (seconds)
interval = 0.1

# Declare counters and counterError
counter = 0
counterError = 0
Пример #6
0
from i2clibraries import i2c_adxl345
from time import *

adxl345 = i2c_adxl345.i2c_adxl345(1)

while True:
    print(adxl345)
    sleep(1)
Пример #7
0
	def __init__(self): 
		self.adxl345 = i2c_adxl345.i2c_adxl345(1)
Пример #8
0
from i2clibraries import i2c_adxl345
from time import *
import os
os.system("export QUICK2WIRE_API_HOME=~/myproject/quick2wire-python-api")

os.system("export PYTHONPATH=$PYTHONPATH:$QUICK2WIRE_API_HOME")

adxl345 = i2c_adxl345.i2c_adxl345(port = 1)

while True:
        print(adxl345)
        sleep(1.2)
Пример #9
0
import time
from i2clibraries import i2c_adxl345

adxl345 = i2c_adxl345.i2c_adxl345(
    1)  #choosing which i2c port to use, RPi2 model B uses port 1

while True:
    print("%f %f %f", adxl345.getAxes)
    time.sleep(1)
Пример #10
0
 def __init__(self):
     self.adxl345 = i2c_adxl345.i2c_adxl345(1)
     self.adxl345.setScale(16)
     threading.Thread.__init__(self)
Пример #11
0
# Code to run the entire image processing and compass sensor data acquisition
# Must be run with python3
from i2clibraries import i2c_hmc5883l
from i2clibraries import i2c_adxl345
import time
import os
import serial

# get compass object to communicate through i2c
compass = i2c_hmc5883l.i2c_hmc5883l(1)
trap = 0
accel = i2c_adxl345.i2c_adxl345(1)
ser = None
read_data = ''
read_object = -1
[BANANA, BOTTLE] = ['0','1']
correct_heading = 0

def main():
    global compass
    global accel
    global trap
    global ser
    global read_object
    global read_data
    global correct_heading

    # Configuring the compass sensor
    compass.setContinuousMode()
    compass.setDeclination(16,0)