mini-carla 0.9.2__tar.gz
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.
- mini_carla-0.9.2/.gitignore +1 -0
- mini_carla-0.9.2/Cargo.lock +131 -0
- mini_carla-0.9.2/Cargo.toml +18 -0
- mini_carla-0.9.2/PKG-INFO +133 -0
- mini_carla-0.9.2/README.md +119 -0
- mini_carla-0.9.2/examples/hills_and_sensors.py +58 -0
- mini_carla-0.9.2/pyproject.toml +28 -0
- mini_carla-0.9.2/python/mini_carla/__init__.py +275 -0
- mini_carla-0.9.2/python/mini_carla/__main__.py +50 -0
- mini_carla-0.9.2/python/tests/test_launcher.py +66 -0
- mini_carla-0.9.2/src/blueprints.rs +438 -0
- mini_carla-0.9.2/src/gridmap.rs +308 -0
- mini_carla-0.9.2/src/main.rs +180 -0
- mini_carla-0.9.2/src/msg.rs +565 -0
- mini_carla-0.9.2/src/odr.rs +410 -0
- mini_carla-0.9.2/src/rpc.rs +1137 -0
- mini_carla-0.9.2/src/stream.rs +99 -0
- mini_carla-0.9.2/src/world.rs +1712 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/target/
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "memchr"
|
|
13
|
+
version = "2.8.3"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "mini-carla"
|
|
19
|
+
version = "0.9.2"
|
|
20
|
+
dependencies = [
|
|
21
|
+
"rmpv",
|
|
22
|
+
"xodr",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[[package]]
|
|
26
|
+
name = "num-traits"
|
|
27
|
+
version = "0.2.19"
|
|
28
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
29
|
+
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
|
30
|
+
dependencies = [
|
|
31
|
+
"autocfg",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[[package]]
|
|
35
|
+
name = "opencrg"
|
|
36
|
+
version = "0.0.2"
|
|
37
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
38
|
+
checksum = "97f3d8561c446e47e9b24e948b40afd93baf40bbd5616cfe32175ee491aa7f95"
|
|
39
|
+
|
|
40
|
+
[[package]]
|
|
41
|
+
name = "proc-macro2"
|
|
42
|
+
version = "1.0.107"
|
|
43
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
44
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
45
|
+
dependencies = [
|
|
46
|
+
"unicode-ident",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[[package]]
|
|
50
|
+
name = "quote"
|
|
51
|
+
version = "1.0.47"
|
|
52
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
53
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
54
|
+
dependencies = [
|
|
55
|
+
"proc-macro2",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[[package]]
|
|
59
|
+
name = "rmp"
|
|
60
|
+
version = "0.8.15"
|
|
61
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
62
|
+
checksum = "4ba8be72d372b2c9b35542551678538b562e7cf86c3315773cae48dfbfe7790c"
|
|
63
|
+
dependencies = [
|
|
64
|
+
"num-traits",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
[[package]]
|
|
68
|
+
name = "rmpv"
|
|
69
|
+
version = "1.3.1"
|
|
70
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
71
|
+
checksum = "7a4e1d4b9b938a26d2996af33229f0ca0956c652c1375067f0b45291c1df8417"
|
|
72
|
+
dependencies = [
|
|
73
|
+
"rmp",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "roxmltree"
|
|
78
|
+
version = "0.21.2"
|
|
79
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
+
checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907"
|
|
81
|
+
dependencies = [
|
|
82
|
+
"memchr",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[[package]]
|
|
86
|
+
name = "syn"
|
|
87
|
+
version = "3.0.10"
|
|
88
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
89
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
90
|
+
dependencies = [
|
|
91
|
+
"proc-macro2",
|
|
92
|
+
"quote",
|
|
93
|
+
"unicode-ident",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
[[package]]
|
|
97
|
+
name = "thiserror"
|
|
98
|
+
version = "2.0.21"
|
|
99
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
100
|
+
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
|
|
101
|
+
dependencies = [
|
|
102
|
+
"thiserror-impl",
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
[[package]]
|
|
106
|
+
name = "thiserror-impl"
|
|
107
|
+
version = "2.0.21"
|
|
108
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
109
|
+
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
|
|
110
|
+
dependencies = [
|
|
111
|
+
"proc-macro2",
|
|
112
|
+
"quote",
|
|
113
|
+
"syn",
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
[[package]]
|
|
117
|
+
name = "unicode-ident"
|
|
118
|
+
version = "1.0.27"
|
|
119
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
120
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
121
|
+
|
|
122
|
+
[[package]]
|
|
123
|
+
name = "xodr"
|
|
124
|
+
version = "0.8.0"
|
|
125
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
126
|
+
checksum = "d8b06c3b930f495c0ebceb4b248c6c5167bd1f039d6314c4ed602c5b784e603d"
|
|
127
|
+
dependencies = [
|
|
128
|
+
"opencrg",
|
|
129
|
+
"roxmltree",
|
|
130
|
+
"thiserror",
|
|
131
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "mini-carla"
|
|
3
|
+
version = "0.9.2"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "A lightweight CARLA-compatible traffic simulator (no rendering) for typesafe_carla"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
|
|
9
|
+
[[bin]]
|
|
10
|
+
name = "mini-carla"
|
|
11
|
+
path = "src/main.rs"
|
|
12
|
+
|
|
13
|
+
[dependencies]
|
|
14
|
+
rmpv = "1"
|
|
15
|
+
xodr = "0.8"
|
|
16
|
+
|
|
17
|
+
[profile.release]
|
|
18
|
+
opt-level = 3
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mini-carla
|
|
3
|
+
Version: 0.9.2
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
7
|
+
Classifier: Topic :: Scientific/Engineering
|
|
8
|
+
Summary: A CARLA-compatible (LibCarla ue58-dev protocol) traffic simulator without rendering, for typesafe_carla
|
|
9
|
+
Keywords: carla,simulation,traffic,opendrive
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
13
|
+
|
|
14
|
+
# mini-carla
|
|
15
|
+
|
|
16
|
+
A CARLA-compatible traffic simulator without a renderer, written in Rust.
|
|
17
|
+
It speaks LibCarla's **ue58-dev** RPC and streaming protocols, so
|
|
18
|
+
[typesafe_carla](../README.md) (built for `ue58-dev`, `TYPESAFE_CARLA_CARLA_REF=ue58-dev`)
|
|
19
|
+
connects to it exactly as to a CARLA server — and so does any other
|
|
20
|
+
LibCarla client of that branch.
|
|
21
|
+
|
|
22
|
+
In the spirit of Autoware's `simple_planning_simulator`: actors are
|
|
23
|
+
bounding boxes that move kinematically on the HD map's road surface. There
|
|
24
|
+
is no physics engine and no rendering.
|
|
25
|
+
|
|
26
|
+
| | |
|
|
27
|
+
|---|---|
|
|
28
|
+
| Map | OpenDRIVE, read with the [`xodr`](https://crates.io/crates/xodr) crate. Built-in `GridTown` (3x3 junctions, sidewalks, traffic lights, hills), any `.xodr` file, a `--maps-dir`, or `client.generate_opendrive_world(xodr)` |
|
|
29
|
+
| Height | Every vehicle and walker is draped on the road surface (elevation, superelevation, lane heights); vehicles pitch with the grade, and gravity acts along it |
|
|
30
|
+
| Vehicles | Kinematic bicycle model with first-order throttle/brake and steering lags; `VehicleControl` and Ackermann control; lights, doors, physics control (max steer angle, mass) |
|
|
31
|
+
| Traffic Manager | Works unchanged (it runs in the client): lane following, traffic lights, collision avoidance |
|
|
32
|
+
| Walkers | `WalkerControl`, and server-side navigation for `controller.ai.walker` (start/go_to_location/set_max_speed/stop, random sidewalk destinations) |
|
|
33
|
+
| Traffic lights | From the map's signals (`1000001`), grouped per junction, cycling green → yellow → all-red; set state/times, freeze, reset, group queries; vehicles see the light they are stopped at (`is_at_traffic_light`) |
|
|
34
|
+
| Sensors | Bounding-box based: `sensor.other.collision`, `sensor.other.obstacle`, `sensor.other.gnss`, `sensor.other.imu`, `sensor.other.lane_invasion` (client-side) |
|
|
35
|
+
| Not supported | Anything that needs rendering — cameras, LiDAR, radar, G-buffers, textures — is refused at spawn time with an error. Also the recorder/replayer |
|
|
36
|
+
|
|
37
|
+
## Running
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
cargo run --release -- --port 2000 # asynchronous, real time
|
|
41
|
+
cargo run --release -- --sync --fixed-delta 0.05 # the client ticks
|
|
42
|
+
cargo run --release -- --map path/to/Town01.xodr
|
|
43
|
+
cargo run --release -- --maps-dir ~/maps # load_world("Town01") finds ~/maps/Town01.xodr
|
|
44
|
+
cargo run --release -- --dump-map GridTown.xodr # write the built-in map
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
RPC listens on `--port`, the sensor/world streams on `--port + 1`.
|
|
48
|
+
|
|
49
|
+
## Python launcher
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pip install mini-carla # Linux x86_64 / aarch64 wheels, with the executable
|
|
53
|
+
pip install ./simulator # from a checkout: builds the wheel with maturin (needs cargo)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Its version is typesafe-carla's: both are released together
|
|
57
|
+
(`tools/bump_version.py` sets them all).
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from mini_carla import Simulator
|
|
61
|
+
|
|
62
|
+
with Simulator(port=2000, sync=True, fixed_delta=0.05) as sim:
|
|
63
|
+
... # run your typesafe_carla program against localhost:2000
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`Simulator(port=0)` picks a free port pair. From a source checkout without
|
|
67
|
+
installing, `PYTHONPATH=simulator/python` works too: the launcher finds
|
|
68
|
+
`target/release/mini-carla`, or builds it with cargo. There is also a
|
|
69
|
+
command line:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
python -m mini_carla --port 2000 --sync --fixed-delta 0.05
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## With typesafe_carla
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
cmake -S . -B build-carla -DTSC_CARLA_GIT_REF=ue58-dev && cmake --build build-carla -j
|
|
79
|
+
export TYPESAFE_CARLA_LIB=$PWD/build-carla/libtypesafe_carla_ffi.so TYPESAFE_CARLA_CHECK_REF=ue58-dev
|
|
80
|
+
uv run typesafe-codon run examples/traffic.py
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
(With an installed wheel, `TYPESAFE_CARLA_CARLA_REF=ue58-dev` selects the
|
|
84
|
+
matching native library.)
|
|
85
|
+
|
|
86
|
+
## How it is put together
|
|
87
|
+
|
|
88
|
+
- `src/rpc.rs` — rpclib's msgpack-rpc framing and every RPC function LibCarla's
|
|
89
|
+
`client::detail::Client` calls (`Response<T>` / `Metadata` encodings).
|
|
90
|
+
- `src/stream.rs` — LibCarla's streaming protocol (stream id handshake,
|
|
91
|
+
size-prefixed messages); the latest world snapshot is replayed to late
|
|
92
|
+
subscribers so a synchronous `tick()` never waits for a missed frame.
|
|
93
|
+
- `src/world.rs` — actors, kinematics, traffic lights, sensors, and the
|
|
94
|
+
per-frame `EpisodeStateSerializer` snapshot (whole states; traffic lights
|
|
95
|
+
and signs are static actors served by `get_static_actors`, as ue58-dev
|
|
96
|
+
expects).
|
|
97
|
+
- `src/odr.rs` — adapter over `xodr` (lane lookup, heights, signals, spawn
|
|
98
|
+
points); `src/gridmap.rs` generates GridTown.
|
|
99
|
+
- `src/blueprints.rs` — the blueprint library.
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
cargo test
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Compatibility
|
|
106
|
+
|
|
107
|
+
Against typesafe_carla's own server test suite (`tests/test_integration.py`,
|
|
108
|
+
written for a real CARLA server), built for `ue58-dev`: 14 of 25 programs
|
|
109
|
+
pass unchanged. Of the others, 10 stop at the first camera/LiDAR spawn or
|
|
110
|
+
recorder call (by design), and `test_optional_none` walks `get_left_lane()`
|
|
111
|
+
from the first waypoint that has one, which on a two-way single-lane road
|
|
112
|
+
alternates between lanes 1 and -1 forever (LibCarla's `Map::GetLeft`); it
|
|
113
|
+
relies on a CARLA town's road order.
|
|
114
|
+
|
|
115
|
+
With the Traffic Manager driving 24 vehicles on GridTown for 60 s
|
|
116
|
+
(synchronous, 20 Hz), vehicles stay within 5 cm of the lane center on
|
|
117
|
+
average (0.7 m at most, in turns), stop at red lights and never enter a
|
|
118
|
+
junction on red.
|
|
119
|
+
|
|
120
|
+
## Speed
|
|
121
|
+
|
|
122
|
+
Synchronous mode, 0.05 s steps, on a 4-core cloud VM:
|
|
123
|
+
|
|
124
|
+
| | ms per tick | × real time |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| server alone, 36 vehicles + 25 walkers | 0.34 | ~150 |
|
|
127
|
+
| server alone, 300 vehicles + 200 walkers | 1.8 | ~28 |
|
|
128
|
+
| typesafe_carla client, 36 vehicles, own control | 0.67 | ~75 |
|
|
129
|
+
| typesafe_carla client, 36 vehicles under the Traffic Manager + 25 walkers | 2.2 | ~23 |
|
|
130
|
+
|
|
131
|
+
With the Traffic Manager, most of a tick is the TM itself (in the client).
|
|
132
|
+
`cargo test --release bench_tick -- --ignored --nocapture` measures the server.
|
|
133
|
+
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# mini-carla
|
|
2
|
+
|
|
3
|
+
A CARLA-compatible traffic simulator without a renderer, written in Rust.
|
|
4
|
+
It speaks LibCarla's **ue58-dev** RPC and streaming protocols, so
|
|
5
|
+
[typesafe_carla](../README.md) (built for `ue58-dev`, `TYPESAFE_CARLA_CARLA_REF=ue58-dev`)
|
|
6
|
+
connects to it exactly as to a CARLA server — and so does any other
|
|
7
|
+
LibCarla client of that branch.
|
|
8
|
+
|
|
9
|
+
In the spirit of Autoware's `simple_planning_simulator`: actors are
|
|
10
|
+
bounding boxes that move kinematically on the HD map's road surface. There
|
|
11
|
+
is no physics engine and no rendering.
|
|
12
|
+
|
|
13
|
+
| | |
|
|
14
|
+
|---|---|
|
|
15
|
+
| Map | OpenDRIVE, read with the [`xodr`](https://crates.io/crates/xodr) crate. Built-in `GridTown` (3x3 junctions, sidewalks, traffic lights, hills), any `.xodr` file, a `--maps-dir`, or `client.generate_opendrive_world(xodr)` |
|
|
16
|
+
| Height | Every vehicle and walker is draped on the road surface (elevation, superelevation, lane heights); vehicles pitch with the grade, and gravity acts along it |
|
|
17
|
+
| Vehicles | Kinematic bicycle model with first-order throttle/brake and steering lags; `VehicleControl` and Ackermann control; lights, doors, physics control (max steer angle, mass) |
|
|
18
|
+
| Traffic Manager | Works unchanged (it runs in the client): lane following, traffic lights, collision avoidance |
|
|
19
|
+
| Walkers | `WalkerControl`, and server-side navigation for `controller.ai.walker` (start/go_to_location/set_max_speed/stop, random sidewalk destinations) |
|
|
20
|
+
| Traffic lights | From the map's signals (`1000001`), grouped per junction, cycling green → yellow → all-red; set state/times, freeze, reset, group queries; vehicles see the light they are stopped at (`is_at_traffic_light`) |
|
|
21
|
+
| Sensors | Bounding-box based: `sensor.other.collision`, `sensor.other.obstacle`, `sensor.other.gnss`, `sensor.other.imu`, `sensor.other.lane_invasion` (client-side) |
|
|
22
|
+
| Not supported | Anything that needs rendering — cameras, LiDAR, radar, G-buffers, textures — is refused at spawn time with an error. Also the recorder/replayer |
|
|
23
|
+
|
|
24
|
+
## Running
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
cargo run --release -- --port 2000 # asynchronous, real time
|
|
28
|
+
cargo run --release -- --sync --fixed-delta 0.05 # the client ticks
|
|
29
|
+
cargo run --release -- --map path/to/Town01.xodr
|
|
30
|
+
cargo run --release -- --maps-dir ~/maps # load_world("Town01") finds ~/maps/Town01.xodr
|
|
31
|
+
cargo run --release -- --dump-map GridTown.xodr # write the built-in map
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
RPC listens on `--port`, the sensor/world streams on `--port + 1`.
|
|
35
|
+
|
|
36
|
+
## Python launcher
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
pip install mini-carla # Linux x86_64 / aarch64 wheels, with the executable
|
|
40
|
+
pip install ./simulator # from a checkout: builds the wheel with maturin (needs cargo)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Its version is typesafe-carla's: both are released together
|
|
44
|
+
(`tools/bump_version.py` sets them all).
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from mini_carla import Simulator
|
|
48
|
+
|
|
49
|
+
with Simulator(port=2000, sync=True, fixed_delta=0.05) as sim:
|
|
50
|
+
... # run your typesafe_carla program against localhost:2000
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`Simulator(port=0)` picks a free port pair. From a source checkout without
|
|
54
|
+
installing, `PYTHONPATH=simulator/python` works too: the launcher finds
|
|
55
|
+
`target/release/mini-carla`, or builds it with cargo. There is also a
|
|
56
|
+
command line:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
python -m mini_carla --port 2000 --sync --fixed-delta 0.05
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## With typesafe_carla
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
cmake -S . -B build-carla -DTSC_CARLA_GIT_REF=ue58-dev && cmake --build build-carla -j
|
|
66
|
+
export TYPESAFE_CARLA_LIB=$PWD/build-carla/libtypesafe_carla_ffi.so TYPESAFE_CARLA_CHECK_REF=ue58-dev
|
|
67
|
+
uv run typesafe-codon run examples/traffic.py
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
(With an installed wheel, `TYPESAFE_CARLA_CARLA_REF=ue58-dev` selects the
|
|
71
|
+
matching native library.)
|
|
72
|
+
|
|
73
|
+
## How it is put together
|
|
74
|
+
|
|
75
|
+
- `src/rpc.rs` — rpclib's msgpack-rpc framing and every RPC function LibCarla's
|
|
76
|
+
`client::detail::Client` calls (`Response<T>` / `Metadata` encodings).
|
|
77
|
+
- `src/stream.rs` — LibCarla's streaming protocol (stream id handshake,
|
|
78
|
+
size-prefixed messages); the latest world snapshot is replayed to late
|
|
79
|
+
subscribers so a synchronous `tick()` never waits for a missed frame.
|
|
80
|
+
- `src/world.rs` — actors, kinematics, traffic lights, sensors, and the
|
|
81
|
+
per-frame `EpisodeStateSerializer` snapshot (whole states; traffic lights
|
|
82
|
+
and signs are static actors served by `get_static_actors`, as ue58-dev
|
|
83
|
+
expects).
|
|
84
|
+
- `src/odr.rs` — adapter over `xodr` (lane lookup, heights, signals, spawn
|
|
85
|
+
points); `src/gridmap.rs` generates GridTown.
|
|
86
|
+
- `src/blueprints.rs` — the blueprint library.
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
cargo test
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Compatibility
|
|
93
|
+
|
|
94
|
+
Against typesafe_carla's own server test suite (`tests/test_integration.py`,
|
|
95
|
+
written for a real CARLA server), built for `ue58-dev`: 14 of 25 programs
|
|
96
|
+
pass unchanged. Of the others, 10 stop at the first camera/LiDAR spawn or
|
|
97
|
+
recorder call (by design), and `test_optional_none` walks `get_left_lane()`
|
|
98
|
+
from the first waypoint that has one, which on a two-way single-lane road
|
|
99
|
+
alternates between lanes 1 and -1 forever (LibCarla's `Map::GetLeft`); it
|
|
100
|
+
relies on a CARLA town's road order.
|
|
101
|
+
|
|
102
|
+
With the Traffic Manager driving 24 vehicles on GridTown for 60 s
|
|
103
|
+
(synchronous, 20 Hz), vehicles stay within 5 cm of the lane center on
|
|
104
|
+
average (0.7 m at most, in turns), stop at red lights and never enter a
|
|
105
|
+
junction on red.
|
|
106
|
+
|
|
107
|
+
## Speed
|
|
108
|
+
|
|
109
|
+
Synchronous mode, 0.05 s steps, on a 4-core cloud VM:
|
|
110
|
+
|
|
111
|
+
| | ms per tick | × real time |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| server alone, 36 vehicles + 25 walkers | 0.34 | ~150 |
|
|
114
|
+
| server alone, 300 vehicles + 200 walkers | 1.8 | ~28 |
|
|
115
|
+
| typesafe_carla client, 36 vehicles, own control | 0.67 | ~75 |
|
|
116
|
+
| typesafe_carla client, 36 vehicles under the Traffic Manager + 25 walkers | 2.2 | ~23 |
|
|
117
|
+
|
|
118
|
+
With the Traffic Manager, most of a tick is the TM itself (in the client).
|
|
119
|
+
`cargo test --release bench_tick -- --ignored --nocapture` measures the server.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# typesafe_carla against mini-carla: a vehicle climbs GridTown's
|
|
2
|
+
# hills under the Traffic Manager while bounding-box sensors report, and a
|
|
3
|
+
# camera (which needs rendering) is refused.
|
|
4
|
+
#
|
|
5
|
+
# python -m mini_carla --port 2000 &
|
|
6
|
+
# TYPESAFE_CARLA_CARLA_REF=ue58-dev uv run typesafe-codon run simulator/examples/hills_and_sensors.py
|
|
7
|
+
import typesafe_carla as carla
|
|
8
|
+
|
|
9
|
+
client = carla.Client("localhost", 2000)
|
|
10
|
+
client.set_timeout(10.0)
|
|
11
|
+
world = client.get_world()
|
|
12
|
+
lib = world.get_blueprint_library()
|
|
13
|
+
tm = client.get_trafficmanager(8000)
|
|
14
|
+
|
|
15
|
+
settings = world.get_settings()
|
|
16
|
+
settings.synchronous_mode = True
|
|
17
|
+
settings.fixed_delta_seconds = 0.05
|
|
18
|
+
world.apply_settings(settings)
|
|
19
|
+
tm.set_synchronous_mode(True)
|
|
20
|
+
|
|
21
|
+
spawned = List[int]()
|
|
22
|
+
try:
|
|
23
|
+
ego = world.spawn_actor(lib.find("vehicle.tesla.model3"), world.get_map().get_spawn_points()[0]).as_vehicle()
|
|
24
|
+
spawned.append(ego.id)
|
|
25
|
+
ego.set_autopilot(True, tm.get_port())
|
|
26
|
+
imu = world.spawn_actor(lib.find("sensor.other.imu"), carla.Transform(), attach_to=ego).as_sensor()
|
|
27
|
+
gnss = world.spawn_actor(lib.find("sensor.other.gnss"), carla.Transform(), attach_to=ego).as_sensor()
|
|
28
|
+
spawned.append(imu.id)
|
|
29
|
+
spawned.append(gnss.id)
|
|
30
|
+
imu.listen()
|
|
31
|
+
gnss.listen()
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
world.spawn_actor(lib.find("sensor.camera.rgb"), carla.Transform(), attach_to=ego)
|
|
35
|
+
print("unexpected: a camera spawned")
|
|
36
|
+
except carla.CarlaError as e:
|
|
37
|
+
print("camera refused:", str(e)[:60], "...")
|
|
38
|
+
|
|
39
|
+
min_z = 1e9
|
|
40
|
+
max_z = -1e9
|
|
41
|
+
max_pitch = 0.0
|
|
42
|
+
for step in range(600):
|
|
43
|
+
world.tick()
|
|
44
|
+
t = ego.get_transform()
|
|
45
|
+
min_z = min(min_z, t.location.z)
|
|
46
|
+
max_z = max(max_z, t.location.z)
|
|
47
|
+
max_pitch = max(max_pitch, abs(t.rotation.pitch))
|
|
48
|
+
if step % 100 == 99:
|
|
49
|
+
acc = imu.wait_for_data(2.0).as_imu()
|
|
50
|
+
fix = gnss.wait_for_data(2.0).as_gnss()
|
|
51
|
+
print("t", step * 0.05 + 0.05, "s z", t.location.z, " speed", ego.get_velocity().length(),
|
|
52
|
+
" imu.az", acc.accelerometer.z, " lat", fix.latitude)
|
|
53
|
+
print("height range", min_z, "..", max_z, "m, max pitch", max_pitch, "deg")
|
|
54
|
+
finally:
|
|
55
|
+
tm.set_synchronous_mode(False)
|
|
56
|
+
settings.synchronous_mode = False
|
|
57
|
+
world.apply_settings(settings)
|
|
58
|
+
client.apply_batch([carla.command.DestroyActor(i) for i in reversed(spawned)])
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.5,<2"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mini-carla"
|
|
7
|
+
# The version is Cargo.toml's, which tools/bump_version.py keeps equal to
|
|
8
|
+
# typesafe-carla's: both are released together.
|
|
9
|
+
dynamic = ["version"]
|
|
10
|
+
description = "A CARLA-compatible (LibCarla ue58-dev protocol) traffic simulator without rendering, for typesafe_carla"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
license = "MIT"
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
keywords = ["carla", "simulation", "traffic", "opendrive"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Rust",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Operating System :: POSIX :: Linux",
|
|
19
|
+
"Topic :: Scientific/Engineering",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[tool.maturin]
|
|
23
|
+
# Ships the Rust executable (mini-carla) in the wheel's scripts and
|
|
24
|
+
# the Python launcher package beside it.
|
|
25
|
+
bindings = "bin"
|
|
26
|
+
python-source = "python"
|
|
27
|
+
module-name = "mini_carla"
|
|
28
|
+
strip = true
|