forked from amey-waghmare/Twin-Rotor-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.py
More file actions
59 lines (48 loc) · 1.85 KB
/
testing.py
File metadata and controls
59 lines (48 loc) · 1.85 KB
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
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import numpy as np
import time
import board
import serial
import adafruit_bno055
import busio
#uart = busio.UART(board.TX, board.RX)
#sensor = adafruit_bno055.BNO055_UART(uart)
i2c = board.I2C()
sensor = adafruit_bno055.BNO055_I2C(i2c)
# If you are going to use UART uncomment these lines
#uart = serial.Serial("/dev/ttyS0")
#sensor = adafruit_bno055.BNO055_UART(uart)
last_val = 0xFFFF
def temperature():
global last_val # pylint: disable=global-statement
result = sensor.temperature
if abs(result - last_val) == 128:
result = sensor.temperature
if abs(result - last_val) == 128:
return 0b00111111 & result
last_val = result
return result
while True:
#print("Temperature: {} degrees C".format(sensor.temperature))
"""
print(
"Temperature: {} degrees C".format(temperature())
) # Uncomment if using a Raspberry Pi
"""
#print("Accelerometer (m/s^2): {}".format(sensor.acceleration))
#print("Magnetometer (microteslas): {}".format(sensor.magnetic))
#print("Gyroscope (rad/sec): {}".format(sensor.gyro))
#print("Euler angle: {}".format(sensor.euler), "Calibration Status: {}".format(sensor.calibration_status))
#print("Quaternion: {}".format(sensor.quaternion))
#print("Linear acceleration (m/s^2): {}".format(sensor.linear_acceleration))
#print("Gravity (m/s^2): {}".format(sensor.gravity))
#print()
yaw, roll, pitch = sensor.euler
if yaw != None or roll != None or pitch != None:
pitch = np.radians(pitch)
roll = np.radians(roll)
yaw = np.radians(yaw)
print("Pitch: {:.2f}\tRoll: {:.2f}\tYaw: {:.2f}\tCalibration: {}".format(pitch, roll, yaw, sensor.calibration_status))
#print("Pitch: {:.2f}".format(pitch))
#time.sleep(0.1)