Carla: Distance from Centre of Lane?

Created on 20 Nov 2017  Â·  11Comments  Â·  Source: carla-simulator/carla

Any pointers on where we would start if we wanted to collect something other than the current PlayerMeasurements? For example, I'd really like to be able to get the distance from the centre of the lane.

documentation question stale

Most helpful comment

@WenchaoDing
Indeed the orientation of the lanes is encoded in the third value (second index) of the RGB-value.
You can observe this, when you pick this value of a specific point of a turn in the road (e.g. "Town01Lanes.png") and perform a small variation.

All 11 comments

Yes, I am interested in this too.
Other measurements would be helpful as well, e.g. the output from the AI controller function IsThereAnObstacleAhead()

@yanii That is not currently available. However on the next release we will give users access to a map. That will allow you to get the car position within the lane. This is probably helpful for your needs. To get access early watch the "new_client_api" branch. It will be there by today or tommorrow.

@xl-sr We try to provide only primary measurements. You could program the IsThereAnObstacleAhead function by getting the player's position and orientation and comparing with the position of all agents in the simulator.

@xl-sr IsThereAnObstacleAhead() is an internal function fine-tuned for the current autopilot and its results may not be very intuitive. Like there are several magic numbers that just work with the current autopilot, only detects dynamic obstacles, and detects pedestrians way before they are on the road.

ok thanks. I think the approach of comparing the agents positions will give me what I want to achieve.

Hi @felipecode ,

I am writing some function to calculate the distance to the lane left boundary and the right boundary, and I notice your implementation:

ori = self.map_image_lanes[int(pixel[1]), int(pixel[0]), 2]

ori = ((float(ori) / 255.0)) * 2 * math.pi

return (-math.cos(ori), -math.sin(ori))

I am confused about why you can obtain the lane orientation by reading from one channel of the image. Is there any format encoded? Could you please provide any hint on how to implement my function efficiently? Thanks in advance.

@WenchaoDing
Indeed the orientation of the lanes is encoded in the third value (second index) of the RGB-value.
You can observe this, when you pick this value of a specific point of a turn in the road (e.g. "Town01Lanes.png") and perform a small variation.

Yes, the image has encoded the information of the road
https://github.com/carla-simulator/carla/blob/60a114eaa291f69681b18546da37edb7c4000b52/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/RoadMap.cpp#L50-L63

I was printing this for debugging purposes then @felipecode started using it in his planner :grinning:, just keep in mind that in the conversion to PNG may be some losses so the info won't be 100% accurate.

@felipecode Also, the image inside the planner is an old one, we improved the precision of turns an intersections.

I thinks "Distance from Centre of Lane" is available in the latest release (0.8)?

Hi,@WenChaoDing
How did you get the Distance from Centre of Lane.I want to get it but i don't know how to get it.

Hello,@nsubiron Nice to meet u again.
I have a problem that if I want to print the orientation of the lanes at screen(Fcolor[2]).How should i do?

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rowanmcallister picture rowanmcallister  Â·  3Comments

cstamatiadis picture cstamatiadis  Â·  3Comments

imran514 picture imran514  Â·  3Comments

tgrel picture tgrel  Â·  3Comments

UndeadBlow picture UndeadBlow  Â·  4Comments