Core Control¶
本页描述 TongSIM Lite 的基础控制 API:用于与 UE 世界中的 actor 交互,包括状态查询、生成/销毁、导航辅助、射线检测与控制台命令等。
命名说明
协议层这些方法由 DemoRLService 实现(见 protobuf/tongsim_lite_protobuf/demo_rl.proto)。尽管名字包含 “DemoRL”,但在 TongSIM Lite 中它承担的是通用控制面的角色。
Key Functions¶
query_info:获取当前世界中已追踪 actor 的状态快照列表。reset_level:重载当前关卡(触发 map travel)。get_actor_state:按 GUID 查询 actor 的位置、朝向向量、标签等元数据。get_actor_transform/set_actor_transform:读取/设置 actor 的 world transform。spawn_actor/destroy_actor:在当前世界中生成/销毁 actor。simple_move_towards:以恒速将 actor 朝目标点移动。query_navigation_path:查询两点间的 NavMesh 路径。navigate_to_location:使用 UE NavMesh 驱动角色移动到目标点。pick_up_object/drop_object:面向任务的交互 helper(需要关卡支持)。exec_console_command:执行 UE 控制台命令。single_line_trace_by_object/multi_line_trace_by_object:批量射线检测并返回命中信息。
API References¶
tongsim.connection.grpc.unary_api.UnaryAPI.query_info
async
staticmethod
¶
query_info(conn: GrpcConnection) -> list[dict]
Fetch state snapshots for every actor in the current Demo RL scene.
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: One entry per actor with GUID, name, class path, location vectors, basis vectors, bounding box and tag metadata. |
Source code in src/tongsim/connection/grpc/unary_api.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
tongsim.connection.grpc.unary_api.UnaryAPI.reset_level
async
staticmethod
¶
reset_level(
conn: GrpcConnection, timeout: float = 60.0
) -> bool
Reset the active Demo RL level.
Source code in src/tongsim/connection/grpc/unary_api.py
184 185 186 187 188 189 190 | |
tongsim.connection.grpc.unary_api.UnaryAPI.get_actor_state
async
staticmethod
¶
get_actor_state(
conn: GrpcConnection, actor_id: str
) -> dict | None
Fetch the state of a single actor by identifier.
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Actor metadata dictionary, or |
Source code in src/tongsim/connection/grpc/unary_api.py
246 247 248 249 250 251 252 253 254 255 256 257 258 | |
tongsim.connection.grpc.unary_api.UnaryAPI.get_actor_transform
async
staticmethod
¶
get_actor_transform(
conn: GrpcConnection, actor_id: str
) -> Transform
Retrieve an actor's world transform.
Returns:
| Type | Description |
|---|---|
Transform
|
Transform | None: World transform, or |
Source code in src/tongsim/connection/grpc/unary_api.py
260 261 262 263 264 265 266 267 268 269 270 271 272 | |
tongsim.connection.grpc.unary_api.UnaryAPI.set_actor_transform
async
staticmethod
¶
set_actor_transform(
conn: GrpcConnection,
actor_id: bytes | str | dict,
transform: Transform,
) -> bool
Teleport an actor to the supplied world transform (TeleportPhysics).
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True on success. |
Source code in src/tongsim/connection/grpc/unary_api.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
tongsim.connection.grpc.unary_api.UnaryAPI.spawn_actor
async
staticmethod
¶
spawn_actor(
conn: GrpcConnection,
blueprint: str,
transform: Transform,
name: str | None = None,
tags: list[str] | None = None,
timeout: float = 5.0,
) -> dict | None
Spawn an actor in the Demo RL scene and return its identity information.
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Dictionary with |
Source code in src/tongsim/connection/grpc/unary_api.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
tongsim.connection.grpc.unary_api.UnaryAPI.destroy_actor
async
staticmethod
¶
destroy_actor(
conn: GrpcConnection, actor_id: bytes | str | dict
) -> bool
Destroy an actor in the Demo RL scene.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True on success. |
Source code in src/tongsim/connection/grpc/unary_api.py
744 745 746 747 748 749 750 751 752 753 754 755 756 | |
tongsim.connection.grpc.unary_api.UnaryAPI.simple_move_towards
async
staticmethod
¶
simple_move_towards(
conn: GrpcConnection,
target_location: Vector3,
actor_id: bytes | str | dict,
orientation_mode: RLDemoOrientationMode = ORIENTATION_KEEP_CURRENT,
given_forward: Vector3 | None = None,
timeout: float = 3600.0,
speed_uu_per_sec: float = 300.0,
tolerance_uu: float = 5.0,
) -> tuple[dict | None, dict | None]
Move an actor toward the given world-space target using the simple mover.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_location
|
Vector3
|
Destination in world coordinates. |
required |
actor_id
|
bytes | str | dict
|
Actor identifier (FGuid bytes or GUID string). |
required |
orientation_mode
|
RLDemoOrientationMode
|
Orientation strategy applied during movement. |
ORIENTATION_KEEP_CURRENT
|
given_forward
|
Vector3 | None
|
Forward vector used when orientation_mode is ORIENTATION_GIVEN. |
None
|
timeout
|
float
|
RPC timeout in seconds. |
3600.0
|
speed_uu_per_sec
|
float
|
Movement speed in Unreal units per second. |
300.0
|
tolerance_uu
|
float
|
Distance threshold treated as arrival. |
5.0
|
Returns:
| Type | Description |
|---|---|
tuple[dict | None, dict | None]
|
tuple[Vector3 | None, dict | None]: Current location and optional hit metadata with |
Source code in src/tongsim/connection/grpc/unary_api.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
tongsim.connection.grpc.unary_api.UnaryAPI.query_navigation_path
async
staticmethod
¶
query_navigation_path(
conn: GrpcConnection,
start: Vector3,
end: Vector3,
allow_partial: bool = True,
require_navigable_end_location: bool = False,
cost_limit: float | None = None,
timeout: float = 2.0,
) -> dict | None
Compute a navigation path between two world positions using the UE navigation system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
Vector3
|
Starting world location. |
required |
end
|
Vector3
|
Target world location. |
required |
allow_partial
|
bool
|
Allow returning partial paths when a full path is unavailable. |
True
|
require_navigable_end_location
|
bool
|
Enforce the end point to lie on the navmesh. |
False
|
cost_limit
|
float | None
|
Optional cost threshold; values <= 0 disable it. |
None
|
timeout
|
float
|
RPC timeout in seconds. |
2.0
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict | None
|
Path data including |
Source code in src/tongsim/connection/grpc/unary_api.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
tongsim.connection.grpc.unary_api.UnaryAPI.navigate_to_location
async
staticmethod
¶
navigate_to_location(
conn: GrpcConnection,
actor_id: bytes | str | dict,
target_location: Vector3,
accept_radius: float,
allow_partial: bool = True,
speed_uu_per_sec: float | None = None,
timeout: float = 3600.0,
) -> dict | None
Navigate a Character to a location using UE NavMesh (server-side async Reactor).
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict | None
|
|
Source code in src/tongsim/connection/grpc/unary_api.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | |
tongsim.connection.grpc.unary_api.UnaryAPI.pick_up_object
async
staticmethod
¶
pick_up_object(
conn: GrpcConnection,
actor_id: bytes | str | dict,
target_object_id: bytes | str | dict,
target_object_location: Vector3 | None = None,
hand: RLDemoHandType = HAND_RIGHT,
timeout: float = 5.0,
) -> dict
Request the UE server to pick up the specified target actor.
Source code in src/tongsim/connection/grpc/unary_api.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
tongsim.connection.grpc.unary_api.UnaryAPI.drop_object
async
staticmethod
¶
drop_object(
conn: GrpcConnection,
actor_id: bytes | str | dict,
target_drop_location: Vector3,
hand: RLDemoHandType = HAND_RIGHT,
enable_physics: bool = False,
timeout: float = 5.0,
) -> dict
Request the UE server to drop an object (placeholder Reactor endpoint).
Source code in src/tongsim/connection/grpc/unary_api.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
tongsim.connection.grpc.unary_api.UnaryAPI.exec_console_command
async
staticmethod
¶
exec_console_command(
conn: GrpcConnection,
command: str,
write_to_log: bool = True,
timeout: float = 2.0,
) -> bool
Execute a UE console command such as stat fps or r.Streaming.PoolSize 4000.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the command was accepted (console output text is unavailable). |
Source code in src/tongsim/connection/grpc/unary_api.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
tongsim.connection.grpc.unary_api.UnaryAPI.single_line_trace_by_object
async
staticmethod
¶
single_line_trace_by_object(
conn: GrpcConnection,
jobs: list[dict],
timeout: float = 5.0,
) -> list[dict]
Run batch SingleLineTraceByObject requests and return hit summaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobs
|
list[dict]
|
Each job describes |
required |
timeout
|
float
|
RPC timeout in seconds. |
5.0
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: Per-job results including |
Source code in src/tongsim/connection/grpc/unary_api.py
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | |
tongsim.connection.grpc.unary_api.UnaryAPI.multi_line_trace_by_object
async
staticmethod
¶
multi_line_trace_by_object(
conn: GrpcConnection,
jobs: list[dict],
timeout: float = 5.0,
*,
enable_debug_draw: bool = False
) -> list[dict]
Run batch MultiLineTraceByObject requests and collect ordered hit lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobs
|
list[dict]
|
Each job describes |
required |
timeout
|
float
|
RPC timeout in seconds. |
5.0
|
enable_debug_draw
|
bool
|
Whether to render debug lines in UE. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: Per-job results with |
Source code in src/tongsim/connection/grpc/unary_api.py
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 | |