-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnxp_imu_test.py
executable file
·69 lines (55 loc) · 1.84 KB
/
nxp_imu_test.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020-2021 by Murray Altheim. All rights reserved. This file is part
# of the Robot Operating System project, released under the MIT License. Please
# see the LICENSE file included as part of this package.
#
# author: Murray Altheim
# created: 2020-08-23
# modified: 2020-08-31
#
# Beginnings of a possible replacement for the BNO055 as the source of
# heading information for the Compass class, instead using the Adafruit
# Precision NXP 9-DOF Breakout Board - FXOS8700 + FXAS21002, see:
#
# https://www.adafruit.com/product/3463
#
# This is very preliminary work and currently non-functional.
#
from colorama import init, Fore, Style
init()
from lib.config_loader import ConfigLoader
from lib.logger import Level, Logger
from lib.queue import MessageQueue
from lib.message_factory import MessageFactory
#rom lib.indicator import Indicator
from lib.nxp9dof import NXP9DoF
from lib.nxp import NXP
from lib.rate import Rate
# ..............................................................................
def main():
try:
# read YAML configuration
_loader = ConfigLoader(Level.INFO)
filename = 'config.yaml'
_config = _loader.configure(filename)
_message_factory = MessageFactory(Level.INFO)
_queue = MessageQueue(_message_factory, Level.INFO)
_rate = Rate(5) # 20Hz
_nxp9dof = NXP9DoF(_config, _queue, Level.INFO)
_nxp = NXP(_nxp9dof, Level.INFO)
# _nxp.enable()
# _nxp9dof.enable()
_nxp.ahrs2(True)
while True:
# _nxp.heading(20)
# _nxp.ahrs(10)
# _nxp.imu(10)
_nxp.ahrs2(False)
_rate.wait()
except KeyboardInterrupt:
print(Fore.RED + 'Ctrl-C caught; exiting...' + Style.RESET_ALL)
if __name__ == "__main__":
main()
# EOF