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

Method _get_forward_speed

leaderboard/team_code/auto_pilot.py:228–240  ·  view source on GitHub ↗

Convert the vehicle transform directly to forward speed

(self, transform=None, velocity=None)

Source from the content-addressed store, hash-verified

226 return am_ab > 0 and am_ab < ab_ab and am_ad > 0 and am_ad < ad_ad
227
228 def _get_forward_speed(self, transform=None, velocity=None):
229 """ Convert the vehicle transform directly to forward speed """
230 if not velocity:
231 velocity = self._vehicle.get_velocity()
232 if not transform:
233 transform = self._vehicle.get_transform()
234
235 vel_np = np.array([velocity.x, velocity.y, velocity.z])
236 pitch = np.deg2rad(transform.rotation.pitch)
237 yaw = np.deg2rad(transform.rotation.yaw)
238 orientation = np.array([np.cos(pitch) * np.cos(yaw), np.cos(pitch) * np.sin(yaw), np.sin(pitch)])
239 speed = np.dot(vel_np, orientation)
240 return speed
241
242 def _is_actor_affected_by_stop(self, actor, stop, multi_step=20):
243 """

Callers 1

_is_stop_sign_hazardMethod · 0.95

Calls 3

get_velocityMethod · 0.80
get_transformMethod · 0.80
dotMethod · 0.80

Tested by

no test coverage detected