lasvsim-openapi 0.1.11__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 +66 -0
- lasvsim_openapi/http_client.py +170 -0
- lasvsim_openapi/main.py +418 -0
- lasvsim_openapi/process_task.py +89 -0
- lasvsim_openapi/process_task_model.py +107 -0
- lasvsim_openapi/qxmap.py +980 -0
- lasvsim_openapi/qxmap_model.py +3 -0
- lasvsim_openapi/request_model.py +3 -0
- lasvsim_openapi/resources.py +74 -0
- lasvsim_openapi/response_model.py +4 -0
- lasvsim_openapi/sim_record.py +147 -0
- lasvsim_openapi/sim_record_model.py +513 -0
- lasvsim_openapi/simulator.py +897 -0
- lasvsim_openapi/simulator_model.py +1940 -0
- lasvsim_openapi/train_task.py +37 -0
- lasvsim_openapi/train_task_model.py +39 -0
- lasvsim_openapi-0.1.11.dist-info/METADATA +172 -0
- lasvsim_openapi-0.1.11.dist-info/RECORD +37 -0
- lasvsim_openapi-0.1.11.dist-info/WHEEL +5 -0
- lasvsim_openapi-0.1.11.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,66 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Client module for the lasvsim API.
|
|
3
|
+
"""
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
from lasvsim_openapi.http_client import HttpConfig, HttpClient
|
|
7
|
+
from lasvsim_openapi.train_task import TrainTask
|
|
8
|
+
from lasvsim_openapi.resources import Resources
|
|
9
|
+
from lasvsim_openapi.process_task import ProcessTask
|
|
10
|
+
from lasvsim_openapi.simulator import Simulator, SimulatorConfig
|
|
11
|
+
from lasvsim_openapi.sim_record import SimRecord
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Client:
|
|
15
|
+
"""Main client for the API."""
|
|
16
|
+
config: HttpConfig = None
|
|
17
|
+
http_client: HttpClient = None
|
|
18
|
+
train_task: TrainTask = None
|
|
19
|
+
resources: Resources = None
|
|
20
|
+
process_task: ProcessTask = None
|
|
21
|
+
simulator: Simulator = None
|
|
22
|
+
sim_record: SimRecord = None
|
|
23
|
+
|
|
24
|
+
def __init__(self, config: HttpConfig):
|
|
25
|
+
"""Initialize a new API client.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
config: HTTP configuration for the client
|
|
29
|
+
"""
|
|
30
|
+
self.config = config
|
|
31
|
+
self.http_client = HttpClient(config)
|
|
32
|
+
self.init_common_client()
|
|
33
|
+
|
|
34
|
+
def init_common_client(self):
|
|
35
|
+
"""Initialize the common client components."""
|
|
36
|
+
self.train_task = TrainTask(self.http_client)
|
|
37
|
+
self.resources = Resources(self.http_client)
|
|
38
|
+
self.process_task = ProcessTask(self.http_client)
|
|
39
|
+
self.sim_record = SimRecord(self.http_client)
|
|
40
|
+
|
|
41
|
+
def init_simulator_from_config(self, sim_config: SimulatorConfig) -> Simulator:
|
|
42
|
+
"""Initialize a simulator from the given configuration.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
sim_config: Configuration for the simulator
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
A new simulator instance
|
|
49
|
+
"""
|
|
50
|
+
simulator = Simulator(self.http_client)
|
|
51
|
+
simulator.init_from_config(sim_config)
|
|
52
|
+
return simulator
|
|
53
|
+
|
|
54
|
+
def init_simulator_from_sim(self, sim_id: str, addr: str) -> Simulator:
|
|
55
|
+
"""Initialize a simulator from existing simulation.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
sim_id: ID of the existing simulation
|
|
59
|
+
addr: Address of the simulation
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
A new simulator instance
|
|
63
|
+
"""
|
|
64
|
+
simulator = Simulator(self.http_client)
|
|
65
|
+
simulator.init_from_sim(sim_id, addr)
|
|
66
|
+
return simulator
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""
|
|
2
|
+
HTTP client module for the lasvsim API.
|
|
3
|
+
"""
|
|
4
|
+
from typing import Any, Dict, Callable, Optional, Type, TypeVar,Tuple
|
|
5
|
+
import requests
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ErrorReason:
|
|
9
|
+
"""Error reason constants."""
|
|
10
|
+
CALL_GRPC_ERR = "CALL_GRPC_ERR"
|
|
11
|
+
PARAM_UNAVAILABLE = "PARAM_UNVAILABLE" # Keep original typo for compatibility
|
|
12
|
+
NOT_EXIST = "NOT_EXIST"
|
|
13
|
+
GET_HEADER_ERR = "GET_HEADER_ERR"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class APIError(Exception):
|
|
17
|
+
"""Error returned by the API."""
|
|
18
|
+
status_code: int = 0
|
|
19
|
+
message: Any = None
|
|
20
|
+
url: str = ""
|
|
21
|
+
reason: str = ""
|
|
22
|
+
|
|
23
|
+
def __init__(self, status_code: int, message: Any, url: str, reason: str = ""):
|
|
24
|
+
super().__init__(f"APIError {url} {status_code}: {message}")
|
|
25
|
+
self.status_code = status_code
|
|
26
|
+
self.message = message
|
|
27
|
+
self.url = url
|
|
28
|
+
self.reason = reason
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def is_api_error(err: Exception) -> Tuple[Optional['APIError'], bool]:
|
|
32
|
+
"""Check if an error is an APIError.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
err: The error to check
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
A tuple of (APIError instance if it is an APIError, boolean indicating if it is an APIError)
|
|
39
|
+
"""
|
|
40
|
+
if isinstance(err, APIError):
|
|
41
|
+
return err, True
|
|
42
|
+
return None, False
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def match_error_reason(err: Exception, err_str: str) -> bool:
|
|
46
|
+
"""Check if an error matches a specific error reason.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
err: The error to check
|
|
50
|
+
err_str: The error reason to match against
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
True if the error matches the reason, False otherwise
|
|
54
|
+
"""
|
|
55
|
+
if isinstance(err, APIError):
|
|
56
|
+
return err.reason == err_str
|
|
57
|
+
return False
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class HttpConfig:
|
|
61
|
+
"""Configuration for the HTTP client."""
|
|
62
|
+
token: str = ""
|
|
63
|
+
endpoint: str = ""
|
|
64
|
+
|
|
65
|
+
def __init__(self, token: str = "", endpoint: str = ""):
|
|
66
|
+
"""Initialize HTTP configuration.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
token: Authentication token
|
|
70
|
+
endpoint: API endpoint URL
|
|
71
|
+
"""
|
|
72
|
+
self.token = token
|
|
73
|
+
self.endpoint = endpoint
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
T = TypeVar('T')
|
|
77
|
+
|
|
78
|
+
class HttpClient():
|
|
79
|
+
"""HTTP client for the API."""
|
|
80
|
+
config: HttpConfig = None
|
|
81
|
+
headers: Dict[str, str] = {}
|
|
82
|
+
|
|
83
|
+
def __init__(self, config: HttpConfig, headers: Dict[str, str] = None):
|
|
84
|
+
"""Initialize HTTP client.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
config: Client configuration
|
|
88
|
+
headers: Optional custom headers
|
|
89
|
+
"""
|
|
90
|
+
self.config = config
|
|
91
|
+
self.headers = headers or {}
|
|
92
|
+
self.headers["Authorization"] = f"Bearer {config.token}"
|
|
93
|
+
|
|
94
|
+
def clone(self) -> 'HttpClient':
|
|
95
|
+
"""Create a clone of this client.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
A new HttpClient instance with the same configuration
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
return HttpClient(self.config, dict(self.headers))
|
|
102
|
+
|
|
103
|
+
def _handle_response(self, response: requests.Response, out_type: Optional[Type[T]] = None) -> Optional[T]:
|
|
104
|
+
if response.status_code != 200:
|
|
105
|
+
try:
|
|
106
|
+
error_data = response.json()
|
|
107
|
+
reason = error_data.get('reason') if isinstance(error_data, dict) else None
|
|
108
|
+
raise APIError(
|
|
109
|
+
status_code=response.status_code,
|
|
110
|
+
message=error_data,
|
|
111
|
+
url=f"{response.request.method},{response.url}",
|
|
112
|
+
reason=reason
|
|
113
|
+
)
|
|
114
|
+
except ValueError:
|
|
115
|
+
raise APIError(
|
|
116
|
+
status_code=response.status_code,
|
|
117
|
+
message=response.text,
|
|
118
|
+
url=f"{response.request.method},{response.url}"
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
if out_type is None:
|
|
122
|
+
return None
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
response_data = response.json()
|
|
126
|
+
return out_type.from_dict(response_data)
|
|
127
|
+
except ValueError:
|
|
128
|
+
raise APIError("Invalid JSON response")
|
|
129
|
+
|
|
130
|
+
def get(self, path: str, params: Dict[str, str] = None, out_type: Optional[Type[T]] = None) -> T:
|
|
131
|
+
"""Send GET request.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
path: API endpoint path
|
|
135
|
+
params: Query parameters
|
|
136
|
+
out: Type to parse response into
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
Response data parsed into specified type
|
|
140
|
+
|
|
141
|
+
Raises:
|
|
142
|
+
APIError: If the request fails
|
|
143
|
+
"""
|
|
144
|
+
response = requests.get(
|
|
145
|
+
self.config.endpoint + path,
|
|
146
|
+
params=params,
|
|
147
|
+
headers=self.headers
|
|
148
|
+
)
|
|
149
|
+
return self._handle_response(response, out_type)
|
|
150
|
+
|
|
151
|
+
def post(self, path: str, data: Any = None, out_type: Optional[Type[T]] = None) -> T:
|
|
152
|
+
"""Send POST request.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
path: API endpoint path
|
|
156
|
+
data: Request data
|
|
157
|
+
out: Type to parse response into
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
Response data parsed into specified type
|
|
161
|
+
|
|
162
|
+
Raises:
|
|
163
|
+
APIError: If the request fails
|
|
164
|
+
"""
|
|
165
|
+
response = requests.post(
|
|
166
|
+
self.config.endpoint + path,
|
|
167
|
+
json=data,
|
|
168
|
+
headers=self.headers
|
|
169
|
+
)
|
|
170
|
+
return self._handle_response(response, out_type)
|
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")
|