lasvsim-openapi 0.1.8__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.
- lasvsim_openapi/__init__.py +2 -0
- lasvsim_openapi/client.py +32 -0
- lasvsim_openapi/http_client.py +58 -0
- lasvsim_openapi/main.py +418 -0
- lasvsim_openapi/process_task.py +43 -0
- lasvsim_openapi/process_task_model.py +39 -0
- lasvsim_openapi/qxmap_model.py +728 -0
- lasvsim_openapi/request_model.py +25 -0
- lasvsim_openapi/resources.py +20 -0
- lasvsim_openapi/response_model.py +971 -0
- lasvsim_openapi/sim_record.py +63 -0
- lasvsim_openapi/sim_record_model.py +282 -0
- lasvsim_openapi/simulator.py +439 -0
- lasvsim_openapi/train_task.py +26 -0
- lasvsim_openapi-0.1.8.dist-info/METADATA +154 -0
- lasvsim_openapi-0.1.8.dist-info/RECORD +34 -0
- lasvsim_openapi-0.1.8.dist-info/WHEEL +5 -0
- lasvsim_openapi-0.1.8.dist-info/top_level.txt +1 -0
- qianxing_openapi/__init__.py +2 -0
- qianxing_openapi/client.py +31 -0
- qianxing_openapi/http_client.py +58 -0
- qianxing_openapi/main.py +418 -0
- qianxing_openapi/process_task.py +43 -0
- qianxing_openapi/process_task_model.py +39 -0
- qianxing_openapi/qxmap_model.py +728 -0
- qianxing_openapi/request_model.py +25 -0
- qianxing_openapi/request_struct.py +25 -0
- qianxing_openapi/resources.py +20 -0
- qianxing_openapi/response_model.py +971 -0
- qianxing_openapi/response_struct.py +898 -0
- qianxing_openapi/sim_record.py +63 -0
- qianxing_openapi/sim_record_model.py +282 -0
- qianxing_openapi/simulator.py +430 -0
- qianxing_openapi/train_task.py +26 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# 包含仿真器等功能的客户端
|
|
2
|
+
|
|
3
|
+
from lasvsim_openapi.simulator import Simulator, SimulatorConfig
|
|
4
|
+
from lasvsim_openapi.http_client import HttpConfig, HttpClient
|
|
5
|
+
from lasvsim_openapi.train_task import TrainTask
|
|
6
|
+
from lasvsim_openapi.resources import Resources
|
|
7
|
+
from lasvsim_openapi.process_task import ProcessTask
|
|
8
|
+
from lasvsim_openapi.sim_record import SimRecord
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Client(object):
|
|
12
|
+
train_task: TrainTask
|
|
13
|
+
resources: Resources
|
|
14
|
+
process_task: ProcessTask
|
|
15
|
+
sim_record: SimRecord
|
|
16
|
+
|
|
17
|
+
def __init__(self, config: HttpConfig):
|
|
18
|
+
print('>>>>>')
|
|
19
|
+
self.config = config
|
|
20
|
+
self.init_common_client(config)
|
|
21
|
+
|
|
22
|
+
def init_common_client(self, config: HttpConfig):
|
|
23
|
+
client = HttpClient(config, {})
|
|
24
|
+
self.train_task = TrainTask(client)
|
|
25
|
+
self.resources = Resources(client)
|
|
26
|
+
self.process_task = ProcessTask(client)
|
|
27
|
+
self.sim_record = SimRecord(client)
|
|
28
|
+
|
|
29
|
+
def init_simulator_from_config(self, sim_config: SimulatorConfig):
|
|
30
|
+
simulator = Simulator(self.config)
|
|
31
|
+
simulator.init_from_config(sim_config)
|
|
32
|
+
return simulator
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class APIError(Exception):
|
|
5
|
+
def __init__(self, status_code, message, url):
|
|
6
|
+
super().__init__(f"APIError {url} {status_code}: {message}")
|
|
7
|
+
self.status_code = status_code
|
|
8
|
+
self.message = message
|
|
9
|
+
self.url = url
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class HttpConfig(object):
|
|
13
|
+
"""
|
|
14
|
+
Configuration for the client.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, token: str = None, endpoint: str = None):
|
|
18
|
+
self.token = token
|
|
19
|
+
self.endpoint = endpoint
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class HttpClient(object):
|
|
23
|
+
"""
|
|
24
|
+
HTTP client for the API.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, config: HttpConfig, headers: dict):
|
|
28
|
+
self.config = config
|
|
29
|
+
self.headers = headers
|
|
30
|
+
self.headers.update({"Authorization": "Bearer " + self.config.token})
|
|
31
|
+
|
|
32
|
+
def get(self, path: str, params: dict):
|
|
33
|
+
response = requests.get(
|
|
34
|
+
self.config.endpoint + path, params, headers=self.headers
|
|
35
|
+
)
|
|
36
|
+
if response.status_code != 200:
|
|
37
|
+
raise APIError(
|
|
38
|
+
response.status_code, tryParseResponse(response), response.url
|
|
39
|
+
)
|
|
40
|
+
return response.json()
|
|
41
|
+
|
|
42
|
+
def post(self, path: str, data: dict):
|
|
43
|
+
response = requests.post(
|
|
44
|
+
self.config.endpoint + path, json=data, headers=self.headers
|
|
45
|
+
)
|
|
46
|
+
if response.status_code != 200:
|
|
47
|
+
raise APIError(
|
|
48
|
+
response.status_code, tryParseResponse(response), response.url
|
|
49
|
+
)
|
|
50
|
+
return response.json()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def tryParseResponse(response):
|
|
54
|
+
try:
|
|
55
|
+
return response.json()
|
|
56
|
+
except:
|
|
57
|
+
print("Failed to parse response:", response.text)
|
|
58
|
+
return response.reason
|
lasvsim_openapi/main.py
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
from lasvsim_openapi.client import Client
|
|
7
|
+
from lasvsim_openapi.http_client import HttpConfig, HttpClient
|
|
8
|
+
from lasvsim_openapi.simulator import SimulatorConfig
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from lasvsim_openapi.request_model import Point, ObjBaseInfo
|
|
11
|
+
from typing import List
|
|
12
|
+
from lasvsim_openapi.train_task import TrainTask
|
|
13
|
+
from lasvsim_openapi.qxmap_model import Qxmap
|
|
14
|
+
|
|
15
|
+
# data = {
|
|
16
|
+
# 'id': 23,
|
|
17
|
+
# 'config': {
|
|
18
|
+
# 'scenario_id': 'gfdsfsf',
|
|
19
|
+
# 'scenario_version': 'hhhhh',
|
|
20
|
+
# 'record_id': 1
|
|
21
|
+
# },
|
|
22
|
+
# 'reason': 'my reason',
|
|
23
|
+
# }
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# class ErrorModel:
|
|
27
|
+
# code: int = 0
|
|
28
|
+
# message: str = ""
|
|
29
|
+
# reason: str = ""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# class MyConfig:
|
|
33
|
+
# scenario_id: str
|
|
34
|
+
# scenario_version: str
|
|
35
|
+
# record_id: int
|
|
36
|
+
# # 如果不是必需的字段,需要设置默认值,保证from_dict成功执行。
|
|
37
|
+
# not_in_dict: str = None
|
|
38
|
+
|
|
39
|
+
# def __init__(self, data: dict):
|
|
40
|
+
# self.__dict__ = data
|
|
41
|
+
|
|
42
|
+
# def to_dict(self):
|
|
43
|
+
# return self.__dict__
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# # @dataclass
|
|
47
|
+
# class MyTabl(ErrorModel):
|
|
48
|
+
# id: int
|
|
49
|
+
# config: MyConfig
|
|
50
|
+
|
|
51
|
+
# def __init__(self, data: dict):
|
|
52
|
+
# if (data == None):
|
|
53
|
+
# return
|
|
54
|
+
# config = data.pop('config', None)
|
|
55
|
+
|
|
56
|
+
# self.__dict__ = data
|
|
57
|
+
# self.config = MyConfig(config)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# mt = MyTabl(data)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# def myfunc() -> MyTabl:
|
|
64
|
+
# return mt
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# def cc():
|
|
68
|
+
# return mt
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# haha = myfunc()
|
|
72
|
+
# print(mt.id, mt.reason)
|
|
73
|
+
# print(mt.config.scenario_id)
|
|
74
|
+
# print(haha.config)
|
|
75
|
+
# print(haha.config.to_dict())
|
|
76
|
+
# hclient = HttpClient(
|
|
77
|
+
# config=HttpConfig(
|
|
78
|
+
# "",
|
|
79
|
+
# "",
|
|
80
|
+
# ),
|
|
81
|
+
# headers={},
|
|
82
|
+
# )
|
|
83
|
+
# resp = hclient.post(
|
|
84
|
+
# "/dev/api/viewhelper/tableheader/get",
|
|
85
|
+
# data={"table_code": "LISTCODE_TASK"},
|
|
86
|
+
# object_hook=MyTabl,
|
|
87
|
+
# )
|
|
88
|
+
# print(resp)
|
|
89
|
+
|
|
90
|
+
api_client = Client(
|
|
91
|
+
HttpConfig(
|
|
92
|
+
token=os.getenv("QX_TOKEN"),
|
|
93
|
+
endpoint=os.getenv("QX_ENDPOINT"),
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# simulator_instance = api_client.init_simulator_from_config(
|
|
98
|
+
# SimulatorConfig(scenario_id="66e525cdb504ceb8d6cd4d9a", scenario_version="0")
|
|
99
|
+
# )
|
|
100
|
+
|
|
101
|
+
# print(f"初始化成功过后的仿真器id:{simulator_instance.simulation_id}\n")
|
|
102
|
+
|
|
103
|
+
# print("rrrrrrrrr", simulator_instance.client.headers)
|
|
104
|
+
|
|
105
|
+
# for i in range(10):
|
|
106
|
+
# step_res = simulator_instance.step()
|
|
107
|
+
# print(f"执行第{i}步的结果:{step_res}") # FIXME: 第一步就执行结束了
|
|
108
|
+
|
|
109
|
+
# # stop_res = simulator_instance.stop()
|
|
110
|
+
# # print(f"停止仿真器的结果:{stop_res}\n")
|
|
111
|
+
|
|
112
|
+
# res = simulator_instance.get_vehicle_id_list()
|
|
113
|
+
# print(f"获取所有车辆ID列表的结果:{res}\n")
|
|
114
|
+
|
|
115
|
+
# res = simulator_instance.get_test_vehicle_id_list() # FIXME: 401
|
|
116
|
+
# print(f"获取测试车辆ID列表的结果:{res}\n")
|
|
117
|
+
|
|
118
|
+
# res = simulator_instance.get_vehicle_base_info([])
|
|
119
|
+
# print(f"根据车辆ID列表获取车辆基本信息的结果:{res}\n")
|
|
120
|
+
|
|
121
|
+
# res = simulator_instance.get_vehicle_position(["测试车辆1", "环境车辆1", "环境车辆2"])
|
|
122
|
+
# print(f"根据车辆ID列表获取车辆位置信息的结果:{res}\n")
|
|
123
|
+
|
|
124
|
+
# res = simulator_instance.get_vehicle_moving_info(
|
|
125
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
126
|
+
# )
|
|
127
|
+
# print(f"根据车辆ID列表获取车辆运动信息的结果:{res}\n")
|
|
128
|
+
|
|
129
|
+
# res = simulator_instance.get_vehicle_control_info(
|
|
130
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
131
|
+
# )
|
|
132
|
+
# print(f"根据车辆ID列表获取车辆控制参数信息的结果:{res}\n")
|
|
133
|
+
|
|
134
|
+
# res = simulator_instance.get_vehicle_perception_info("测试车辆1")
|
|
135
|
+
# print(f"根据车辆ID获取车辆感知信息的结果:{res}\n")
|
|
136
|
+
|
|
137
|
+
# res = simulator_instance.get_vehicle_planning_info("测试车辆1")
|
|
138
|
+
# print(f"获取车辆规划路径的结果:{res}\n")
|
|
139
|
+
|
|
140
|
+
# res = simulator_instance.get_vehicle_navigation_info("测试车辆1")
|
|
141
|
+
# print(f"获取车辆导航信息的结果:{res}\n")
|
|
142
|
+
|
|
143
|
+
# res = simulator_instance.get_vehicle_collision_status("测试车辆1")
|
|
144
|
+
# print(f"根据车辆ID获取车辆碰撞状态的结果:{res}\n")
|
|
145
|
+
|
|
146
|
+
# res = simulator_instance.set_vehicle_planning_info(
|
|
147
|
+
# vehicle_id="测试车辆1",
|
|
148
|
+
# planning_path=[
|
|
149
|
+
# Point(x=-8.75, y=-537.0316, z=0),
|
|
150
|
+
# Point(x=-8.75, y=-537.5316, z=0),
|
|
151
|
+
# Point(x=-8.75, y=-538.0316, z=0),
|
|
152
|
+
# Point(x=-8.75, y=-538.5316, z=0),
|
|
153
|
+
# ],
|
|
154
|
+
# )
|
|
155
|
+
# print(f"修改车辆规划路径的结果:{res}\n")
|
|
156
|
+
|
|
157
|
+
# res = simulator_instance.get_vehicle_planning_info("测试车辆1")
|
|
158
|
+
# print(f"获取车辆规划路径的结果:{res}\n")
|
|
159
|
+
|
|
160
|
+
# res = simulator_instance.set_vehicle_control_info(
|
|
161
|
+
# vehicle_id="测试车辆1", ste_wheel=1.2, lon_acc=1.1
|
|
162
|
+
# )
|
|
163
|
+
# print(f"修改车辆控制参数:{res}\n")
|
|
164
|
+
# res = simulator_instance.get_vehicle_control_info(
|
|
165
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
166
|
+
# )
|
|
167
|
+
# print(f"根据车辆ID列表获取车辆控制参数信息的结果:{res}\n")
|
|
168
|
+
|
|
169
|
+
# res = simulator_instance.set_vehicle_position(
|
|
170
|
+
# vehicle_id="测试车辆1", point=Point(x=-8.75, y=-537.0316, z=0)
|
|
171
|
+
# )
|
|
172
|
+
# print(f"修改车辆点位信息:{res}\n")
|
|
173
|
+
|
|
174
|
+
# res = simulator_instance.get_vehicle_position(["测试车辆1", "环境车辆1", "环境车辆2"])
|
|
175
|
+
# print(f"根据车辆ID列表获取车辆位置信息的结果:{res}\n")
|
|
176
|
+
|
|
177
|
+
# res = simulator_instance.set_vehicle_moving_info(vehicle_id="测试车辆1", u=1.1, v=1.2)
|
|
178
|
+
# print(f"修改车辆运动信息:{res}\n")
|
|
179
|
+
|
|
180
|
+
# res = simulator_instance.get_vehicle_moving_info(
|
|
181
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
182
|
+
# )
|
|
183
|
+
# print(f"根据车辆ID列表获取车辆运动信息的结果:{res}\n")
|
|
184
|
+
|
|
185
|
+
# # res = simulator_instance.get_movement_list(junction_id="f")
|
|
186
|
+
# # print(f"根据junctionId获取对应movement列表:{res}\n")
|
|
187
|
+
# res = simulator_instance.set_vehicle_base_info(
|
|
188
|
+
# vehicle_id="测试车辆1",
|
|
189
|
+
# base_info=ObjBaseInfo(
|
|
190
|
+
# 1,
|
|
191
|
+
# 2,
|
|
192
|
+
# 3,
|
|
193
|
+
# 4,
|
|
194
|
+
# ),
|
|
195
|
+
# )
|
|
196
|
+
# print(f"修改车辆基础信息,:{res}\n")
|
|
197
|
+
|
|
198
|
+
# res = simulator_instance.get_vehicle_base_info(["测试车辆1"])
|
|
199
|
+
# print(f"根据车辆ID列表获取车辆基本信息的结果:{res}\n")
|
|
200
|
+
|
|
201
|
+
# # res = simulator_instance.set_vehicle_link_nav(
|
|
202
|
+
# # vehicle_id="测试车辆1", link_nav=["sg7_lk0"]
|
|
203
|
+
# # )
|
|
204
|
+
# # print(f"修改车辆子路段导航信息:{res}\n")
|
|
205
|
+
|
|
206
|
+
# res = simulator_instance.get_vehicle_navigation_info("测试车辆1")
|
|
207
|
+
# print(f"获取车辆导航信息的结果:{res}\n")
|
|
208
|
+
|
|
209
|
+
# # res = simulator_instance.set_vehicle_destination(vehicle_id="测试车辆1")
|
|
210
|
+
# # print(f"修改车辆终点:{res}\n")
|
|
211
|
+
|
|
212
|
+
# res = simulator_instance.get_ped_id_list()
|
|
213
|
+
# print(f"获取行人ID列表:{res}\n")
|
|
214
|
+
|
|
215
|
+
# res = simulator_instance.get_ped_base_info(ped_id_list=["ped280", "ped100", "ped182"])
|
|
216
|
+
# print(f"获取行人基础信息:{res}\n")
|
|
217
|
+
|
|
218
|
+
# # res = simulator_instance.set_ped_position(
|
|
219
|
+
# # ped_id="ped280", point=Point(x=-8.75, y=-538.5316, z=0)
|
|
220
|
+
# # )
|
|
221
|
+
# # print(f"修改行人点位信息, 航向角Phi:{res}\n")
|
|
222
|
+
|
|
223
|
+
# res = simulator_instance.get_nmv_id_list()
|
|
224
|
+
# print(f"获取非机动车ID列表:{res}\n")
|
|
225
|
+
|
|
226
|
+
# # res = simulator_instance.get_nmv_base_info(nmv_id_list=["ped280", "ped100", "ped182"])
|
|
227
|
+
# # print(f"获取非机动车基础信息:{res}\n")
|
|
228
|
+
|
|
229
|
+
# # res = simulator_instance.set_ped_position(
|
|
230
|
+
# # ped_id="ped280", point=Point(x=-8.75, y=-538.5316, z=0), phi=1.2
|
|
231
|
+
# # )
|
|
232
|
+
# # print(f"修改非机动车点位信息, 航向角Phi:{res}\n")
|
|
233
|
+
# res = simulator_instance.stop()
|
|
234
|
+
# print(f"停止仿真器:{res}\n")
|
|
235
|
+
|
|
236
|
+
# ---------------------------
|
|
237
|
+
# simulator_instance = api_client.init_simulator_from_config(
|
|
238
|
+
# SimulatorConfig(scenario_id="58821406023938", scenario_version="1")
|
|
239
|
+
# )
|
|
240
|
+
|
|
241
|
+
# res = api_client.train_task.get_scene_id_list(395)
|
|
242
|
+
# print(f"训练任务获取场景列表:{res}\n")
|
|
243
|
+
|
|
244
|
+
# res = simulator_instance.get_map(asset_id="66e525cdb504ceb8d6cd4d9a", asset_version="0")
|
|
245
|
+
# print(f"地图查询结果:{res}")
|
|
246
|
+
|
|
247
|
+
# -----------resource-------------
|
|
248
|
+
|
|
249
|
+
# res = api_client.resources.get_map(
|
|
250
|
+
# asset_id="66e525cdb504ceb8d6cd4d9a", asset_version="0"
|
|
251
|
+
# )
|
|
252
|
+
# print(f"获取地图结构:{res}\n")
|
|
253
|
+
|
|
254
|
+
# ----------------train_task--------------
|
|
255
|
+
|
|
256
|
+
res = api_client.train_task.get_scene_id_list(395)
|
|
257
|
+
print(f"训练任务获取场景列表:{res}\n")
|
|
258
|
+
|
|
259
|
+
simulator_instance = api_client.init_simulator_from_config(
|
|
260
|
+
SimulatorConfig(
|
|
261
|
+
scenario_id=res.scene_id_list[0], scenario_version=res.scene_version_list[0]
|
|
262
|
+
)
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
print(f"初始化成功过后的仿真器id:{simulator_instance.simulation_id}\n")
|
|
266
|
+
|
|
267
|
+
print("rrrrrrrrr", simulator_instance.client.headers)
|
|
268
|
+
|
|
269
|
+
res = simulator_instance.get_vehicle_base_info(["测试车辆1"])
|
|
270
|
+
print(f"获取车辆基础信息:{res}\n")
|
|
271
|
+
res = simulator_instance.get_vehicle_target_speed("测试车辆1")
|
|
272
|
+
print(f"获取车辆目标速度:{res}\n")
|
|
273
|
+
for i in range(10):
|
|
274
|
+
step_res = simulator_instance.step()
|
|
275
|
+
print(f"执行第{i}步的结果:{step_res}")
|
|
276
|
+
# res = simulator_instance.reset()
|
|
277
|
+
# print(f"重置仿真器:{res}\n")
|
|
278
|
+
res = simulator_instance.stop()
|
|
279
|
+
print(f"停止仿真器:{res}\n")
|
|
280
|
+
|
|
281
|
+
# for i in range(10):
|
|
282
|
+
# step_res = simulator_instance.step()
|
|
283
|
+
# print(f"执行第{i}步的结果:{step_res}") # FIXME: 第一步就执行结束了
|
|
284
|
+
|
|
285
|
+
# # stop_res = simulator_instance.stop()
|
|
286
|
+
# # print(f"停止仿真器的结果:{stop_res}\n")
|
|
287
|
+
|
|
288
|
+
# res = simulator_instance.get_vehicle_id_list()
|
|
289
|
+
# print(f"获取所有车辆ID列表的结果:{res}\n")
|
|
290
|
+
|
|
291
|
+
# res = simulator_instance.get_test_vehicle_id_list() # FIXME: 401
|
|
292
|
+
# print(f"获取测试车辆ID列表的结果:{res}\n")
|
|
293
|
+
|
|
294
|
+
# res = simulator_instance.get_vehicle_base_info([])
|
|
295
|
+
# print(f"根据车辆ID列表获取车辆基本信息的结果:{res}\n")
|
|
296
|
+
|
|
297
|
+
# res = simulator_instance.get_vehicle_position(
|
|
298
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
299
|
+
# )
|
|
300
|
+
# print(f"根据车辆ID列表获取车辆位置信息的结果:{res}\n")
|
|
301
|
+
|
|
302
|
+
# res = simulator_instance.get_vehicle_moving_info(
|
|
303
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
304
|
+
# )
|
|
305
|
+
# print(f"根据车辆ID列表获取车辆运动信息的结果:{res}\n")
|
|
306
|
+
|
|
307
|
+
# res = simulator_instance.get_vehicle_control_info(
|
|
308
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
309
|
+
# )
|
|
310
|
+
# print(f"根据车辆ID列表获取车辆控制参数信息的结果:{res}\n")
|
|
311
|
+
|
|
312
|
+
# res = simulator_instance.get_vehicle_perception_info("测试车辆1")
|
|
313
|
+
# print(f"根据车辆ID获取车辆感知信息的结果:{res}\n")
|
|
314
|
+
|
|
315
|
+
# res = simulator_instance.get_vehicle_planning_info("测试车辆1")
|
|
316
|
+
# print(f"获取车辆规划路径的结果:{res}\n")
|
|
317
|
+
|
|
318
|
+
# res = simulator_instance.get_vehicle_navigation_info("测试车辆1")
|
|
319
|
+
# print(f"获取车辆导航信息的结果:{res}\n")
|
|
320
|
+
|
|
321
|
+
# res = simulator_instance.get_vehicle_collision_status("测试车辆1")
|
|
322
|
+
# print(f"根据车辆ID获取车辆碰撞状态的结果:{res}\n")
|
|
323
|
+
|
|
324
|
+
# res = simulator_instance.set_vehicle_planning_info(
|
|
325
|
+
# vehicle_id="测试车辆1",
|
|
326
|
+
# planning_path=[
|
|
327
|
+
# Point(x=-8.75, y=-537.0316, z=0),
|
|
328
|
+
# Point(x=-8.75, y=-537.5316, z=0),
|
|
329
|
+
# Point(x=-8.75, y=-538.0316, z=0),
|
|
330
|
+
# Point(x=-8.75, y=-538.5316, z=0),
|
|
331
|
+
# ],
|
|
332
|
+
# )
|
|
333
|
+
# print(f"修改车辆规划路径的结果:{res}\n")
|
|
334
|
+
|
|
335
|
+
# res = simulator_instance.get_vehicle_planning_info("测试车辆1")
|
|
336
|
+
# print(f"获取车辆规划路径的结果:{res}\n")
|
|
337
|
+
|
|
338
|
+
# res = simulator_instance.set_vehicle_control_info(
|
|
339
|
+
# vehicle_id="测试车辆1", ste_wheel=1.2, lon_acc=1.1
|
|
340
|
+
# )
|
|
341
|
+
# print(f"修改车辆控制参数:{res}\n")
|
|
342
|
+
# res = simulator_instance.get_vehicle_control_info(
|
|
343
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
344
|
+
# )
|
|
345
|
+
# print(f"根据车辆ID列表获取车辆控制参数信息的结果:{res}\n")
|
|
346
|
+
|
|
347
|
+
# res = simulator_instance.set_vehicle_position(
|
|
348
|
+
# vehicle_id="测试车辆1", point=Point(x=-8.75, y=-537.0316, z=0)
|
|
349
|
+
# )
|
|
350
|
+
# print(f"修改车辆点位信息:{res}\n")
|
|
351
|
+
|
|
352
|
+
# res = simulator_instance.get_vehicle_position(
|
|
353
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
354
|
+
# )
|
|
355
|
+
# print(f"根据车辆ID列表获取车辆位置信息的结果:{res}\n")
|
|
356
|
+
|
|
357
|
+
# res = simulator_instance.set_vehicle_moving_info(
|
|
358
|
+
# vehicle_id="测试车辆1", u=1.1, v=1.2
|
|
359
|
+
# )
|
|
360
|
+
# print(f"修改车辆运动信息:{res}\n")
|
|
361
|
+
|
|
362
|
+
# res = simulator_instance.get_vehicle_moving_info(
|
|
363
|
+
# ["测试车辆1", "环境车辆1", "环境车辆2"]
|
|
364
|
+
# )
|
|
365
|
+
# print(f"根据车辆ID列表获取车辆运动信息的结果:{res}\n")
|
|
366
|
+
|
|
367
|
+
# # res = simulator_instance.get_movement_list(junction_id="f")
|
|
368
|
+
# # print(f"根据junctionId获取对应movement列表:{res}\n")
|
|
369
|
+
# res = simulator_instance.set_vehicle_base_info(
|
|
370
|
+
# vehicle_id="测试车辆1",
|
|
371
|
+
# base_info=ObjBaseInfo(
|
|
372
|
+
# 1,
|
|
373
|
+
# 2,
|
|
374
|
+
# 3,
|
|
375
|
+
# 4,
|
|
376
|
+
# ),
|
|
377
|
+
# )
|
|
378
|
+
# print(f"修改车辆基础信息,:{res}\n")
|
|
379
|
+
|
|
380
|
+
# res = simulator_instance.get_vehicle_base_info(["测试车辆1"])
|
|
381
|
+
# print(f"根据车辆ID列表获取车辆基本信息的结果:{res}\n")
|
|
382
|
+
|
|
383
|
+
# # res = simulator_instance.set_vehicle_link_nav(
|
|
384
|
+
# # vehicle_id="测试车辆1", link_nav=["sg7_lk0"]
|
|
385
|
+
# # )
|
|
386
|
+
# # print(f"修改车辆子路段导航信息:{res}\n")
|
|
387
|
+
|
|
388
|
+
# res = simulator_instance.get_vehicle_navigation_info("测试车辆1")
|
|
389
|
+
# print(f"获取车辆导航信息的结果:{res}\n")
|
|
390
|
+
|
|
391
|
+
# # res = simulator_instance.set_vehicle_destination(vehicle_id="测试车辆1")
|
|
392
|
+
# # print(f"修改车辆终点:{res}\n")
|
|
393
|
+
|
|
394
|
+
# res = simulator_instance.get_ped_id_list()
|
|
395
|
+
# print(f"获取行人ID列表:{res}\n")
|
|
396
|
+
|
|
397
|
+
# res = simulator_instance.get_ped_base_info(
|
|
398
|
+
# ped_id_list=["ped280", "ped100", "ped182"]
|
|
399
|
+
# )
|
|
400
|
+
# print(f"获取行人基础信息:{res}\n")
|
|
401
|
+
|
|
402
|
+
# # res = simulator_instance.set_ped_position(
|
|
403
|
+
# # ped_id="ped280", point=Point(x=-8.75, y=-538.5316, z=0)
|
|
404
|
+
# # )
|
|
405
|
+
# # print(f"修改行人点位信息, 航向角Phi:{res}\n")
|
|
406
|
+
|
|
407
|
+
# res = simulator_instance.get_nmv_id_list()
|
|
408
|
+
# print(f"获取非机动车ID列表:{res}\n")
|
|
409
|
+
|
|
410
|
+
# # res = simulator_instance.get_nmv_base_info(nmv_id_list=["ped280", "ped100", "ped182"])
|
|
411
|
+
# # print(f"获取非机动车基础信息:{res}\n")
|
|
412
|
+
|
|
413
|
+
# # res = simulator_instance.set_ped_position(
|
|
414
|
+
# # ped_id="ped280", point=Point(x=-8.75, y=-538.5316, z=0), phi=1.2
|
|
415
|
+
# # )
|
|
416
|
+
# # print(f"修改非机动车点位信息, 航向角Phi:{res}\n")
|
|
417
|
+
# res = simulator_instance.stop()
|
|
418
|
+
# print(f"停止仿真器:{res}\n")
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from lasvsim_openapi.http_client import HttpClient
|
|
2
|
+
from lasvsim_openapi import process_task_model
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ProcessTask:
|
|
6
|
+
client: HttpClient
|
|
7
|
+
|
|
8
|
+
def __init__(self, client: HttpClient):
|
|
9
|
+
self.client = client
|
|
10
|
+
|
|
11
|
+
def copy_record(
|
|
12
|
+
self,
|
|
13
|
+
task_id: int = None,
|
|
14
|
+
record_id: int = None,
|
|
15
|
+
) -> process_task_model.CopyRecordRes:
|
|
16
|
+
req_data = {"task_id": task_id, "record_id": record_id}
|
|
17
|
+
resp = self.client.post(
|
|
18
|
+
"/openapi/process_task/v2/record/copy", req_data)
|
|
19
|
+
|
|
20
|
+
return process_task_model.CopyRecordRes(resp)
|
|
21
|
+
|
|
22
|
+
def get_record_scenario(
|
|
23
|
+
self,
|
|
24
|
+
task_id: int = None,
|
|
25
|
+
record_id: int = None,
|
|
26
|
+
) -> process_task_model.GetRecordScenarioRes:
|
|
27
|
+
req_data = {"task_id": task_id, "record_id": record_id}
|
|
28
|
+
resp = self.client.post(
|
|
29
|
+
"/openapi/process_task/v2/record/scenario/get", req_data
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return process_task_model.GetRecordScenarioRes(resp)
|
|
33
|
+
|
|
34
|
+
def get_task_record_ids(
|
|
35
|
+
self,
|
|
36
|
+
task_id: int = None,
|
|
37
|
+
) -> process_task_model.GetTaskRecordIdsRes:
|
|
38
|
+
req_data = {"task_id": task_id}
|
|
39
|
+
print("rr", req_data)
|
|
40
|
+
resp = self.client.post(
|
|
41
|
+
"/openapi/process_task/v2/record/id_list", req_data)
|
|
42
|
+
print("eeee", resp)
|
|
43
|
+
return process_task_model.GetTaskRecordIdsRes(resp)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# -----------------------------仿真结构结构--------------------------------
|
|
5
|
+
@dataclass
|
|
6
|
+
class CopyRecordRes:
|
|
7
|
+
sim_record_id: str = None
|
|
8
|
+
scen_id: str = None
|
|
9
|
+
scen_ver: str = None
|
|
10
|
+
new_record_id: str = None
|
|
11
|
+
|
|
12
|
+
def __init__(self, data: dict) -> None:
|
|
13
|
+
if data == None:
|
|
14
|
+
return
|
|
15
|
+
|
|
16
|
+
self.__dict__ = data
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class GetRecordScenarioRes:
|
|
21
|
+
scen_id: str = None
|
|
22
|
+
scen_ver: str = None
|
|
23
|
+
|
|
24
|
+
def __init__(self, data: dict) -> None:
|
|
25
|
+
if data == None:
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
self.__dict__ = data
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class GetTaskRecordIdsRes:
|
|
33
|
+
record_ids: list[int] = None
|
|
34
|
+
|
|
35
|
+
def __init__(self, data: dict) -> None:
|
|
36
|
+
if data == None:
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
self.__dict__ = data
|