-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster-only-mode.py
75 lines (63 loc) · 2.82 KB
/
master-only-mode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#####################################################################
# Author: Jeferson Menegazzo #
# Year: 2020 #
# License: MIT #
#####################################################################
import sys
sys.path.append("")
import time
from mpu9250_jmdev.registers import *
from mpu9250_jmdev.mpu_9250 import MPU9250
##################################################
# Create #
##################################################
mpu = MPU9250(
address_ak=AK8963_ADDRESS,
address_mpu_master=MPU9050_ADDRESS_68, # In 0x68 Address
address_mpu_slave=None,
bus=1,
gfs=GFS_1000,
afs=AFS_8G,
mfs=AK8963_BIT_16,
mode=AK8963_MODE_C100HZ)
##################################################
# Configure #
##################################################
mpu.reset() # Reset sensors
mpu.configure() # Apply the settings to the registers.
##################################################
# Calibrate #
##################################################
mpu.calibrate() # Calibrate sensors
mpu.configure() # The calibration function resets the sensors, so you need to reconfigure them
##################################################
# Get Calibration #
##################################################
abias = mpu.abias # Get the master accelerometer biases
gbias = mpu.gbias # Get the master gyroscope biases
magScale = mpu.magScale # Get magnetometer soft iron distortion
mbias = mpu.mbias # Get magnetometer hard iron distortion
print("|.....MPU9250 in 0x68 Biases.....|")
print("Accelerometer", abias)
print("Gyroscope", gbias)
print("Magnetometer SID", magScale)
print("Magnetometer HID", mbias)
print("\n")
##################################################
# Set Calibration #
##################################################
# mpu.abias = [-0.08004239710365854, 0.458740234375, 0.2116996951219512]
# mpu.gbias = [0.8958025676448171, 0.45292551924542684, 0.866773651867378]
# mpu.magScale = [1.0104166666666667, 0.9797979797979799, 1.0104166666666667]
# mpu.mbias = [2.6989010989010986, 2.7832417582417586, 2.6989010989010986]
##################################################
# Show Values #
##################################################
while True:
print("|.....MPU9250 in 0x68 Address.....|")
print("Accelerometer", mpu.readAccelerometerMaster())
print("Gyroscope", mpu.readGyroscopeMaster())
print("Magnetometer", mpu.readMagnetometerMaster())
print("Temperature", mpu.readTemperatureMaster())
print("\n")
time.sleep(1)