How to use the pypot.sensor.imu.lsm303.L3GD20Gyroscope function in pypot

To help you get started, we’ve selected a few pypot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github poppy-project / pypot / pypot / sensor / imu / lsm303.py View on Github external
def get_raw_data(self):
        x = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.XOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.XOUTLOW)
        if x >= 32768:
            x = BitArray(bin(x)).int

        y = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.YOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.YOUTLOW)
        if y >= 32768:
            y = BitArray(bin(y)).int

        z = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.ZOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.ZOUTLOW)
        if z >= 32768:
            z = BitArray(bin(z)).int

        return self.scale * (x + L3GD20Gyroscope.ZERO_X), self.scale * (y + L3GD20Gyroscope.ZERO_Y), self.scale * (z + L3GD20Gyroscope.ZERO_Z)
github poppy-project / pypot / pypot / sensor / imu / lsm303.py View on Github external
x = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.XOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.XOUTLOW)
        if x >= 32768:
            x = BitArray(bin(x)).int

        y = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.YOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.YOUTLOW)
        if y >= 32768:
            y = BitArray(bin(y)).int

        z = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.ZOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.ZOUTLOW)
        if z >= 32768:
            z = BitArray(bin(z)).int

        return self.scale * (x + L3GD20Gyroscope.ZERO_X), self.scale * (y + L3GD20Gyroscope.ZERO_Y), self.scale * (z + L3GD20Gyroscope.ZERO_Z)
github poppy-project / pypot / pypot / sensor / imu / lsm303.py View on Github external
def __init__(self, i2cBus, dps):
        self.bus = SMBus(i2cBus)
        self.bus.write_byte_data(
            L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.CTREG1, L3GD20Gyroscope.ON)
        self.bus.write_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.CTREG4, dps)
        if dps == L3GD20Gyroscope.DPS250:
            self.scale = 250.0 / 32768.0
        if dps == L3GD20Gyroscope.DPS500:
            self.scale = 500.0 / 32768.0
        if dps == L3GD20Gyroscope.DPS2000:
            self.scale = 2000.0 / 32768.0
github poppy-project / pypot / pypot / sensor / imu / lsm303.py View on Github external
def __init__(self, i2cBus=1):
        self.gyro = L3GD20Gyroscope(i2cBus, L3GD20Gyroscope.DPS2000)
        self.accel = LSM303Accelerometer(i2cBus, LSM303Accelerometer.SCALE_A_8G)
        initOrientation = self.accel.get_orientation()
        self.roll = initOrientation.roll
        self.pitch = initOrientation.pitch
        self.yaw = initOrientation.yaw
        self.kalmanFilter = KalmanFilter(
            IMU.GYRO_NOISE, IMU.BIAS_NOISE, IMU.ACCEL_NOISE)
        self.thread = threading.Thread(target=self.updateOrientation)
        self.thread.daemon = True
        self.thread.start()
github poppy-project / pypot / pypot / sensor / imu / lsm303.py View on Github external
def get_raw_data(self):
        x = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.XOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.XOUTLOW)
        if x >= 32768:
            x = BitArray(bin(x)).int

        y = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.YOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.YOUTLOW)
        if y >= 32768:
            y = BitArray(bin(y)).int

        z = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.ZOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.ZOUTLOW)
        if z >= 32768:
            z = BitArray(bin(z)).int

        return self.scale * (x + L3GD20Gyroscope.ZERO_X), self.scale * (y + L3GD20Gyroscope.ZERO_Y), self.scale * (z + L3GD20Gyroscope.ZERO_Z)
github poppy-project / pypot / pypot / sensor / imu / lsm303.py View on Github external
def __init__(self, i2cBus, dps):
        self.bus = SMBus(i2cBus)
        self.bus.write_byte_data(
            L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.CTREG1, L3GD20Gyroscope.ON)
        self.bus.write_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.CTREG4, dps)
        if dps == L3GD20Gyroscope.DPS250:
            self.scale = 250.0 / 32768.0
        if dps == L3GD20Gyroscope.DPS500:
            self.scale = 500.0 / 32768.0
        if dps == L3GD20Gyroscope.DPS2000:
            self.scale = 2000.0 / 32768.0
github poppy-project / pypot / pypot / sensor / imu / lsm303.py View on Github external
def get_raw_data(self):
        x = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.XOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.XOUTLOW)
        if x >= 32768:
            x = BitArray(bin(x)).int

        y = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.YOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.YOUTLOW)
        if y >= 32768:
            y = BitArray(bin(y)).int

        z = 256 * self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.ZOUTHIGH) + \
            self.bus.read_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.ZOUTLOW)
        if z >= 32768:
            z = BitArray(bin(z)).int

        return self.scale * (x + L3GD20Gyroscope.ZERO_X), self.scale * (y + L3GD20Gyroscope.ZERO_Y), self.scale * (z + L3GD20Gyroscope.ZERO_Z)
github poppy-project / pypot / pypot / sensor / imu / lsm303.py View on Github external
def __init__(self, i2cBus, dps):
        self.bus = SMBus(i2cBus)
        self.bus.write_byte_data(
            L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.CTREG1, L3GD20Gyroscope.ON)
        self.bus.write_byte_data(L3GD20Gyroscope.L3GADDR, L3GD20Gyroscope.CTREG4, dps)
        if dps == L3GD20Gyroscope.DPS250:
            self.scale = 250.0 / 32768.0
        if dps == L3GD20Gyroscope.DPS500:
            self.scale = 500.0 / 32768.0
        if dps == L3GD20Gyroscope.DPS2000:
            self.scale = 2000.0 / 32768.0