evshary / autoware_carla_launch

ROS 2 Launch for running Autoware + Carla easily
https://autoware-carla-launch.readthedocs.io/en/latest/
Apache License 2.0
56 stars 18 forks source link

How to use Traffic Manager with the Bridge #129

Open epris opened 3 weeks ago

epris commented 3 weeks ago

Hello,

I would like to configure the Traffic Manager (TM) so that it works in deterministic mode. In deterministic mode, the TM will produce the same results and behaviors under the same conditions. Is that possible with the bridge?

We tried the code below but the inclusion of the instructions related to the TM blocks the non-player characters. Thanks a lot

`import carla import random import time

Connect to the client and retrieve the world object

client = carla.Client('localhost', 3000) world = client.get_world()

world = client.load_world('Town03')

If we configure the TM as in the code below the simulation doesn't start

Set up the simulator in synchronous mode

settings = world.get_settings() settings.synchronous_mode = True # Enables synchronous mode settings.fixed_delta_seconds = 0.05 world.apply_settings(settings)

Set up the TM in synchronous mode

traffic_manager = client.get_trafficmanager() traffic_manager.set_synchronous_mode(True)

Set a seed so behaviour can be repeated if necessary

traffic_manager.set_random_device_seed(0) random.seed(0)

We will aslo set up the spectator so we can see what we do

spectator = world.get_spectator()

spawn_points = world.get_map().get_spawn_points()`

evshary commented 1 week ago

Hi @epris I didn't try TM before, but we are using sync mode by default. Could you provide some information, like which branch you are using now and where you add these code (in our Python script here? https://github.com/evshary/autoware_carla_launch/blob/1ee137b61dc37df0547a56ac9ee89fe842ba9033/script/run-bridge.sh#L17)

JessicaFerrara commented 4 days ago

Hello we set the bridge in sync mode in the file run_bridge.sh and now the Traffic Manager works. The code above is a piece of a script that creates a scenario with the spawn of several players. The problem is that by setting the seed (both random seed and Traffic Manager seed as in the code above) and repeating the same scenario several times, the behavior is not the same, in particular the behavior of the ego-vehicle is different for each run (the velocity of vehicle is different) while that of the other players is the same. For both the ego-vehicle and the other players, autopilot is set. The bridge, Carla and the Traffic Manager are in sync mode