MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / tick

Method tick

roach/criteria/run_stop_sign.py:23–73  ·  view source on GitHub ↗
(self, vehicle, timestamp)

Source from the content-addressed store, hash-verified

21 self._affected_by_stop = False
22
23 def tick(self, vehicle, timestamp):
24 info = None
25 ev_loc = vehicle.get_location()
26 ev_f_vec = vehicle.get_transform().get_forward_vector()
27
28 if self._target_stop_sign is None:
29 self._target_stop_sign = self._scan_for_stop_sign(vehicle.get_transform())
30 if self._target_stop_sign is not None:
31 stop_loc = self._target_stop_sign.get_location()
32 # info = {
33 # 'event': 'encounter',
34 # 'step': timestamp['step'],
35 # 'simulation_time': timestamp['relative_simulation_time'],
36 # 'id': self._target_stop_sign.id,
37 # 'stop_loc': [stop_loc.x, stop_loc.y, stop_loc.z],
38 # 'ev_loc': [ev_loc.x, ev_loc.y, ev_loc.z]
39 # }
40 else:
41 # we were in the middle of dealing with a stop sign
42 if not self._stop_completed:
43 # did the ego-vehicle stop?
44 current_speed = self._calculate_speed(vehicle.get_velocity())
45 if current_speed < self._speed_threshold:
46 self._stop_completed = True
47
48 if not self._affected_by_stop:
49 stop_t = self._target_stop_sign.get_transform()
50 transformed_tv = stop_t.transform(self._target_stop_sign.trigger_volume.location)
51 stop_extent = self._target_stop_sign.trigger_volume.extent
52 if self.point_inside_boundingbox(ev_loc, transformed_tv, stop_extent):
53 self._affected_by_stop = True
54
55 if not self.is_affected_by_stop(ev_loc, self._target_stop_sign):
56 # is the vehicle out of the influence of this stop sign now?
57 if not self._stop_completed and self._affected_by_stop:
58 # did we stop?
59 stop_loc = self._target_stop_sign.get_transform().location
60 # info = {
61 # 'event': 'run',
62 # 'step': timestamp['step'],
63 # 'simulation_time': timestamp['relative_simulation_time'],
64 # 'id': self._target_stop_sign.id,
65 # 'stop_loc': [stop_loc.x, stop_loc.y, stop_loc.z],
66 # 'ev_loc': [ev_loc.x, ev_loc.y, ev_loc.z]
67 # }
68 # reset state
69 self._target_stop_sign = None
70 self._stop_completed = False
71 self._affected_by_stop = False
72
73 # return info
74
75 def _scan_for_stop_sign(self, vehicle_transform):
76 target_stop_sign = None

Callers

nothing calls this directly

Calls 7

_scan_for_stop_signMethod · 0.95
_calculate_speedMethod · 0.95
is_affected_by_stopMethod · 0.95
get_locationMethod · 0.80
get_transformMethod · 0.80
get_velocityMethod · 0.80

Tested by

no test coverage detected