-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PathTracker generate wrong route #81
Comments
Ok, so using There is something need to be addressed:
I'll leave the test code below, for reproducibility: import carla
import random
import time
from agents.navigation.basic_agent import BasicAgent
from agents.tools.misc import draw_waypoints
scenario = {
"map": "Town03",
"actors": {
"car1": {
"start": [170.5, 80, 0.4],
"end": [144, 59, 0]
},
"car2": {
"start": [188, 59, 0.4],
"end": [167, 75.7, 0.13],
},
"car3": {
"start": [147.6, 62.6, 0.4],
"end": [191.2, 62.7, 0],
}
},
"weather_distribution": [0],
"max_steps": 500,
"spectator_location": [140, 68, 9],
}
class PathTracker:
'''Path tracker for the agent to follow the path
'''
def __init__(self, origin, destination, actor):
self.agent = BasicAgent(actor)
self.agent.set_destination(
carla.Location(x=destination[0],
y=destination[1], z=destination[2]),
carla.Location(x=origin[0], y=origin[1], z=origin[2])
)
def get_path(self):
return self.agent._local_planner.get_plan()
def create_scenario(client, scenario):
world = client.load_world(scenario["map"])
map = world.get_map()
vehicle_blueprints = world.get_blueprint_library().filter('vehicle.*')
actors = {}
for actor_id in scenario["actors"]:
bp = random.choice(vehicle_blueprints)
start_loc = carla.Location(x=scenario["actors"][actor_id]["start"][0],
y=scenario["actors"][actor_id]["start"][1],
z=scenario["actors"][actor_id]["start"][2])
spawn_point = carla.Transform(
start_loc,
map.get_waypoint(
start_loc, project_to_road=True).transform.rotation
)
actors[actor_id] = world.spawn_actor(bp, spawn_point)
if scenario.get("spectator_location", None) is not None:
spectator_transform = carla.Transform(
carla.Location(x=scenario["spectator_location"][0],
y=scenario["spectator_location"][1],
z=scenario["spectator_location"][2]),
carla.Rotation(pitch=-90)
)
world.get_spectator().set_transform(spectator_transform)
return actors
if __name__ == "__main__":
client = carla.Client("localhost", 2000)
client.set_timeout(10)
actors = create_scenario(client, scenario)
path_trackers = [PathTracker(scenario["actors"][actor_id]["start"],
scenario["actors"][actor_id]["end"], actors[actor_id]) for actor_id in scenario["actors"]]
while True:
for path_tracker in path_trackers:
path = path_tracker.get_path()
draw_waypoints(client.get_world(), [p[0] for p in path], 1.0)
time.sleep(0.1) |
Hi,
Recently, MACAD-Gym started adding support for CARLA 0.9.13 and later. It is a good idea to update the Traffic Manager APIs to the latest versions. From your #82 PR description, it sounds like you also tried the autopilot and path tracking with CARLA v |
I want to apply
traffic_manager.set_path(actor, route)
(This api is missed in the doc, but actually available and described in this PR) to navigate the actor to desired end point when "auto_control" is enabled.However, the path generated by Macad's PathTracker is not correct. I've tested Scenario
SSUI3C_TOWN3
, the start/end position is defined as:macad-gym/src/macad_gym/carla/scenarios.py
Lines 43 to 61 in 1006e84
Take
car1
as an example, this car should take a left turn. But the route generated by PathTracker is like this (green line):It takes a right turn, and we can check the end point, it's far away from what we defined:
I've noticed that Macad-Gym copied a PythonAPI from Carla 0.9.6 distribution, maybe this is the reason why the generated path is incorrect. I'm trying to apply the Carla 0.9.13 PythonAPI to see whether it will make a difference.
The text was updated successfully, but these errors were encountered: