-
Notifications
You must be signed in to change notification settings - Fork 2
/
phm_cui.py
93 lines (76 loc) · 3.5 KB
/
phm_cui.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
"""
@name phm_main.py
@info the main entry to the application (runnable execution)
@organization: Laval University
@professor Professor Xavier Maldague
@author Parham Nooralishahi
@email parham.nooralishahi.1@ulaval.ca
@equipment FLIR A700, Intel RealSense D435i, DJI M600, DJI Manifold 2
"""
from consolemenu import ConsoleMenu, SelectionMenu
from consolemenu.items import FunctionItem, SubmenuItem, CommandItem
import logging
import sys
import rospy
import numpy as np
import message_filters
from std_msgs.msg import String
from phm import LeManchotDC
from sensor_msgs.msg import Image
from multiprocessing import cpu_count
def callback_sync(*arg):
dcobj = arg[-1]
data = arg[:-1]
packet = dict()
for index in range(len(data)) :
name = dcobj.collectors_name[index]
packet[name] = data[index]
dcobj.record(packet)
def shutdown():
logging.info('Node is shutting down ...')
def main_func(argv):
try:
logging.info('System is started!')
logging.info(f'starting computations on {cpu_count()} cores')
rospy.init_node('lemanchot-dc', argv=argv, anonymous=True)
rospy.on_shutdown(shutdown)
dcobj = LeManchotDC.get_instance(config_file='./config_combo.json')
# dcobj = LeManchotDC.get_instance(config_file='./config.json')
# ts = message_filters.ApproximateTimeSynchronizer(dcobj.subscribers, dcobj.buffer_size, 10)
# ts.registerCallback(callback_sync, dcobj)
# Create the menu
title = 'LeManchot-DC'
subtitle = '''
=============================================================
== LeManchot-DC System : Multi-Modal Data Acquisition ==
== Laval University ==
== @Supervisor : Professor Xavier Maldague ==
== @Researcher : Parham Nooralishahi ==
== @year @ 2021 ==
=============================================================
'''
prologue = 'You can select the following options for controling DC process'
epilogue = '@ULAVAL'
menu = ConsoleMenu(title, subtitle=subtitle, prologue_text=prologue, epilogue_text=epilogue)
# menu.clear_screen()
menu.append_item(FunctionItem("Start recording", dcobj.start, menu=menu))
menu.append_item(FunctionItem("Start/Resume recording", dcobj.resume, menu=menu))
menu.append_item(FunctionItem("Pause recording", dcobj.pause, menu=menu))
menu.append_item(FunctionItem("Stop recording", dcobj.stop, menu=menu))
# Finally, we call show to show the menu and allow the user to interact
menu.show()
logging.info('System is terminated!')
except rospy.ROSInitException as exp:
logging.error('lemachot-dc system is failed!')
logging.exception(exp)
print(exp)
if __name__ == '__main__':
print('=============================================================')
print('== LeManchot-DC System : Multi-Modal Data Acquisition ==')
print('== Laval University ==')
print('== @Supervisor : Professor Xavier Maldague ==')
print('== @Researcher : Parham Nooralishahi ==')
print('== @year @ 2021 ==')
print('=============================================================')
main_func (sys.argv)