autoverse-cli 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {autoverse_cli-0.4.0.dist-info → autoverse_cli-0.5.0.dist-info}/METADATA +3 -1
- autoverse_cli-0.5.0.dist-info/RECORD +35 -0
- {autoverse_cli-0.4.0.dist-info → autoverse_cli-0.5.0.dist-info}/WHEEL +1 -1
- avrs/app_version.py +1 -1
- avrs/avrs.py +25 -8
- avrs/can_tool.py +192 -0
- avrs/can_tool_util.py +190 -0
- avrs/cfg.py +53 -1
- avrs/launcher.py +7 -1
- avrs/launcher_util.py +3 -0
- avrs/requests/demo.py +3 -7
- avrs/requests/{edit_environment.py → environment.py} +15 -3
- avrs/requests/fault_injection.py +155 -0
- avrs/requests/list_sim_objects.py +26 -0
- avrs/requests/request.py +4 -1
- avrs/requests/scenario_control.py +43 -0
- avrs/requests/vehicle_input.py +21 -0
- avrs/requests/vehicle_replay.py +191 -0
- avrs/simconfig.py +61 -0
- avrs/simconfig_util.py +70 -0
- autoverse_cli-0.4.0.dist-info/RECORD +0 -28
- avrs/requests/can.py +0 -131
- avrs/requests/input.py +0 -46
- {autoverse_cli-0.4.0.dist-info → autoverse_cli-0.5.0.dist-info}/LICENSE +0 -0
- {autoverse_cli-0.4.0.dist-info → autoverse_cli-0.5.0.dist-info}/entry_points.txt +0 -0
- {autoverse_cli-0.4.0.dist-info → autoverse_cli-0.5.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
from avrs.requests.request import AvrsApiRequest
|
2
|
+
from argparse import RawDescriptionHelpFormatter
|
3
|
+
from argparse import RawTextHelpFormatter
|
4
|
+
|
5
|
+
class AvrsFaultInjectionRequests():
|
6
|
+
def __init__(self, parser, cfg):
|
7
|
+
psr = parser.add_parser('inject-fault', help='utilty to inject faults into components (sensors, actuators, etc)')
|
8
|
+
sps = psr.add_subparsers(required= True, help='sub-command inject-fault')
|
9
|
+
AvrsGnssFaultRequest(sps, cfg)
|
10
|
+
AvrsLidarFaultRequest(sps, cfg)
|
11
|
+
AvrsImuFaultRequest(sps, cfg)
|
12
|
+
|
13
|
+
def add_base_injection_args(psr):
|
14
|
+
|
15
|
+
psr.add_argument(
|
16
|
+
'--target',
|
17
|
+
default='ego',
|
18
|
+
help='the simulated object to apply the fault to')
|
19
|
+
|
20
|
+
psr.add_argument(
|
21
|
+
'--duration',
|
22
|
+
type=float,
|
23
|
+
default=1.0,
|
24
|
+
help='how long to apply the fault (0.0 is infinite)')
|
25
|
+
|
26
|
+
psr.add_argument(
|
27
|
+
'--dropout',
|
28
|
+
action='store_true',
|
29
|
+
help='if specified, will apply a complete dropout fault')
|
30
|
+
|
31
|
+
psr.add_argument(
|
32
|
+
'--freeze',
|
33
|
+
action='store_true',
|
34
|
+
help='if specified, will freeze the data (values will not change)')
|
35
|
+
|
36
|
+
class AvrsGnssFaultRequest(AvrsApiRequest):
|
37
|
+
def __init__(self, parser, cfg):
|
38
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'FaultInjection', '')
|
39
|
+
|
40
|
+
psr = parser.add_parser(
|
41
|
+
'gnss',
|
42
|
+
help='inject a gnss fault',
|
43
|
+
formatter_class=RawTextHelpFormatter)
|
44
|
+
|
45
|
+
psr.add_argument(
|
46
|
+
'--horizontal-bias',
|
47
|
+
type=float,
|
48
|
+
default=0.0,
|
49
|
+
help='horizontal bias to apply to the sensor as a fault')
|
50
|
+
|
51
|
+
psr.add_argument(
|
52
|
+
'--vertical-bias',
|
53
|
+
type=float,
|
54
|
+
default=0.0,
|
55
|
+
help='vertical bias to apply to the sensor as a fault')
|
56
|
+
|
57
|
+
psr.add_argument(
|
58
|
+
'--horizontal-stdev',
|
59
|
+
type=float,
|
60
|
+
default=0.0,
|
61
|
+
help='horizontal standard deviation to apply to the sensor')
|
62
|
+
|
63
|
+
psr.add_argument(
|
64
|
+
'--vertical-stdev',
|
65
|
+
type=float,
|
66
|
+
default=0.0,
|
67
|
+
help='vertical standard deviation to apply to the sensor')
|
68
|
+
|
69
|
+
add_base_injection_args(psr)
|
70
|
+
psr.set_defaults(func=self.send_request)
|
71
|
+
|
72
|
+
def get_request_body(self, args):
|
73
|
+
self.target_object_id = args.target
|
74
|
+
self.verbose = args.verbose
|
75
|
+
return {
|
76
|
+
'faultType': 'GnssFault',
|
77
|
+
'duration': args.duration,
|
78
|
+
'bIsDropout': args.dropout,
|
79
|
+
'bIsFreeze': args.freeze,
|
80
|
+
'JsonBody': {
|
81
|
+
'verticalBias': args.vertical_bias,
|
82
|
+
'verticalStdev': args.vertical_stdev,
|
83
|
+
'horizontalBias': args.horizontal_bias,
|
84
|
+
'horizontalStdev': args.horizontal_stdev
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
class AvrsImuFaultRequest(AvrsApiRequest):
|
89
|
+
def __init__(self, parser, cfg):
|
90
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'FaultInjection', '')
|
91
|
+
|
92
|
+
psr = parser.add_parser(
|
93
|
+
'imu',
|
94
|
+
help='inject an imu fault',
|
95
|
+
formatter_class=RawTextHelpFormatter)
|
96
|
+
|
97
|
+
psr.add_argument(
|
98
|
+
'--bias',
|
99
|
+
type=float,
|
100
|
+
default=0.0,
|
101
|
+
help='horizontal bias to apply to the sensor as a fault')
|
102
|
+
|
103
|
+
psr.add_argument(
|
104
|
+
'--stdev',
|
105
|
+
type=float,
|
106
|
+
default=0.0,
|
107
|
+
help='horizontal standard deviation to apply to the sensor')
|
108
|
+
|
109
|
+
add_base_injection_args(psr)
|
110
|
+
psr.set_defaults(func=self.send_request)
|
111
|
+
|
112
|
+
def get_request_body(self, args):
|
113
|
+
self.target_object_id = args.target
|
114
|
+
self.verbose = args.verbose
|
115
|
+
return {
|
116
|
+
'faultType': 'ImuFault',
|
117
|
+
'duration': args.duration,
|
118
|
+
'bIsDropout': args.dropout,
|
119
|
+
'bIsFreeze': args.freeze,
|
120
|
+
'JsonBody': {
|
121
|
+
'bias': args.bias,
|
122
|
+
'stdev': args.stdev
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
class AvrsLidarFaultRequest(AvrsApiRequest):
|
127
|
+
def __init__(self, parser, cfg):
|
128
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'FaultInjection', '')
|
129
|
+
|
130
|
+
psr = parser.add_parser(
|
131
|
+
'lidar',
|
132
|
+
help='inject a lidar fault',
|
133
|
+
formatter_class=RawTextHelpFormatter)
|
134
|
+
|
135
|
+
psr.add_argument(
|
136
|
+
'--point-density-reduction',
|
137
|
+
type=float,
|
138
|
+
default=0.5,
|
139
|
+
help='the percent of point density reduction, where 1.0 drops all points')
|
140
|
+
|
141
|
+
add_base_injection_args(psr)
|
142
|
+
psr.set_defaults(func=self.send_request)
|
143
|
+
|
144
|
+
def get_request_body(self, args):
|
145
|
+
self.target_object_id = args.target
|
146
|
+
self.verbose = args.verbose
|
147
|
+
return {
|
148
|
+
'faultType': 'LidarFault',
|
149
|
+
'duration': args.duration,
|
150
|
+
'bIsDropout': args.dropout,
|
151
|
+
'bIsFreeze': args.freeze,
|
152
|
+
'JsonBody': {
|
153
|
+
'pointDensityReduction': args.point_density_reduction
|
154
|
+
}
|
155
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
from avrs.requests.request import AvrsApiRequest
|
2
|
+
|
3
|
+
class AvrsListSimObjectsRequest(AvrsApiRequest):
|
4
|
+
def __init__(self, parser, cfg):
|
5
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'ListSimObjects', 0)
|
6
|
+
psr = parser.add_parser('list-sim-objects', help='list all the sim objects that currently exist in the simulator')
|
7
|
+
psr.add_argument(
|
8
|
+
'-v',
|
9
|
+
action='store_true',
|
10
|
+
help='request verbose output')
|
11
|
+
psr.add_argument(
|
12
|
+
'--components',
|
13
|
+
action='store_true',
|
14
|
+
help='also print information about the object components')
|
15
|
+
psr.add_argument(
|
16
|
+
'--isolate',
|
17
|
+
default='',
|
18
|
+
help='indicate a specific object of interest')
|
19
|
+
psr.set_defaults(func=self.send_request)
|
20
|
+
|
21
|
+
def get_request_body(self, args):
|
22
|
+
return {
|
23
|
+
"bVerbose": args.v,
|
24
|
+
'bListComponents': args.components,
|
25
|
+
'isolate': args.isolate
|
26
|
+
}
|
avrs/requests/request.py
CHANGED
@@ -11,12 +11,15 @@ class AvrsApiRequest:
|
|
11
11
|
def __init__(self, parser, cfg, request_type, target_id):
|
12
12
|
self.target_object_id = target_id
|
13
13
|
self.request_type = request_type
|
14
|
+
self.verbose = False
|
14
15
|
|
15
16
|
def get_request(self, args):
|
17
|
+
body = json.dumps(self.get_request_body(args))
|
16
18
|
return {
|
17
19
|
'TargetObjectId': self.target_object_id,
|
18
20
|
'RequestType': self.request_type,
|
19
|
-
'
|
21
|
+
'bVerboseResponse': self.verbose,
|
22
|
+
'RequestBody': body
|
20
23
|
}
|
21
24
|
|
22
25
|
def get_request_body(self, args):
|
@@ -0,0 +1,43 @@
|
|
1
|
+
from avrs.requests.request import AvrsApiRequest
|
2
|
+
from argparse import RawDescriptionHelpFormatter
|
3
|
+
from argparse import RawTextHelpFormatter
|
4
|
+
|
5
|
+
class AvrsScenarioRequests():
|
6
|
+
def __init__(self, parser, cfg):
|
7
|
+
psr = parser.add_parser('scenario', help='commands related to scenarios in the simulator')
|
8
|
+
sps = psr.add_subparsers(required= True, help='sub-command scenario')
|
9
|
+
StartScenarioRequest(sps, cfg)
|
10
|
+
StopScenarioRequest(sps, cfg)
|
11
|
+
|
12
|
+
class StartScenarioRequest(AvrsApiRequest):
|
13
|
+
def __init__(self, parser, cfg):
|
14
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'ScenarioControl', '')
|
15
|
+
psr = parser.add_parser(
|
16
|
+
'start', help='start a scenario', formatter_class=RawTextHelpFormatter)
|
17
|
+
|
18
|
+
psr.add_argument(
|
19
|
+
'scenario_name',
|
20
|
+
default='',
|
21
|
+
help='the name of the scenario to start')
|
22
|
+
|
23
|
+
psr.set_defaults(func=self.send_request)
|
24
|
+
|
25
|
+
|
26
|
+
def get_request_body(self, args):
|
27
|
+
return {
|
28
|
+
'scenarioName': args.scenario_name,
|
29
|
+
'action': 'start'
|
30
|
+
}
|
31
|
+
|
32
|
+
class StopScenarioRequest(AvrsApiRequest):
|
33
|
+
def __init__(self, parser, cfg):
|
34
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'ScenarioControl', '')
|
35
|
+
psr = parser.add_parser(
|
36
|
+
'stop', help='stop any active scenarios', formatter_class=RawTextHelpFormatter)
|
37
|
+
|
38
|
+
psr.set_defaults(func=self.send_request)
|
39
|
+
|
40
|
+
def get_request_body(self, args):
|
41
|
+
return {
|
42
|
+
'action': 'stop'
|
43
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
from avrs.requests.request import AvrsApiRequest
|
2
|
+
|
3
|
+
class AvrsConfigureVehicleInputRequest(AvrsApiRequest):
|
4
|
+
def __init__(self, parser, cfg):
|
5
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'ConfigureVehicleInput', 'Ego')
|
6
|
+
psr = parser.add_parser(
|
7
|
+
'configure-vehicle-input',
|
8
|
+
help='Allows different input modes to be set for a vehicle')
|
9
|
+
|
10
|
+
psr.add_argument(
|
11
|
+
'input_mode',
|
12
|
+
default='None',
|
13
|
+
choices=['None', 'Keyboard', 'WheelAndPedals', 'CAN'],
|
14
|
+
help='the type of input mode to set')
|
15
|
+
|
16
|
+
psr.set_defaults(func=self.send_request)
|
17
|
+
|
18
|
+
def get_request_body(self, args):
|
19
|
+
return {
|
20
|
+
"InputMode": args.input_mode
|
21
|
+
}
|
@@ -0,0 +1,191 @@
|
|
1
|
+
from avrs.requests.request import AvrsApiRequest
|
2
|
+
from argparse import RawDescriptionHelpFormatter
|
3
|
+
from argparse import RawTextHelpFormatter
|
4
|
+
|
5
|
+
class AvrsVehicleReplayRequests():
|
6
|
+
def __init__(self, parser, cfg):
|
7
|
+
psr = parser.add_parser('vehicle-replay', help='utilty for recording and replaying vehicle motion')
|
8
|
+
sps = psr.add_subparsers(required= True, help='sub-command vehicle-replay')
|
9
|
+
SpawnReplayVehicle(sps, cfg)
|
10
|
+
StartVehicleReplayRecording(sps, cfg)
|
11
|
+
StopVehicleReplayRecording(sps, cfg)
|
12
|
+
|
13
|
+
class SpawnReplayVehicle(AvrsApiRequest):
|
14
|
+
def __init__(self, parser, cfg):
|
15
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'SpawnObject', '')
|
16
|
+
psr = parser.add_parser(
|
17
|
+
'spawn', help='spawn a vehicle intended to replay motion', formatter_class=RawTextHelpFormatter)
|
18
|
+
|
19
|
+
psr.add_argument(
|
20
|
+
'replay_file',
|
21
|
+
default='',
|
22
|
+
help='the replay file to use ("random" for a random profile)')
|
23
|
+
|
24
|
+
psr.add_argument(
|
25
|
+
'--name',
|
26
|
+
default='npc0',
|
27
|
+
help='name of the replay vehicle to spawn')
|
28
|
+
|
29
|
+
psr.add_argument(
|
30
|
+
'--vehicle-type',
|
31
|
+
default='EAV24',
|
32
|
+
help='what type of vehicle to spawn for replay')
|
33
|
+
|
34
|
+
# psr.add_argument(
|
35
|
+
# '--position',
|
36
|
+
# choices=('relative', 'absolute'),
|
37
|
+
# default='absolute',
|
38
|
+
# help=NPC_SPAWN_POSITION_HELP)
|
39
|
+
|
40
|
+
|
41
|
+
# psr.add_argument(
|
42
|
+
# '--velocity-type',
|
43
|
+
# default='constant',
|
44
|
+
# help='the path the NPC follows is a constant velocity or speed')
|
45
|
+
|
46
|
+
# psr.add_argument(
|
47
|
+
# '--speed',
|
48
|
+
# type=float,
|
49
|
+
# default=20,
|
50
|
+
# help='the speed of the npc is m/s')
|
51
|
+
|
52
|
+
psr.add_argument(
|
53
|
+
'--rate',
|
54
|
+
type=float,
|
55
|
+
default=1.0,
|
56
|
+
help='the playback rate, 1.0 is normal')
|
57
|
+
|
58
|
+
psr.add_argument(
|
59
|
+
'--random-start',
|
60
|
+
action='store_true',
|
61
|
+
help='if set, will start at a random point in the replay')
|
62
|
+
|
63
|
+
psr.add_argument(
|
64
|
+
'--relative-dist',
|
65
|
+
type=float,
|
66
|
+
default=40.0,
|
67
|
+
help='the distance relative to ego to start the playback (-1 to start at playback start)')
|
68
|
+
|
69
|
+
psr.add_argument(
|
70
|
+
'--auto-start',
|
71
|
+
action='store_true',
|
72
|
+
help='if set, the npc will begin moving immediately')
|
73
|
+
|
74
|
+
# psr.add_argument(
|
75
|
+
# '--enable-sensors',
|
76
|
+
# type=bool,
|
77
|
+
# default=False,
|
78
|
+
# help='whether to enable sensors on the replay vehicle')
|
79
|
+
|
80
|
+
psr.add_argument(
|
81
|
+
'--with-view-cameras',
|
82
|
+
action='store_true',
|
83
|
+
help='if set, will attach viewing cameras to the replay vehicle')
|
84
|
+
|
85
|
+
psr.set_defaults(func=self.send_request)
|
86
|
+
|
87
|
+
|
88
|
+
def get_request_body(self, args):
|
89
|
+
|
90
|
+
replay_ipd = {
|
91
|
+
'bEnableRecording': False,
|
92
|
+
'bRecordOnPhysicsTick': False,
|
93
|
+
'recordMotionMinSpeedThreshold': 0.01,
|
94
|
+
'bEnableReplay': True,
|
95
|
+
'bApplyInitialConfig': True,
|
96
|
+
'initialConfig': {
|
97
|
+
'playRate': args.rate,
|
98
|
+
'profile': args.replay_file,
|
99
|
+
'bUseRandomProfile': args.replay_file == 'random',
|
100
|
+
'replayAction': 'start' if args.auto_start else '',
|
101
|
+
'bStartReplayAtRandomTime': args.random_start,
|
102
|
+
'relativeDistance': args.relative_dist
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
eav_init_pld = {
|
107
|
+
"bEnableBsuCan": False,
|
108
|
+
"bEnableKistlerCan": False,
|
109
|
+
"bEnableBadeniaCan": False,
|
110
|
+
"bHudEnabled": False,
|
111
|
+
"bLidarEnabled": False,
|
112
|
+
"bCameraEnabled": False,
|
113
|
+
"bPublishInputs": False,
|
114
|
+
"bPublishGroundTruth": False
|
115
|
+
}
|
116
|
+
|
117
|
+
plds = [
|
118
|
+
{
|
119
|
+
'TypeName': 'WheeledVehicleReplayIpd',
|
120
|
+
'Body': replay_ipd
|
121
|
+
},
|
122
|
+
{
|
123
|
+
'TypeName': 'Eav24Initializer',
|
124
|
+
'Body': eav_init_pld
|
125
|
+
}
|
126
|
+
]
|
127
|
+
|
128
|
+
if args.with_view_cameras:
|
129
|
+
plds.append(
|
130
|
+
{
|
131
|
+
'TypeName': 'InitializerTemplates',
|
132
|
+
'Body': {
|
133
|
+
'Templates': [
|
134
|
+
{
|
135
|
+
'PayloadType': 'SimViewTargetIpd',
|
136
|
+
'PayloadSpec': 'DefaultCarCams'
|
137
|
+
}
|
138
|
+
]
|
139
|
+
}
|
140
|
+
})
|
141
|
+
|
142
|
+
return {
|
143
|
+
'Name': args.name,
|
144
|
+
'Type': args.vehicle_type,
|
145
|
+
'Location': {},
|
146
|
+
'Rotation': {},
|
147
|
+
'Payloads': plds
|
148
|
+
}
|
149
|
+
|
150
|
+
class StartVehicleReplayRecording(AvrsApiRequest):
|
151
|
+
def __init__(self, parser, cfg):
|
152
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'ConfigureVehicleReplay', 'Ego')
|
153
|
+
psr = parser.add_parser(
|
154
|
+
'start-recording', help='begin recording vehicle motion', formatter_class=RawTextHelpFormatter)
|
155
|
+
|
156
|
+
psr.add_argument(
|
157
|
+
'out_file',
|
158
|
+
help='the file name to use for the saved recording')
|
159
|
+
|
160
|
+
psr.add_argument(
|
161
|
+
'--rate-hz',
|
162
|
+
type=float,
|
163
|
+
default=100.0,
|
164
|
+
help='the rate to record vehicle motion. high rates will produce large files')
|
165
|
+
|
166
|
+
psr.set_defaults(func=self.send_request)
|
167
|
+
|
168
|
+
|
169
|
+
def get_request_body(self, args):
|
170
|
+
return {
|
171
|
+
'PlayRate': -1.0,
|
172
|
+
'profile': '',
|
173
|
+
'replayAction': '',
|
174
|
+
#'teleportLocation': '',
|
175
|
+
'recordAction': 'start',
|
176
|
+
'recordFileName': args.out_file,
|
177
|
+
'recordRateHz': args.rate_hz
|
178
|
+
}
|
179
|
+
|
180
|
+
class StopVehicleReplayRecording(AvrsApiRequest):
|
181
|
+
def __init__(self, parser, cfg):
|
182
|
+
AvrsApiRequest.__init__(self, parser, cfg, 'ConfigureVehicleReplay', 'Ego')
|
183
|
+
psr = parser.add_parser(
|
184
|
+
'stop-recording', help='begin recording vehicle motion', formatter_class=RawTextHelpFormatter)
|
185
|
+
psr.set_defaults(func=self.send_request)
|
186
|
+
|
187
|
+
|
188
|
+
def get_request_body(self, args):
|
189
|
+
return {
|
190
|
+
'recordAction': 'stop',
|
191
|
+
}
|
avrs/simconfig.py
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
import os
|
2
|
+
import stat
|
3
|
+
import json
|
4
|
+
import http.client
|
5
|
+
from avrs.cfg import *
|
6
|
+
from avrs.launcher_util import *
|
7
|
+
from avrs.simconfig_util import *
|
8
|
+
|
9
|
+
class AvrsSimConfig:
|
10
|
+
def __init__(self, parent_parser, cfg):
|
11
|
+
self.cfg = cfg
|
12
|
+
sim_config_parser = parent_parser.add_parser(
|
13
|
+
'sim-config',
|
14
|
+
help='utilities for easily configuring the simulator\n\n')
|
15
|
+
|
16
|
+
sps = sim_config_parser.add_subparsers(required=True, help='sim-config options')
|
17
|
+
|
18
|
+
apply_preset_parser = sps.add_parser(
|
19
|
+
'apply-preset',
|
20
|
+
help='apply a preset configuration for a certain use-case')
|
21
|
+
apply_preset_parser.add_argument(
|
22
|
+
'preset_name',
|
23
|
+
choices=['default', 'lightweight', 'a2rl'],
|
24
|
+
help='the name of the preset to apply')
|
25
|
+
apply_preset_parser.add_argument(
|
26
|
+
'--sim-path',
|
27
|
+
default='',
|
28
|
+
help='''
|
29
|
+
the path to the simulator installation having the intended config to modify, or the
|
30
|
+
index of a known installation. if there is only one known installation, it will be used as
|
31
|
+
the target
|
32
|
+
''')
|
33
|
+
apply_preset_parser.set_defaults(func=self.apply_preset)
|
34
|
+
|
35
|
+
|
36
|
+
def apply_preset(self, args):
|
37
|
+
sim_path = args.sim_path
|
38
|
+
if sim_path == '':
|
39
|
+
if 'installs' in self.cfg and len(self.cfg['installs']) > 0:
|
40
|
+
if len(self.cfg['installs']) > 1:
|
41
|
+
print('multiple known installs. specify path or index')
|
42
|
+
for i in range(len(self.cfg['installs'])):
|
43
|
+
print('({}) {}'.format(i, self.cfg['installs'][i]))
|
44
|
+
return
|
45
|
+
else:
|
46
|
+
sim_path = self.cfg['installs'][0]
|
47
|
+
else:
|
48
|
+
print('sim_path not specified and no known existing installations')
|
49
|
+
return
|
50
|
+
try:
|
51
|
+
sim_path_index = int(sim_path)
|
52
|
+
if 'installs' in self.cfg and len(self.cfg['installs']) > sim_path_index:
|
53
|
+
sim_path = self.cfg['installs'][sim_path_index]
|
54
|
+
except Exception as e:
|
55
|
+
pass
|
56
|
+
if not is_installed_sim(sim_path):
|
57
|
+
print('{} is not a valid sim installation'.format(sim_path))
|
58
|
+
return
|
59
|
+
|
60
|
+
print('applying preset {} to sim install at {}'.format(args.preset_name, sim_path))
|
61
|
+
apply_simconfig_preset(get_sim_saved_dir(sim_path), args.preset_name)
|
avrs/simconfig_util.py
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
import os
|
2
|
+
import json
|
3
|
+
|
4
|
+
class SimConfigFiles():
|
5
|
+
def __init__(self, saved_dir):
|
6
|
+
|
7
|
+
self.required_files = {
|
8
|
+
'main': os.path.join(saved_dir, 'simconfig.json'),
|
9
|
+
'eav24': os.path.join(saved_dir, 'Objects', 'Eav24_default.json'),
|
10
|
+
'yas': os.path.join(saved_dir, 'Environments', 'yasmarina_env.json')
|
11
|
+
}
|
12
|
+
self.files = {}
|
13
|
+
|
14
|
+
ok, status = self.valdiate()
|
15
|
+
if ok:
|
16
|
+
for name, path in self.required_files.items():
|
17
|
+
with open(path, 'r', encoding='utf-8') as f:
|
18
|
+
self.files[name] = json.load(f)
|
19
|
+
|
20
|
+
def valdiate(self):
|
21
|
+
for name, path in self.required_files.items():
|
22
|
+
if not os.path.exists(path):
|
23
|
+
return (False, '{} not found'.format(path))
|
24
|
+
return (True, '')
|
25
|
+
|
26
|
+
def save(self):
|
27
|
+
for name, path in self.required_files.items():
|
28
|
+
with open(path, 'w', encoding='utf-8') as f:
|
29
|
+
json.dump(self.files[name], f, ensure_ascii=False, indent=4)
|
30
|
+
|
31
|
+
def apply_simconfig_preset(sim_saved_dir, preset_name):
|
32
|
+
cfg_files = SimConfigFiles(sim_saved_dir)
|
33
|
+
ok, status = cfg_files.valdiate()
|
34
|
+
if not ok:
|
35
|
+
print(status)
|
36
|
+
return
|
37
|
+
|
38
|
+
presets = {
|
39
|
+
'default': apply_default_simconfig_preset,
|
40
|
+
'lightweight': apply_lightweight_simconfig_preset,
|
41
|
+
'a2rl': apply_a2rl_simconfig_preset
|
42
|
+
}
|
43
|
+
presets[preset_name](cfg_files)
|
44
|
+
|
45
|
+
def apply_default_simconfig_preset(cfg_files):
|
46
|
+
files = cfg_files.files
|
47
|
+
|
48
|
+
print('globally enabling ROS2 and CAN')
|
49
|
+
files['main']['interfaces']['bEnableRos2'] = True
|
50
|
+
files['main']['interfaces']['bEnableCan'] = True
|
51
|
+
|
52
|
+
print('ensuring default eav24 and yasmarina are reference in main config')
|
53
|
+
if not 'Environments/yasmarina_env.json' in files['main']['environmentPaths']:
|
54
|
+
print('missing yas environment. adding')
|
55
|
+
print('{}'.format(files['main']['environmentPaths']))
|
56
|
+
if not 'Objects/Eav24_default.json' in files['main']['objectTemplatePaths']:
|
57
|
+
print('missing eav24. adding')
|
58
|
+
|
59
|
+
cfg_files.save()
|
60
|
+
|
61
|
+
|
62
|
+
def apply_lightweight_simconfig_preset(cfg_files):
|
63
|
+
files = cfg_files.files
|
64
|
+
|
65
|
+
cfg_files.save()
|
66
|
+
|
67
|
+
def apply_a2rl_simconfig_preset(cfg_files):
|
68
|
+
files = cfg_files.files
|
69
|
+
|
70
|
+
cfg_files.save()
|
@@ -1,28 +0,0 @@
|
|
1
|
-
avrs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
avrs/app_version.py,sha256=U9S11DYP1oLycncpvTmnWvqUunUHaEDl_O6Elho4iEw,855
|
3
|
-
avrs/argparse_help.py,sha256=EoEaohGXZXqJvs1dFEzbo9vh47CYdHdSY2Im2Ps2iFo,945
|
4
|
-
avrs/avrs.py,sha256=3dP6YE8aB2IGN0wu_FUcRW4fch6h-b97sFcUeF0vfC0,1953
|
5
|
-
avrs/cfg.py,sha256=9NBtPrJjVN7gj_vxlvO4wOEx3OFw4d2qQgLIVLiccD0,701
|
6
|
-
avrs/launcher.py,sha256=OWwIQDgeIwGLgmLnCxv7RbzVfRNLxSbg3eaZLJ2K64s,7467
|
7
|
-
avrs/launcher_util.py,sha256=X60Jd2JUXr1MmdEF0lwjUBC5gHZte9uLlSgLWOLofXc,5121
|
8
|
-
avrs/tests.py,sha256=3JeYBjn0tRqHXERDROfzmYuW1KXeCcKur5Bw-EIegto,153
|
9
|
-
avrs/requests/can.py,sha256=iL2Dsk-V4tm37D-F1QoauaxeQtLAbg5br7zJcoR9h0o,5295
|
10
|
-
avrs/requests/code_booz.py,sha256=5bzT8Ra6EIwI19TqXMxkHG_llnyFgqSzTSo7yLNV9Vc,2274
|
11
|
-
avrs/requests/demo.py,sha256=TksvKX5YmL8-FQ4h7MWwjyIwcaZQrF9vCQ20PdfgS3Q,1138
|
12
|
-
avrs/requests/edit_environment.py,sha256=iITvLHJ4N6m-RE8dC_KnFxoTNKSjQu7ydERfQvVtb58,828
|
13
|
-
avrs/requests/input.py,sha256=SkfVjk3LsOhYNXEwn0rcSS6kZK3g8DXoMPX8Zc9LnCo,1855
|
14
|
-
avrs/requests/log_path.py,sha256=Ur24C9VqPVx78MfpicgQu2uOEe-0dXbGoWF_7dzMtZE,1326
|
15
|
-
avrs/requests/move_to_landmark.py,sha256=cLRBKu9XEDsmCoftBJ8JwoBLqzb0IZsxFMBnus4T-kc,702
|
16
|
-
avrs/requests/npc.py,sha256=Y_WovbcLomCCcOLAMMO_DHZtc1crAzWo97qEIGS3SvU,9691
|
17
|
-
avrs/requests/request.py,sha256=3hbBAt_Kd9n-HuggIbziJ3xs-VcRfLBc2GEFSOQ-LJ4,1512
|
18
|
-
avrs/requests/reserve_mv_slot.py,sha256=p_jiTV7rcoyJU6u3UR9sqPBpSaq8-PWMEs0Ckm2Hf8w,3843
|
19
|
-
avrs/requests/reset_to_track.py,sha256=lSd2YavBxDV_hQMhVoi08_TpTFEq7G2MA18xosFYa1g,450
|
20
|
-
avrs/requests/restart.py,sha256=ih5mnWiU34q3-xhOth45CtOUXxKI0PoMDCnFJV0JbwE,415
|
21
|
-
avrs/requests/teleport.py,sha256=WpnB2-Ii0FGI11EXTAHlaF5zqZIsgEyJnJ2j_w4rDFY,824
|
22
|
-
avrs/requests/vd.py,sha256=at6oUAGY2h0OxYU6MLOi1gnxyUn6i24vL9DUAj0L880,1600
|
23
|
-
autoverse_cli-0.4.0.dist-info/LICENSE,sha256=d4eWXho-u18HkBsX4K21uHX_bBb2UXZSrJdsb7Z_JlM,2647
|
24
|
-
autoverse_cli-0.4.0.dist-info/METADATA,sha256=1ekzIvDf6Hwm5gthZcMYVCzcjFKRC7DIETN7cOCD4ng,3296
|
25
|
-
autoverse_cli-0.4.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
26
|
-
autoverse_cli-0.4.0.dist-info/entry_points.txt,sha256=Cb9qsUyU5AKkklehCcvtfT0-N3SXbUEqvjze4iEU5kE,40
|
27
|
-
autoverse_cli-0.4.0.dist-info/top_level.txt,sha256=-AJO2e4MCVej6hY0U84pu5NfMeMW5qaAPSMisDT5rmA,5
|
28
|
-
autoverse_cli-0.4.0.dist-info/RECORD,,
|