carla-driver-interface 2.4.1__tar.gz → 2.5.0__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.
Files changed (34) hide show
  1. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/PKG-INFO +1 -1
  2. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/pyproject.toml +1 -1
  3. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/pyproject.toml.orig +1 -1
  4. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/t4_scene.py +49 -10
  5. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/LICENSE +0 -0
  6. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/README.md +0 -0
  7. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/__init__.py +0 -0
  8. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/__init__.py +0 -0
  9. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/carla_driver_pb2.py +0 -0
  10. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/carla_driver_pb2.pyi +0 -0
  11. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/carla_driver_pb2_grpc.py +0 -0
  12. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/common_pb2.py +0 -0
  13. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/common_pb2.pyi +0 -0
  14. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/egodriver_pb2.py +0 -0
  15. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/egodriver_pb2.pyi +0 -0
  16. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/egodriver_pb2_grpc.py +0 -0
  17. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/sensorsim_pb2.py +0 -0
  18. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/_proto/sensorsim_pb2.pyi +0 -0
  19. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/alpasim.py +0 -0
  20. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/cli.py +0 -0
  21. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/contract.py +0 -0
  22. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/driver.py +0 -0
  23. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/geometry.py +0 -0
  24. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/hdmap.py +0 -0
  25. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/inprocess.py +0 -0
  26. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/policies/__init__.py +0 -0
  27. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/policies/constant_speed.py +0 -0
  28. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/policies/route_follower.py +0 -0
  29. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/polyline.py +0 -0
  30. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/protocol.py +0 -0
  31. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/py.typed +0 -0
  32. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/server.py +0 -0
  33. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/service.py +0 -0
  34. {carla_driver_interface-2.4.1 → carla_driver_interface-2.5.0}/src/carla_driver_interface/testing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: carla-driver-interface
3
- Version: 2.4.1
3
+ Version: 2.5.0
4
4
  Summary: Both ends of alpasim's egodriver gRPC contract: serve a driving policy, or drive one without CARLA
5
5
  Author: Masaya Kataoka
6
6
  Author-email: Masaya Kataoka <ms.kataoka@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "carla-driver-interface"
3
- version = "2.4.1"
3
+ version = "2.5.0"
4
4
  description = "Both ends of alpasim's egodriver gRPC contract: serve a driving policy, or drive one without CARLA"
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "carla-driver-interface"
3
- version = "2.4.1"
3
+ version = "2.5.0"
4
4
  description = "Both ends of alpasim's egodriver gRPC contract: serve a driving policy, or drive one without CARLA"
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -1,7 +1,8 @@
1
1
  """A policy fed T4Scenes: :class:`T4SceneDriver`, a :class:`BaseDriver` like any other.
2
2
 
3
3
  tier4/e2e-devkit wraps a trained model as a *T4 driver*
4
- (``t4_e2e_devkit.driver.AbstractT4Driver``): a ``T4Scene`` goes in, an
4
+ (``t4_e2e_devkit.driver.T4Driver``; ``AbstractT4Driver`` before it): a
5
+ ``T4Scene`` goes in, an
5
6
  ego-frame plan comes out, and the model is fed exactly the window it was
6
7
  trained on. :class:`T4SceneDriver` puts one behind the egodriver contract.
7
8
  The runtime sends the rollout so far as a scene with every drive
@@ -52,6 +53,13 @@ def scene_proto() -> Any:
52
53
 
53
54
  logger = logging.getLogger(__name__)
54
55
 
56
+ #: The devkit's public turn indicators that are commands here: disabled, left
57
+ #: and right, the same values as :class:`TurnIndicator`'s. Unknown and hazard
58
+ #: are no command.
59
+ _COMMANDS = frozenset(
60
+ (TurnIndicator.DISABLE, TurnIndicator.ENABLE_LEFT, TurnIndicator.ENABLE_RIGHT)
61
+ )
62
+
55
63
  #: The map set format holding the scene's map resource: a serialized
56
64
  #: ``t4_e2e_devkit`` ``MapResource`` (Lanelet2 OSM in Autoware's ``map`` frame).
57
65
  T4_MAP_FORMAT = "t4"
@@ -61,7 +69,8 @@ class T4SceneDriver(BaseDriver):
61
69
  """Drives with a devkit T4 driver over the scene the runtime sends.
62
70
 
63
71
  Args:
64
- scene_driver: The model, as a ``t4_e2e_devkit.driver.AbstractT4Driver``.
72
+ scene_driver: The model, as a ``t4_e2e_devkit.driver.T4Driver`` (or an
73
+ ``AbstractT4Driver`` of an earlier devkit).
65
74
  map_dir: Your copy of the runtime's ``driver.map_dir``, where the scene's
