def __init__(self, sensor): from data import Sensor, Filter from pid import DronePID from motors import BLDC sensorfusion = kalman.Kalman()#madgwick.Madgwick(0.023) sensorfusion.roll = 0 sensorfusion.pitch = 0 sensorfusion.yaw = 0 address = 0x68 bus = smbus.SMBus(1) imu = MPU9250.MPU9250(bus, address) imu.begin() imu.loadCalibDataFromFile("/home/pi/projects/drone/app/flask/utils/calib.json") self.pids = DronePID() m = BLDC.from_csv() self.motors = [m[0], m[3], m[1], m[2]] self.sensor = imu#sensor self.filter = sensorfusion#Filter() self.r = redis.Redis('localhost') self.r.delete('_drone_cmd') self.r.delete(prio_cmd) atexit.register(self.quit) t0 = time.time() time.sleep(0.5) self._running = False self.start()
def __init__(self): address = 0x68 bus = smbus.SMBus(1) self.imu = MPU9250.MPU9250(bus, address) self.imu.begin() self.heading = 0 self.kill_thread = False self.heading_thread = threading.Thread(target=self.track_heading) self.heading_thread.start()
def __init__(self): self.disp = Adafruit_SSD1306.SSD1306_128_64(rst=None) self.disp.begin() self.disp.clear() self.disp.display() self.font = ImageFont.truetype('freepixel-modified.ttf', 16) self.draw(-1, "Starting Up") address = 0x68 bus = smbus.SMBus(1) self.imu = MPU9250.MPU9250(bus, address) self.imu.begin() self.draw(-1, "Calibrating Gyro") self.imu.caliberateGyro()
def __init__(self, debug=False): super(KalmanMPU, self).__init__() self.address = 0x68 self.debug = debug self.ended = False self.bus = smbus.SMBus(1) self.imu = MPU9250.MPU9250(self.bus, self.address) self.imu.setLowPassFilterFrequency("AccelLowPassFilter184") self.imu.begin() self.imu.loadCalibDataFromFile("/home/pi/calib_real4.json") self.sensorfusion = kalman.Kalman() self.imu.readSensor() self.imu.computeOrientation() self.sensorfusion.roll = self.imu.roll self.sensorfusion.pitch = self.imu.pitch self.sensorfusion.yaw = self.imu.yaw
# initializing publisher host = '192.168.1.8' port = 8358 url = 'tcp://' + host + ':' + str(port) context = zmq.Context() socket = context.socket(zmq.PUB) socket.bind(url) sensorfusion = madgwick.Madgwick(0.1) kalman_filter = kalman.Kalman() tca = adafruit_tca9548a.TCA9548A(busio.I2C(board.SCL, board.SDA)) address = 0x68 imu = MPU9250.MPU9250(tca, address, 0) imu.begin() # imu.caliberateAccelerometer() # print ("Acceleration calib successful") # imu.caliberateMag() # print ("Mag calib successful") # or load your caliberation file # imu.loadCalibDataFromFile("/home/pi/calib_real_bolder.json") imu.readSensor() imu.computeOrientation() kalman_filter.roll = imu.roll kalman_filter.pitch = imu.pitch kalman_filter.yaw = imu.yaw print_count = 0
import os import sys import time import smbus from imusensor.MPU9250 import MPU9250 from imusensor.filters import madgwick sensorfusion = madgwick.Madgwick(0.5) address = 0x68 bus = smbus.SMBus(1) imu = MPU9250.MPU9250(bus, address) imu.begin() # imu.caliberateGyro() # imu.caliberateAccelerometer() # or load your own caliberation file #imu.loadCalibDataFromFile("/home/pi/calib_real4.json") currTime = time.time() print_count = 0 while True: imu.readSensor() for i in range(10): newTime = time.time() dt = newTime - currTime currTime = newTime sensorfusion.updateRollPitchYaw(imu.AccelVals[0], imu.AccelVals[1], imu.AccelVals[2], imu.GyroVals[0], \