Open StijnOosterlinck opened 10 months ago
Hi,
In principle, everything that works in CARLA can be used with JOAN. JOAN basically just takes control of the ego vehicle and let CARLA do its thing. However, the idea behind JOAN is that it allows you to control everything (and record all data) from one place. This makes it easier to run experiments with multiple conditions because the experiment manager can automatically load the other scenario. JOAN also provides access to all variables for saving, stuff that happens only on the CARLA side can be difficult to save in the same datafile.
Implementing such experiments in JOAN is possible, but it will require some coding. Experiments in JOAN use two concepts. First, the experiment manager loads all settings for a specific condition. This includes all NPC vehicles and their trajectories. These settings are static; they are loaded once and remain the same for a complete trial. Second, the module CARLA interface allows for the implementation of scenarios. Scenarios have a do function that is called on every timestep and can be used to implement checks and triggers to trigger the dynamic behaviour you're looking for.
For the experiment you describe, you could define an experiment with NPC vehicles for the other traffic that just follow trajectories (and use the velocity defined in the trajectory). Then you could create a custom NPC controller that normally follows a trajectory, but that can be triggered to start tailgating (e.g., get the position of the closest other vehicle from carla shared variables, calculate the gap, and use a PD controller to control for the gap). This trigger needs to originate from a shared variables object in the CARLA interface module. Finally, you create a scenario that checks the position of the ego vehicle and beyond a certain point flips the boolean that triggers the tailgating behaviour.
A few things to keep in mind:
I hope this helps. Just let me know if you have more questions!
Hi,
Thanks for the great explanation!
The concept of trajectories is new for me, so I was wondering how I would go about creating those. Since a trajectory defines the path and the velocity for a certain car, it seems like a lot of work to create those for let's say 50 cars. Is the easiest way to make a trajectory to record a track I ride myself? What about traffic lights? If a certain trajectory has a non-zero speed but there is a traffic light which turns red then this will not be taken into account or am i wrong?
Normally, in Carla, it should be possible to just spawn npc vehicles which run on autopilot so I thought that I would also be able to use this to just create a map with a certain number of npc vehicles riding around...
The easiest way would be to record a trajectory. There is a checkbox in the data recorder that allows you to record a trajectory of the ego vehicle (in the correct format). The only open bug in this system is that it will record some ticks in the beginning with zero velocity. This can cause NPC vehicles to freeze because they track this velocity. A quick fix is to manually remove the first few lines from the csv. (The last value in a row denotes the cruise control velocity which is -1 when disabled, the second to last value is the velocity. Just remove the first lines where it is almost zero.)
The traffic lights are not taken into account here, and I can't think of a quick fix to include this.
Alternatively, you could indeed use the traffic manager in Carla to spawn some traffic. These vehicles will respond to other traffic and traffic lights. However, as far as I know, their behaviour is somewhat random (e.g., where the spawn and what turns they take). I'm not sure how to make such an experiment repeatable. It would also require some extra coding to record data from these vehicles with the JOAN datarecorder. The Carla interface has access to them but does not put their data in it's shared variables object. Therefore, this data is not available to the Datarecoder. If you would alter the Carla interface module to automatically detect other vehicles and include their data in the carla interface shared variables, the datarecorder would automatically be able to record it.
Hi @OlgerSiebinga,
I was wondering whether the experiment manager / carla interface modules also support functionality of pedestrians / cyclists? Or is it only designed for cars?
Because making a trajectory for a pedestrian could then not be done by recording a ride of the ego vehicle for example.
Thanks!
There is no functionality implemented in JOAN for pedestrians or cyclists (yet). However, the care interface module has access to all actors in CARLA so it should be pretty straightforward to implement.
The experiment manager uses the settings objects of all modules to create experiments. So as long a you save the pedestrian settings in the carla interface settings object, the experiment manager will automatically include them. One sidenote: make sure to pay attention to the methods in the carla interface settings object that convert the settings from/to dictionaries (which are used for saving). The actors have their own settings objects which need to be reconstructed on loading. So if you add a pedestrian type actor, you need to manually reconstruct it's settings object there.
Hi,
I want to implement different scenarios, for example one where I'm driving in a map with random npc cars and suddenly a car is tailgating me constantly. In Carla, Open Scenario can be used to create such scenarios (if I'm not mistaken).
I was wondering whether the experiment manager in JOAN is capable of performing such experiments, and if so, are there any examples of likewise experiments which I could use as inspiration for setting up one myself?
I have gone through the example experiment of the documentation, but it is quite difficult to only use that as inspiration to set up a whole experiment like I want to. For example, the npc car needs a trajectory which it has to follow, but in the case of tailgating, it would just follow the ego vehicle, so this would be a dynamic trajectory or something?
If it's not possible to create such experiments using the experiment manager, can I integrate Open Scenario with JOAN?
Thanks in advance!