autoverse-cli 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
avrs/requests/can.py DELETED
@@ -1,131 +0,0 @@
1
- from avrs.requests.request import AvrsApiRequest
2
- import can
3
- import cantools
4
- import time
5
- import os
6
- import pandas as pd
7
- import datetime
8
-
9
- # class Can():
10
- # def __init__(self, parser, cfg):
11
- # psr = parser.add_parser('can', help='Peforms a variety of CAN commands')
12
- # sps = psr.add_subparsers(required= True, help='sub-command of NPC')
13
- # SendCan(sps, dbc)
14
- # #TestCanRates(sps, cfg)
15
- # LogCan(sps, dbc)
16
-
17
-
18
- # class SendCan(AvrsApiRequest):
19
- # def __init__(self, parser, dbc):
20
- # psr = parser.add_parser('send', help='sends CAN data for given duration (seconds) with given throttle and steer percent values')
21
- # psr.add_argument('duration', type=float, help='Length of time to send Can data')
22
- # psr.add_argument('hertz', type=float, help = 'Frequency of Can Messages')
23
- # psr.add_argument('throttle', type=float, help='throttle (in percent)')
24
- # psr.add_argument('steer', type=float, help='steer (in percent)')
25
- # self.dbc = dbc
26
- # psr.set_defaults(func=self.send_can_values)
27
-
28
-
29
- # def send_can_values(self, args):
30
- # with can.interface.Bus('vcan0', bustype='socketcan') as bus:
31
- # message_1 = self.dbc.get_message_by_name("HL_Msg_01")
32
- # message_2 = self.dbc.get_message_by_name("HL_Msg_02")
33
- # signals_1 = {
34
- # "HL_TargetThrottle": args.throttle,
35
- # "HL_TargetGear": 1,
36
- # "HL_TargetPressure_RR": 0,
37
- # "HL_TargetPressure_RL": 0,
38
- # "HL_TargetPressure_FR": 0,
39
- # "HL_TargetPressure_FL": 0,
40
- # "HL_Alive_01": 0,
41
- # }
42
-
43
- # signals_2 = {
44
- # "HL_Alive_02": 0,
45
- # "HL_PSA_Profile_Vel_rad_s": 0,
46
- # "HL_PSA_Profile_Dec_rad_s2": 0,
47
- # "HL_PSA_Profile_Acc_rad_s2": 0,
48
- # "HL_TargetPSAControl": args.steer,
49
- # "HL_PSA_ModeOfOperation": 0,
50
- # }
51
-
52
- # start_time = time.time()
53
-
54
- # print('sending can data...')
55
- # while time.time() - start_time < args.duration:
56
- # data = message_1.encode(signals_1)
57
- # msg = can.Message(arbitration_id=message_1.frame_id, data=data, is_extended_id=False)
58
- # bus.send(msg)
59
-
60
- # data = message_2.encode(signals_2)
61
- # msg = can.Message(arbitration_id=message_2.frame_id, data=data, is_extended_id=False)
62
- # bus.send(msg)
63
- # time.sleep(args.hertz)
64
- # print('done')
65
-
66
-
67
- # # class TestCanRates(AvrsApiRequest):
68
- # # def __init__(self, parser, cfg):
69
- # # AvrsApiRequest.__init__(self, parser, cfg, 'TestCanRates')
70
- # # psr = parser.add_parser('test-rates', help='get average can message rates over given duration for all can messages on vcan0')
71
- # # psr.add_argument('duration', type=float, help='Length of time to test Can rates')
72
- # # psr.set_defaults(func=self.send_request)
73
-
74
-
75
- # # def get_request_body(self, args):
76
- # # return {
77
- # # 'Duration': args.duration,
78
- # # }
79
-
80
- # class LogCan(AvrsApiRequest):
81
- # def __init__(self, parser, dbc):
82
- # psr = parser.add_parser('log', help='logs csv CAN data for given duration (seconds) to the given absolute file path. Will append numbers to colliding file names')
83
- # psr.add_argument('duration', type=float, help='length of time to log Can data')
84
- # psr.add_argument('path', help='absoulte file path')
85
- # psr.set_defaults(func=self.log_can)
86
- # self.dbc = dbc
87
-
88
- # def log_can(self, args):
89
- # start_time = time.time()
90
-
91
- # # Check and remove the existing 'messages.csv' file
92
- # file_no = 1
93
- # tmp_file_path = args.path
94
- # print(tmp_file_path)
95
- # while os.path.exists(tmp_file_path):
96
- # tmp_file_path = args.path.replace('.csv', '{}.csv'.format(file_no))
97
- # file_no += 1
98
- # args.path = tmp_file_path
99
-
100
- # messages_list = []
101
- # databases = [self.dbc]
102
- # print('logging can data...')
103
-
104
- # with can.interface.Bus('vcan0', bustype='socketcan') as bus:
105
- # while time.time() - start_time < args.duration:
106
- # message = bus.recv()
107
- # # If a message was received
108
- # if message is not None:
109
- # for db in databases:
110
- # decoded = self.decode_message(message)
111
- # if decoded:
112
- # messages_list.append(decoded)
113
- # break
114
- # df = pd.DataFrame(messages_list)
115
- # df.to_csv(args.path, index=False)
116
- # print('done')
117
-
118
-
119
- # def decode_message(self, message):
120
- # try:
121
- # decoded_message = self.dbc.decode_message(message.arbitration_id, message.data)
122
- # message_name = self.dbc.get_message_by_frame_id(message.arbitration_id).name
123
- # timestamp = datetime.datetime.now().isoformat()
124
- # return {'timestamp': timestamp, 'name': message_name, 'data': decoded_message}
125
- # except KeyError:
126
- # # Return None if decoding fails
127
- # return None
128
-
129
-
130
-
131
-
avrs/requests/input.py DELETED
@@ -1,46 +0,0 @@
1
- from avrs.requests.request import AvrsApiRequest
2
-
3
- class InputRequest(AvrsApiRequest):
4
- def __init__(self, parser, cfg):
5
- psr = parser.add_parser('user-input', help='Commands related to controlling the vehicles with controllers')
6
- sps = psr.add_subparsers(required= True, help='sub-command of Input')
7
- EnableInput(sps, cfg)
8
- DisableInput(sps, cfg)
9
- ChangeInput(sps, cfg)
10
-
11
- class EnableInput(AvrsApiRequest):
12
- def __init__(self, parser, cfg):
13
- AvrsApiRequest.__init__(self, parser, cfg, 'EnableInput', 'Ego')
14
- psr = parser.add_parser('enable', help='Enable user input on car')
15
- psr.add_argument('controller', help='type of way to control the actor', nargs = 1,
16
- choices=('keyboard', 'xbox', 'wheel', 'can'))
17
- psr.set_defaults(func=self.send_request)
18
-
19
- def get_request_body(self, args):
20
- return {
21
- 'Controller': args.controller
22
- }
23
-
24
- class DisableInput(AvrsApiRequest):
25
- def __init__(self, parser, cfg):
26
- AvrsApiRequest.__init__(self, parser, cfg, 'DisableInput', 'Ego')
27
- psr = parser.add_parser('disable', help='disable user input on car')
28
- psr.set_defaults(func=self.send_request)
29
-
30
- def get_request_body(self, args):
31
- return {
32
- }
33
-
34
- class ChangeInput(AvrsApiRequest):
35
- def __init__(self, parser, cfg):
36
- AvrsApiRequest.__init__(self, parser, cfg, 'ChangeInput', 'Ego')
37
- psr = parser.add_parser('change', help='change the input type if input is already enabled')
38
- psr.add_argument('controller', help='type of way to control the actor', nargs = 1,
39
- choices=('keyboard', 'xbox', 'wheel'))
40
- psr.set_defaults(func=self.send_request)
41
-
42
- def get_request_body(self, args):
43
- return {
44
- 'Controller': args.controller
45
- }
46
-