|
| | sensor = adafruit_icm20x.ICM20948(i2c) |
| bool | running = True |
| | accel = self.sensor.acceleration |
| | gyro = self.sensor.gyro |
| | magnetic = self.sensor.magnetic |
| bool | new_data = False |
| | thread = threading.Thread(target=self.update_loop, daemon=True) |
Definition at line 15 of file imu.py.
◆ __init__()
Definition at line 16 of file imu.py.
16 def __init__(self):
17
18 i2c = board.I2C()
19 self.sensor = adafruit_icm20x.ICM20948(i2c)
20
21 self.running = True
22
23 self.accel = self.sensor.acceleration
24 self.gyro = self.sensor.gyro
25 self.magnetic = self.sensor.magnetic
26
27
28 self.new_data = False
29
30
31 self.thread = threading.Thread(target=self.update_loop, daemon=True)
32 self.thread.start()
33
◆ __str__()
Definition at line 34 of file imu.py.
34 def __str__(self):
35 return (
36 f"Acceleration: X:{self.accel[0]:.3f}, Y:{self.accel[1]:.3f}, Z:{self.accel[2]:.3f} m/s^2\n"
37 f"Gyroscope: X:{self.gyro[0]:.3f}, Y:{self.gyro[1]:.3f}, Z:{self.gyro[2]:.3f} rads/s\n"
38 f"Magnetometer: X:{self.magnetic[0]:.3f}, Y:{self.magnetic[1]:.3f}, Z:{self.magnetic[2]:.3f} uT\n"
39 )
40
◆ get_accel()
| imu.IMU.get_accel |
( |
| self | ) |
|
Definition at line 50 of file imu.py.
50 def get_accel(self):
51 return self.accel
52
◆ get_gyro()
Definition at line 53 of file imu.py.
53 def get_gyro(self):
54 return self.gyro
55
◆ get_magn()
Definition at line 56 of file imu.py.
56 def get_magn(self):
57 self.new_data = False
58 return self.magnetic
59
◆ stop()
Definition at line 60 of file imu.py.
60 def stop(self):
61 self.running = False
62 self.thread.join()
◆ update_loop()
| imu.IMU.update_loop |
( |
| self | ) |
|
Definition at line 41 of file imu.py.
41 def update_loop(self):
42
43 while self.running:
44 self.accel = self.sensor.acceleration
45 self.gyro = self.sensor.gyro
46 self.magnetic = self.sensor.magnetic
47 self.new_data = True
48
49
◆ accel
| imu.IMU.accel = self.sensor.acceleration |
◆ gyro
| imu.IMU.gyro = self.sensor.gyro |
◆ magnetic
| imu.IMU.magnetic = self.sensor.magnetic |
◆ new_data
| bool imu.IMU.new_data = False |
◆ running
| bool imu.IMU.running = True |
◆ sensor
| imu.IMU.sensor = adafruit_icm20x.ICM20948(i2c) |
◆ thread
| imu.IMU.thread = threading.Thread(target=self.update_loop, daemon=True) |
The documentation for this class was generated from the following file: