Measuring Lane Deviation #8825
Unanswered
jpgarrett17
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a program to track takeover smoothness in the case of automation failure by tracking the users ability to stay in their lane correctly when they obtain control, and I've looked at the documentation and currently have an implementation of this using waypoints
vehicle_location = self.player.get_location()
waypoint = self.world.get_map().get_waypoint(vehicle_location)
lane_center = waypoint.transform.location
forward = waypoint.transform.get_forward_vector()
right = carla.Vector3D(x=-forward.y, y=forward.x, z=0)
right_dir = right / math.sqrt(right.x ** 2 + right.y ** 2 + right.z ** 2)
diff = vehicle_location - lane_center
lateral_dist = abs(diff.x * right_dir.x + diff.y * right_dir.y)
lane_width = waypoint.lane_width
deviation_percentage = (lateral_dist / (lane_width / 2)) * 100
return lateral_dist
Beta Was this translation helpful? Give feedback.
All reactions