-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbrake.py
executable file
·58 lines (48 loc) · 1.66 KB
/
brake.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
#!/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.
#
# created: 2020-05-17
# modified: 2021-01-29
#
import sys
from lib.config_loader import ConfigLoader
from lib.logger import Level, Logger
from lib.clock import Clock
from lib.message_bus import MessageBus
from lib.message_factory import MessageFactory
from lib.motor_configurer import MotorConfigurer
from lib.motors import Motors
_motors = None
# main .........................................................................
def main(argv):
try:
_log = Logger('brake', Level.INFO)
_log.info('configuring...')
# read YAML configuration
_loader = ConfigLoader(Level.WARN)
_config = _loader.configure()
_log.info('creating message factory...')
_message_factory = MessageFactory(Level.INFO)
_log.info('creating message bus...')
_message_bus = MessageBus(Level.INFO)
_log.info('creating clock...')
_clock = Clock(_config, _message_bus, _message_factory, Level.WARN)
_motor_configurer = MotorConfigurer(_config, _clock, Level.INFO)
_motors = _motor_configurer.get_motors()
_log.info('braking...')
_motors.brake()
_log.info('done.')
except KeyboardInterrupt:
_log.error('Ctrl-C caught in main: exiting...')
finally:
if _motors:
_motors.stop()
_motors.close()
_log.info('complete.')
if __name__ == '__main__':
main(sys.argv[1:])
#EOF