Closed krdindorkar19 closed 5 years ago
Hi , I'm also looking for this issue, as I require lane coordinates either in world coordinate or local coordinate system. Just that the map is saved in opendrive format , but the lane coordinates are not provided. It would be better if we have lane coordinates for processing as well.
As far as i know, at the moment it is not possible. But you can do it yourself using original opendrive File .xodr. There are list of road segments and list of lanes and markings for each segment. see https://github.com/carla-simulator/carla/issues/1082, there i got it from xodr and draw on camera image
Instead of using sensor.other.lane_detector
, I think you can easily implement this using the Waypoint API that works on carla.Map
.
@YashBansod can you explain how we will get lane's co-ordinates from waypoint api
# Get the carla.Map object from carla.World using
carla_map = world.get_map()
# Get the location of the ego vehicle using
ego_location = player.get_location()
# Get the waypoint on the lane closest to the ego vehicle using
waypoint = carla_map.get_waypoint(ego_location)
# Get the next waypoint(s) at particular distance using
waypoint.next(distance)
@krdindorkar19 you can always refer Carla's Documentation and Python API reference for full usage of their APIs.
@YashBansod: Few questions on this.
Please help on this regard.
@aravindSwamy94
If there was some way to get the topology of the route that the ego vehicle is following (or it is going to follow in the autopilot mode) , it would be great indeed. Unfortunately I do not know if this is already possible to do so with the current API. Maybe CARLA's members would know for sure. I will create an Issue for this since this is something I have wanted to know for quite some time.
Regarding my suggestion on using the Waypoint API, the waypoints contain their transform (therefore their orientation is known) and the lane width is also provided. You can use this information to get the boundaries of the lane at that point. You can repeat this step for the next waypoint.
@YashBansod : Thanks for your reply.
I would also like to have a look at @Unlingius code for this, if he is okay to share with us.
Also, reading directly from openDrive file is one way to do this, which is more similar to a complete module like HDMap lane provider module. But can we get the lane information with carla API's
I have few doubts regarding this, For example, consider my ego position is in road 71 and lane id as -2. I can get the lane information for the same (road 71 and lane -2) by the method what u have suggested. But is there any way we can get the lane information for my neighbor lane(road 71, lane -1). For this information, we need a waypoint from the same lane . Is there any possible way to get a waypoint of the subsequent lane, I came to know that this can be done by reading the openDrive file, but can we do this with any possible combinations of API ?
@aravindSwamy94 I believe you can do that using the Carla's Waypoint API. I call tell you the pseudo code for the same:
# 1. Get the carla.Map object from carla.World using
carla_map = world.get_map()
# 2. Get all the waypoints in the map at say 1 meter distance
all_waypoints = carla_map.generate_waypoints(distance=1.0)
# 3. Get the location of the ego_vehicle
location = player.get_location()
# 4. Compute the the Waypoint closes to the ego_vehicle
nearest_waypoint = carla_map.get_waypoint(location, project_to_road=True)
# 5. Find the closest waypoint to the `nearest_waypoint` in `all_waypoints`. Make sure the Road and Lane IDs are same.
waypoint_on_map = get_nearest_waypoint_same_lane(nearest_waypoint, all_waypoints)
# 6. Find the closest waypoints to the adjacent lane of the `waypoint_on_map`. For this you narrow down your list to waypoints with same road id as `waypoint_on_map` but lane id equal to +1 or -1 of the lane id of `waypoint_on_map`.
adj_wayp_on_map_m1, adj_wayp_on_map_p1 = get_nearest_waypoint_adj_lanes(waypoint_on_map, all_waypoints)
I hope this helps. :penguin:
adj_wayp_on_map_m1, adj_wayp_on_map_p1 = get_nearest_waypoint_adj_lanes(waypoint_on_map, all_waypoints)
You can do:
left_lane_waypoint = waypoint.get_left_lane()
right_lane_waypoint = waypoint.get_right_lane()
Note the it could return None if there is no adjacent lanes.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@YashBansod @TDHTTTT How do you calculate the deviation of the car from the centre of the road?
# Get the carla.Map object from carla.World using carla_map = world.get_map() # Get the location of the ego vehicle using ego_location = player.get_location() # Get the waypoint on the lane closest to the ego vehicle using waypoint = carla_map.get_waypoint(ego_location) # Get the next waypoint(s) at particular distance using waypoint.next(distance)
@krdindorkar19 you can always refer Carla's Documentation and Python API reference for full usage of their APIs.
Hello @YashBansod . Is it possible to spawn these points back in the simulator? I have some problem while dealing with waypoint.next transform.