Giter Site home page Giter Site logo

Comments (2)

Morphlng avatar Morphlng commented on June 7, 2024

Ok, so using BasicAgent in Carla 0.9.13's PythonAPI, I've successfully generated correct route. It can be seen as below:

SSUI3C_TOWN3

There is something need to be addressed:

  1. This bug seems hard to reproduce the exact same behavior, but it generally exists. I've tried to run the same scenario under Ubuntu 22.04, it turns out the car1's route is correct but car2 and car3 remain incorrect.
  2. I think copying a specific version of PythonAPI isn't a good idea, this part of API is rapidly changing. Since each distribution contains a version of BasicAgent, why don't we just wrap around this class?

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)

from macad-gym.

praveen-palanisamy avatar praveen-palanisamy commented on June 7, 2024

Hi,
Good to see your investigation with details.

  1. Thanks for the test code to reproduce the issues you described! I'll take a look.
  2. Yes, the carla/PythonAPI module is directly from CARLA) as stated in the README. When MACAD-Gym package was developed, that module was included in code instead of importing because we didn't publish CARLA python wheels for versions 0.9.6 to 0.9.11 as you can see on the package registry here: https://pypi.org/project/carla/#history. The reason for using the specific API version was to ensure the results in the MACAG-Gym paper is reproducible.

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 v0.9.13 and found it to be unusable because the autopilot chooses destinations/path at random especially at the intersections. We need to use a deterministic planner to ensure that every agent in a specific Multi-Agent RL environment behaves as expected and is reproducible (deterministic env). Any randomness in the behaviour should be driven by a random seed to make the RL problem tractable and reproducible.
I'll take a look into the path tracking issue you raised and update when I have one.

from macad-gym.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.