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, 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
from imusensor.MPU9250 import MPU9250 from imusensor.filters import madgwick from imusensor.filters import kalman # 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
from imusensor.MPU9250 import MPU9250 from imusensor.filters import kalman address = 0x68 bus = smbus.SMBus(1) imu = MPU9250.MPU9250(bus, address) imu.begin() # imu.caliberateAccelerometer() # print ("Acceleration calib successful") # imu.caliberateMag() # print ("Mag calib successful") # or load your calibration file # imu.loadCalibDataFromFile("/home/pi/calib_real_bolder.json") sensorfusion = kalman.Kalman() imu.readSensor() imu.computeOrientation() sensorfusion.roll = imu.roll sensorfusion.pitch = imu.pitch sensorfusion.yaw = imu.yaw count = 0 currTime = time.time() while True: imu.readSensor() imu.computeOrientation() newTime = time.time() dt = newTime - currTime currTime = newTime