carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
11.38k stars 3.69k forks source link

Python API reference misses set_path and set_route #5087

Open j-scharrenbach opened 2 years ago

j-scharrenbach commented 2 years ago

Hi everybody,

not sure if this is on purpose or not. Feel free to close the issue if so.

I was trying to make a car always do a specific maneuver in a scenic scenario. I stumbled accross the set_path and set_route functionality as definined here. Both functions are not mentioned in the Python API reference. It would be nice to add it to the documentation as others will find it more easily.

Best regards, Jannik

albertxos commented 2 years ago

indeed: https://carla.readthedocs.io/en/latest/python_api/#carlatrafficmanager

sschupp commented 2 years ago

Could you give me a quick tutorial on how to use set_path or set_route? I have a route that is provided in the same way the set_destination creates a route for Agents, but I can't manage to match the C++ Signature

j-scharrenbach commented 2 years ago

Could you give me a quick tutorial on how to use set_path or set_route? I have a route that is provided in the same way the set_destination creates a route for Agents, but I can't manage to match the C++ Signature

Hi Steffen,

I only used the set_route function, so I only can give you detailed information about this. I use the function like this:

# get your instance of traffic_manager and the corresponding carla_actor
trafficmanager.set_route(carla_actor, ["Left", "Right", "Straight"])

In this case, the actor will turn left on the first intersection, turn right on the second one and then drives straight. Just pass a list with the desired actions to take. You can find all options here.

I also tried the set_path function once but I don't know for sure if I used it correctly. As far as I remember I did the following:

from carla.libcarla import Location
# get your instance of traffic_manager and the corresponding carla_actor
path = [Location(x=0., y=1., z=0.), Location(x=3., y=4., z=0.)]   # add all the points of the desired path to a list of Location() objs
traffic_manager.set_path(carla_actor, path)

I hope this helps!

Edit: As mentioned here remember to enable autopilot before calling both set_route or set_path!

glopezdiest commented 2 years ago

Hey @j-scharrenbach, yeah, the docs are a bit being, as those features were just introduced in 0.9.13, and are working to add them.

As for how they work, everything you explains is correct. However, I'd like to add that those aren't meant to be route planners, but directions to take at a given junction. You can either use set_path with a high level command such as "Left", "Straight"... or set_route with CARLA locations

2Innovative commented 2 years ago

I have a problem where the vehicles I spawn do drive by autopilot but don't stick to the applied path, they sometimes even crash into a tree on the sidewalk. Why would CARLA do that? The code is rather simple I think.

stale[bot] commented 1 year ago

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.