66
75
  map resource is (the ``t4`` format); ``None`` for a model that reads
67
76
  no map.
@@ -69,10 +78,14 @@ class T4SceneDriver(BaseDriver):
69
78
 
70
79
  The plan the T4 driver returns is in the ego frame of the scene's current
71
80
  row, the rig at ``time_now_us``; pose ``i`` is ``(i + 1)`` sampling
72
- intervals later. Its ``extras`` may carry ``turn_indicator`` (an
73
- :class:`TurnIndicator` value) and ``debug_scalars`` (a ``str -> float``
74
- mapping), which the result passes on; the servicer drops a value of
75
- either it cannot send, keeping the plan.
81
+ intervals later. A devkit ``Driver`` (tier4/e2e-devkit#141) returns it as
82
+ its ``DriverOutput``'s ``planner_output``: the turn indicator is that
83
+ output's ``turn_indicator`` (the devkit's public vocabulary, whose
84
+ disabled / left / right are :class:`TurnIndicator`'s values; ``None`` or
85
+ unknown is no command), and ``debug_scalars`` (a ``str -> float``
86
+ mapping) its ``extra``'s. An earlier ``T4Driver``'s output carries both
87
+ in its ``extras``. The result passes them on; the servicer drops a value
88
+ of either it cannot send, keeping the plan.
76
89
 
77
90
  One drive at a time: a T4 driver holds a model and per-session state that
78
91
  concurrent drives would share.
@@ -89,7 +102,12 @@ class T4SceneDriver(BaseDriver):
89
102
  ) -> None:
90
103
  self.scene_driver = scene_driver
91
104
  self.map_dir = map_dir
92
- self.name = name if name is not None else str(scene_driver.name())
105
+ if name is None:
106
+ # A T4Driver names itself with an attribute; an AbstractT4Driver
107
+ # of an earlier devkit, with a method.
108
+ named = scene_driver.name
109
+ name = named() if callable(named) else named
110
+ self.name = str(name)
93
111
  #: The map resources registered, one store for every map.
94
112
  self._store: Any = None
95
113
  #: Each map set's resource, read once, by map id.
@@ -141,7 +159,7 @@ class T4SceneDriver(BaseDriver):
141
159
 
142
160
  def result(self, output: Any, ctx: DriveContext) -> DriveResult:
143
161
  """A T4 driver's ``DriverOutput`` as the egodriver's result, in the rig frame."""
144
- trajectory = output.trajectory
162
+ trajectory, extras, indicator = self._plan_of(output)
145
163
  poses = np.asarray(trajectory.poses, dtype=np.float64)
146
164
  if poses.ndim != 2 or poses.shape[1] != 3:
147
165
  raise ValueError(
@@ -160,13 +178,34 @@ class T4SceneDriver(BaseDriver):
160
178
  plan.append(
161
179
  ctx.time_now_us + index * step_us, Pose.from_xyz_yaw(x, y, 0.0, yaw)
162
180
  )
163
- extras = output.extras or {}
164
181
  return DriveResult(
165
182
  trajectory_in_rig=plan,
166
- turn_indicator=extras.get("turn_indicator", TurnIndicator.NO_COMMAND),
183
+ turn_indicator=indicator,
167
184
  debug_scalars=dict(extras.get("debug_scalars") or {}),
168
185
  )
169
186
 
187
+ def _plan_of(self, output: Any) -> tuple[Any, Dict[str, Any], Any]:
188
+ """``(trajectory, extras, turn indicator)`` of either devkit's output."""
189
+ if not hasattr(output, "planner_output"):
190
+ # An earlier T4Driver's: the plan, and both values in its extras.
191
+ extras = output.extras or {}
192
+ return (
193
+ output.trajectory,
194
+ extras,
195
+ extras.get("turn_indicator", TurnIndicator.NO_COMMAND),
196
+ )
197
+ planned = output.planner_output
198
+ if planned is None:
199
+ raise ValueError(
200
+ f"{self.name} returned no plan: the egodriver contract carries plans, "
201
+ "not control commands"
202
+ )
203
+ public = planned.turn_indicator
204
+ commanded = TurnIndicator.NO_COMMAND
205
+ if public is not None and int(public) in _COMMANDS:
206
+ commanded = TurnIndicator(int(public))
207
+ return planned.trajectory, dict(planned.extra or {}), commanded
208
+
170
209
  def _map_store(self, map_files: Optional["MapFiles"]) -> Any:
171
210
  """The store holding the step's map resource; ``None`` without a map set.
172
211