18
18
from typing import Any
19
19
from typing import TYPE_CHECKING
20
20
21
+ from autoware_adapi_v1_msgs .srv import InitializeLocalization
21
22
from autoware_auto_perception_msgs .msg import ObjectClassification
22
23
from builtin_interfaces .msg import Time as Stamp
23
24
from geometry_msgs .msg import Point
43
44
from tf2_ros import TransformException
44
45
from tf2_ros import TransformListener
45
46
from tf_transformations import euler_from_quaternion
46
- from tier4_localization_msgs .srv import InitializeLocalization
47
47
from tier4_localization_msgs .srv import PoseWithCovarianceStamped as PoseWithCovarianceStampedSrv
48
48
import yaml
49
49
53
53
from driving_log_replayer .scenario import load_scenario
54
54
55
55
if TYPE_CHECKING :
56
- from autoware_common_msgs .msg import ResponseStatus
56
+ from autoware_adapi_v1_msgs .msg import ResponseStatus
57
57
58
58
59
59
class DLREvaluator (Node ):
@@ -107,10 +107,9 @@ def __init__(self, name: str, scenario_class: Callable, result_class: Callable)
107
107
self ._tf_buffer = Buffer ()
108
108
self ._tf_listener = TransformListener (self ._tf_buffer , self , spin_thread = True )
109
109
110
- # initial pose estimation
111
110
self ._initial_pose_running : bool = False
112
111
self ._initial_pose_success : bool = False
113
- self ._initial_pose , self . _initial_pose_method = self .set_initial_pose ()
112
+ self ._initial_pose = self .set_initial_pose ()
114
113
self .start_initialpose_service ()
115
114
116
115
self ._current_time = Time ().to_msg ()
@@ -175,20 +174,17 @@ def start_initialpose_service(self) -> None:
175
174
return
176
175
self ._initial_pose_client = self .create_client (
177
176
InitializeLocalization ,
178
- "/localization/initialize" ,
177
+ "/api/ localization/initialize" ,
179
178
)
179
+ self ._map_fit_client = self .create_client (
180
+ PoseWithCovarianceStampedSrv ,
181
+ "/map/map_height_fitter/service" ,
182
+ )
183
+
180
184
while not self ._initial_pose_client .wait_for_service (timeout_sec = 1.0 ):
181
185
self .get_logger ().warning ("initial pose service not available, waiting again..." )
182
-
183
- if self ._initial_pose_method == InitializeLocalization .Request .AUTO :
184
- self ._map_fit_client = self .create_client (
185
- PoseWithCovarianceStampedSrv ,
186
- "/map/map_height_fitter/service" ,
187
- )
188
- while not self ._map_fit_client .wait_for_service (timeout_sec = 1.0 ):
189
- self .get_logger ().warning (
190
- "map height fitter service not available, waiting again..." ,
191
- )
186
+ while not self ._map_fit_client .wait_for_service (timeout_sec = 1.0 ):
187
+ self .get_logger ().warning ("map height fitter service not available, waiting again..." )
192
188
193
189
def call_initialpose_service (self ) -> None :
194
190
if self ._initial_pose is None or self ._initial_pose_success or self ._initial_pose_running :
@@ -198,29 +194,17 @@ def call_initialpose_service(self) -> None:
198
194
)
199
195
self ._initial_pose_running = True
200
196
self ._initial_pose .header .stamp = self ._current_time
201
- if self ._initial_pose_method == InitializeLocalization .Request .AUTO :
202
- future_map_fit = self ._map_fit_client .call_async (
203
- PoseWithCovarianceStampedSrv .Request (pose_with_covariance = self ._initial_pose ),
204
- )
205
- future_map_fit .add_done_callback (self .map_fit_cb )
206
- else :
207
- future_direct_init_pose = self ._initial_pose_client .call_async (
208
- InitializeLocalization .Request (
209
- method = self ._initial_pose_method ,
210
- pose_with_covariance = [self ._initial_pose ],
211
- ),
212
- )
213
- future_direct_init_pose .add_done_callback (self .initial_pose_cb )
197
+ future_map_fit = self ._map_fit_client .call_async (
198
+ PoseWithCovarianceStampedSrv .Request (pose_with_covariance = self ._initial_pose ),
199
+ )
200
+ future_map_fit .add_done_callback (self .map_fit_cb )
214
201
215
202
def map_fit_cb (self , future : Future ) -> None :
216
203
result = future .result ()
217
204
if result is not None :
218
205
if result .success :
219
206
future_init_pose = self ._initial_pose_client .call_async (
220
- InitializeLocalization .Request (
221
- method = self ._initial_pose_method ,
222
- pose_with_covariance = [result .pose_with_covariance ],
223
- ),
207
+ InitializeLocalization .Request (pose = [result .pose_with_covariance ]),
224
208
)
225
209
future_init_pose .add_done_callback (self .initial_pose_cb )
226
210
else :
@@ -283,17 +267,12 @@ def transform_stamped_with_euler_angle(cls, transform_stamped: TransformStamped)
283
267
}
284
268
return tf_euler
285
269
286
- def set_initial_pose (self ) -> tuple [PoseWithCovarianceStamped | None , int | None ]:
287
- auto_pose = getattr (self ._scenario .Evaluation , "InitialPose" , None )
288
- direct_pose = getattr (self ._scenario .Evaluation , "DirectInitialPose" , None )
289
- if auto_pose is None and direct_pose is None :
290
- return None , None
291
- if auto_pose is not None :
292
- initial_pose : InitialPose = auto_pose
293
- pose_method : int = InitializeLocalization .Request .AUTO
294
- if direct_pose is not None :
295
- initial_pose : InitialPose = direct_pose
296
- pose_method : int = InitializeLocalization .Request .DIRECT
270
+ def set_initial_pose (self ) -> PoseWithCovarianceStamped | None :
271
+ if not hasattr (self ._scenario .Evaluation , "InitialPose" ):
272
+ return None
273
+ if self ._scenario .Evaluation .InitialPose is None :
274
+ return None
275
+ initial_pose : InitialPose = self ._scenario .Evaluation .InitialPose
297
276
covariance = np .array (
298
277
[
299
278
0.25 ,
@@ -341,7 +320,7 @@ def set_initial_pose(self) -> tuple[PoseWithCovarianceStamped | None, int | None
341
320
),
342
321
covariance = covariance ,
343
322
)
344
- return PoseWithCovarianceStamped (header = Header (frame_id = "map" ), pose = pose ), pose_method
323
+ return PoseWithCovarianceStamped (header = Header (frame_id = "map" ), pose = pose )
345
324
346
325
@classmethod
347
326
def get_perception_label_str (cls , classification : ObjectClassification ) -> str :
0 commit comments