-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathconfig.py
More file actions
64 lines (56 loc) · 2.43 KB
/
config.py
File metadata and controls
64 lines (56 loc) · 2.43 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
60
61
62
63
64
import datetime
import sys
import struct
import json
# global constants
IP_ADDRESS = "" # dafault IP
PORT = 35001 # new port used in PSAS server-client example
#PORT = 36000 # old port used in PSAS server-client example
PACKET_SIZE = 4096 # maximum packet size to receive
TIMEOUT = 0.1 # backend to frontend update frequency
# debugging
BAD_DEBUG_ONLY = False # Show only debug information for bad cases
DEBUG = (sys.argv[1:] == ['-d'])
PRINT_CHAR_FOR_ARRIVING_PACKETS = False
PRINT_CHAR_FOR_BACK_TO_FRONT_UPDATE = False
# packet header
SEQUENCE_LENGTH = 4 # packet sequence field length in bytes
# message header format
FIELD_ID_LENGTH = 4 # message field ID (message type ID) length in bytes
TIMESTAMP_LENGTH = 6 # message timestamp length in bytes
DATA_LENGTH_LENGTH = 2 # message data-length length in bytes
HEADER_LENGTH = FIELD_ID_LENGTH + TIMESTAMP_LENGTH + DATA_LENGTH_LENGTH
FIELD_ID_OFFSET = 0
TIMESTAMP_OFFSET = FIELD_ID_OFFSET + FIELD_ID_LENGTH
DATA_LENGTH_OFFSET = TIMESTAMP_OFFSET + TIMESTAMP_LENGTH
DATA_OFFSET = DATA_LENGTH_OFFSET + DATA_LENGTH_LENGTH
# log filename format
PACKET_LOG_FILENAME = datetime.datetime.now().strftime(
"log/log_%Y.%m.%d_%H-%M-%S")
VALIDATION_LOG_FILENAME = datetime.datetime.now().strftime(
"log/data_validation_%Y.%m.%d_%H-%M-%S.txt")
MESSAGES_LOG_FILENAME = datetime.datetime.now().strftime(
"log/messages_%Y.%m.%d_%H-%M-%S.json")
# units conversion
MILLI = 0.001
MICRO = 0.000001
NANO = 0.000000001
GFORCE_EQ_X_MPS2 = 9.80665 # g-force equals 9.81 meters per second squared
GAUSS_EQ_X_TESLA = 0.0001 # gauss equals 0.0001 teslas
KELVIN_MINUS_CELSIUS = 273.0 # (K = C + 273) equivalent to (K - C = 273)
# message format
delimiter = struct.Struct('!4sLH')
gps1_struct = struct.Struct("<BBH 3d 5f HH"), # GPS BIN1
# more details about GPS format here:
# http://www.hemispheregps.com/gpsreference/Bin1.htm
message_type = {
'SEQN': delimiter, # packet log separator
'GPS\x01': struct.Struct("<BBH 3d 5f HH"),
'GPS1': struct.Struct("<BBH 3d 5f HH"),
'ADIS': struct.Struct("<12h"), # ADIS16405 IMU
'MPU9': struct.Struct(">7H"), # MPU9150 IMU
'MPL3': struct.Struct(">2L"), # MPL3115A2 Pressure Sensor
'ROLL': struct.Struct("<HB") # ROLL computer data
}
# this line must be in the end of this file
import debug