New iteration on J review 03
This commit is contained in:
parent
31412f0c2d
commit
739ddf6654
|
@ -4,7 +4,7 @@
|
|||
* [ALSM](#alsm)
|
||||
* [Command array](#command-array)
|
||||
* [Control loop](#control-loop)
|
||||
* [In memory map](#in-memory-map)
|
||||
* [In-Memory Map](#in-memory-map)
|
||||
* [PBVT](#pbvt)
|
||||
* [PID controller](#pid-controller)
|
||||
* [Simulation state](#simulation-state)
|
||||
|
@ -47,45 +47,45 @@ The previous diagram is a summary of the internal architecture of the Traffic Ma
|
|||
|
||||
Nevertheless, the logic of it can be simplified as follows.
|
||||
|
||||
__1. Store the current state of the simulation.__
|
||||
First of all, the [ALSM](#ALSM) (Agent Lifecycle & State Management) scans the world to keep track of all the vehicles and walkers present in it, and clean up entries for those that no longer exist. All the data is retrieved from the server, and passed on to others. In such way, calls to the server are isolated in the ALSM, and these information can be easily accessible onwards. The [vehicle registry](#vehicle-registry) contains an array with the registered vehicles, and a list with the rest of vehicles and pedestrians. The [simulation state](#simulation-state) stores in cache the position and velocity and some additional information of all the vehicles and walkers.
|
||||
__1. Store and update the current state of the simulation.__
|
||||
First of all, the [ALSM](#ALSM) (Agent Lifecycle & State Management) scans the world to keep track of all the vehicles and walkers present in it, and clean up entries for those that no longer exist. All the data is retrieved from the server, and then passed to the [stages](#stages). In such way, calls to the server are isolated in the ALSM, and these information can be easily accessible onwards. The [vehicle registry](#vehicle-registry) contains an array with the registered vehicles, and a list with the rest of vehicles and pedestrians. The [simulation state](#simulation-state) stores in cache the position and velocity and some additional information of all the cars and walkers.
|
||||
|
||||
__2. Calculate the movement of every registered vehicle.__
|
||||
The main goal of the TM is generating viable commands for all the vehicles in the [vehicle registry](#vehicle-registry), according to the [simulation state](#simulation-state). The calculations for each vehicle are done separatedly. These calculations are divided in different [stages](#stages). The [control loop](#control-loop) makes sure that all the calculations are consistent by creating __synchronization barriers__ in between stages. No one moves to the following stage before the calculations for all the vehicles are finished in the current one. Each vehicles has to go through the following stages.
|
||||
__2.1 - [Localization stage](#stage-1-localization-stage).__
|
||||
TM vehicles do not have a specific route in mind. Choices are made randomly at junctions. Having these in mind, the [in memory map](#in-memory-map) simplifies the map as a grid of waypoints, and a near-future path to follow is created as a list of waypoints ahead. The path of every vehicle will be stored by the [PBVT](#PBVT) component (Path Buffers & Vehicle Tracking), so that these can be easily accessible and modified in future stages.
|
||||
__2.2 - [Collision stage](#stage-2-collision-stage).__
|
||||
During this stage, bounding boxes are extended over the path of the vehicle, and collision hazards are triggered when necessary.
|
||||
__2.3 - [Traffic Light stage](#stage-3-traffic-light-stage)__
|
||||
Similar to the collision stage, triggers hazards that modify the path of the vehicle according to traffic light influence, stop signs, and junction priority.
|
||||
__2.4 - [Motion Planner stage](#stage-4-motion-planner-stage).__
|
||||
Once the path has been defined by the previous stages, this stage calculates the vehice movement. A [PID controller](#pid-controller) will be used to determine how to reach the target values. This movement is then translated into an actual CARLA command to be applied.
|
||||
The main goal of the TM is to generate viable commands for all the vehicles in the [vehicle registry](#vehicle-registry), according to the [simulation state](#simulation-state). The calculations for each vehicle are done separatedly. These calculations are divided in different [stages](#stages). The [control loop](#control-loop) makes sure that all the calculations are consistent by creating __synchronization barriers__ in between stages. No one moves to the following stage before the calculations for all the vehicles are finished in the current one. Each vehicle has to go through the following stages.
|
||||
__2.1 - [Localization Stage](#stage-1-localization-stage).__
|
||||
TM vehicles do not have a predefined route, and path choices are taken randomly at junctions. Having this in mind, the [In-Memory Map](#in-memory-map) simplifies the map as a grid of waypoints, and a near-future path to follow is created as a list of waypoints ahead. The path of every vehicle will be stored by the [PBVT](#PBVT) component (Path Buffers & Vehicle Tracking), so that these can be easily accessible and modified in future stages.
|
||||
__2.2 - [Collision Stage](#stage-2-collision-stage).__
|
||||
During this stage, bounding boxes are extended over the path of each vehicle to identify potential collision hazards, which are then managed when necessary.
|
||||
__2.3 - [Traffic Light Stage](#stage-3-traffic-light-stage)__
|
||||
Similar to the Collision Stage, this stage identifies potential hazards that affect the path of the vehicle according to traffic light influence, stop signs, and junction priority.
|
||||
__2.4 - [Motion Planner Stage](#stage-4-motion-planner-stage).__
|
||||
Once a path has been defined, this stage computes vehicle movement. A [PID controller](#pid-controller) is used to determine how to reach the target values. This movement is then translated into an actual CARLA command to be applied.
|
||||
|
||||
__3. Apply the commands in the simulation.__
|
||||
Finally, the TM has calculated the next command for every vehicle. It is only a matter of applying these. All the commands are gathered by the [command array](#command-array), and sent to the CARLA server in a batch so that they are applied in the same frame.
|
||||
Finally, the TM has calculated the next command for every vehicle, and now it is only a matter of applying them. All the commands are gathered by the [command array](#command-array), and sent to the CARLA server in a batch so that they are applied in the same frame.
|
||||
|
||||
And thus concludes the cycle. The TM follows this logic on every step of the simulation. For a better understanding of the role that each component plays, this section includes an in-depth description of each of them.
|
||||
And thus the cycle is concluded. The TM follows this logic on every step of the simulation. For a better understanding of the role that each component plays, this section includes an in-depth description of each of them.
|
||||
|
||||
### ALSM
|
||||
|
||||
ALSM stands for __Agent Lifecycle and State Management__. First step in the logic cycle. Provides context over the current state of the simulation.
|
||||
|
||||
* Scans the world to keep track of all the vehicles and walkers in it, their position and velocity. For walkers and vehicles with physics enabled, the velocity is retrieved by [Vehicle.get_velocity()](#python_api.md#carla.Vehicle). For vehicles with physics disabled, the velocity is computed using the history of position updates over time.
|
||||
* Scans the world to keep track of all the vehicles and walkers in it, their positions and velocities. If physics are enabled, the velocity is retrieved by [Vehicle.get_velocity()](#python_api.md#carla.Vehicle). Instead, if physics are disabled, the velocity is computed using the history of position updates over time.
|
||||
* Stores the position, velocity and additional information (traffic light influence, bounding boxes, etc) of every vehicle and walker in the [simulation state](#simulation-state) module.
|
||||
* Updates the list of registered vehicles stored by [vehicle registry](#vehicle-registry).
|
||||
* Removes/Adds entries in the [control loop](#control-loop) and [PBVT](#pbvt) modules to match the list of registered vehicles.
|
||||
* Updates the list of registered vehicles stored by the [vehicle registry](#vehicle-registry).
|
||||
* Updates entries in the [control loop](#control-loop) and [PBVT](#pbvt) modules to match the list of registered vehicles.
|
||||
|
||||
__Related .cpp files:__ `ALSM.h`, `ALSM.cpp`.
|
||||
|
||||
### Command array
|
||||
|
||||
Last step in the TM logic cycle. Receives commands for all the registered vehicles and applies these.
|
||||
Last step in the TM logic cycle. Receives commands for all the registered vehicles and applies them.
|
||||
|
||||
* Receives a series of [carla.VehicleControl](#python_api.md#carla.VehicleControl) from the [Motion Planner stage](#motion-planner-stage).
|
||||
* Receives a series of [carla.VehicleControl](#python_api.md#carla.VehicleControl) from the [Motion Planner Stage](#motion-planner-stage).
|
||||
* Constructs a batch for all the commands to be applied during the same frame.
|
||||
* Sends the batch to the CARLA server. Either __apply_batch()__ or __apply_batch_synch()__ in [carla.Client](../python_api/#carla.Client) will be called, depending if the simulation is running in asynchronous or synchronous mode, respectively.
|
||||
|
||||
__Related .cpp files:__ `BatchControlStage.cpp`.
|
||||
__Related .cpp files:__ `TrafficManagerLocal.cpp`.
|
||||
|
||||
### Control loop
|
||||
|
||||
|
@ -96,16 +96,16 @@ Manages the process of calculating the next command for all the registered vehic
|
|||
* These calculations are divided in a series of [stages](#stages).
|
||||
* Synchronization barriers are placed between stages so that consistency is guaranteed. Calculations for all vehicles must finish before any of them moves to the next stage, ensuring that all vehicles are updated in the same frame.
|
||||
* Coordinates the transition between [stages](#stages) so that all the calculations are done in sync.
|
||||
* When the last stage ([Motion Planner stage](#motion-planner-stage)) finishes, the [command array](#command-array) is sent to the server. In this manner, no frame delays occur between the calculations of the control loop, and the commands being applied.
|
||||
* When the last stage ([Motion Planner Stage](#motion-planner-stage)) finishes, the [command array](#command-array) is sent to the server. In this way, there are no frame delays between the calculations of the control loop, and the commands being applied.
|
||||
|
||||
__Related .cpp files:__ `TBD`.
|
||||
__Related .cpp files:__ `TrafficManagerLocal.cpp`.
|
||||
|
||||
### In memory map
|
||||
### In-Memory Map
|
||||
|
||||
Helper module contained by the [PBVT](#pbvt) and used during the [Localization stage](#localization-stage).
|
||||
Helper module contained by the [PBVT](#pbvt) and used during the [Localization Stage](#localization-stage).
|
||||
|
||||
* Discretizes the map into a grid of waypoints.
|
||||
* Includes these waypoints in a specific data structure with more information to connect the waypoints and identify roads, junctions...
|
||||
* Includes waypoints in a specific data structure with more information to connect waypoints and identify roads, junctions...
|
||||
* Identifies these structures with an ID that is used to quickly spot vehicles in nearby areas.
|
||||
|
||||
__Related .cpp files:__ `InMemoryMap.cpp` and `SimpleWaypoint.cpp`.
|
||||
|
@ -116,13 +116,13 @@ PBVT stands for __Path Buffer and Vehicle Tracking__. This data structure contai
|
|||
|
||||
* Contains a map of deque objects with an entry per vehicle.
|
||||
* For each vehicle, contains a set of waypoints describing its current location and near-future path.
|
||||
* Contains the [in memory map](#in-memory-map) that will be used by the [Localization stage](#localization-stage) to relate every vehicle to the nearest waypoint, and possible overlapping paths.
|
||||
* Contains the [In-Memory Map](#in-memory-map) that will be used by the [Localization Stage](#localization-stage) to relate every vehicle to the nearest waypoint, and possible overlapping paths.
|
||||
|
||||
### PID controller
|
||||
|
||||
Helper module that performs calculations during the [Motion Planner stage](#motion-planner-stage).
|
||||
Helper module that performs calculations during the [Motion Planner Stage](#motion-planner-stage).
|
||||
|
||||
* Using the information gathered by the [Motion Planner stage](#motion-planner-stage), estimates the throttle, brake and steering input needed to reach a target value.
|
||||
* Using the information gathered by the [Motion Planner Stage](#motion-planner-stage), estimates the throttle, brake and steering input needed to reach a target value.
|
||||
* The adjustment is made depending on the specific parameterization of the controller, which can be modified if desired. Read more about [PID controllers](https://en.wikipedia.org/wiki/PID_controller) to learn how to do it.
|
||||
|
||||
__Related .cpp files:__ `PIDController.cpp`.
|
||||
|
@ -134,33 +134,33 @@ Stores information about the vehicles in the world so that it can be easily acce
|
|||
* Receives the current state of all vehicles and walkers in the world from the [ALSM](#ALSM), including their position, velocity and some additional information (such as traffic light influence and state). It also stores some additional information such as whereas these vehicles are under the inffluence of a traffic light and what is the current state of said traffic light.
|
||||
* Stores in cache all the information so that no additional calls to the server are needed during the [control loop](#control-loop).
|
||||
|
||||
__Related .cpp files:__ `TBD`.
|
||||
__Related .cpp files:__ `SimulationState.cpp`, `SimulationState.h`.
|
||||
|
||||
### Stages
|
||||
|
||||
##### Stage 1- Localization stage
|
||||
##### Stage 1- Localization Stage
|
||||
|
||||
First stage in the [control loop](#control-loop). Defines a near-future path for registered vehicles.
|
||||
|
||||
* Obtains the position and velocity of all the vehicles from [simulation state](#simulation-state).
|
||||
* Using the [in memory map](#in-memory-map), relates every vehicle with a list of waypoints that describes its current location and near-future path, according to its trajectory. The faster the vehicle goes, the larger said list will be.
|
||||
* Using the [In-Memory Map](#in-memory-map), relates every vehicle with a list of waypoints that describes its current location and near-future path, according to its trajectory. The faster the vehicle goes, the larger said list will be.
|
||||
* The path is updated according to planning decisions such as lan changes, speed limit, distance to leading vehicle parameterization, etc.
|
||||
* The [PBVT](#pbvt) module stores the path for all the vehicles.
|
||||
* These paths are compared with each other, in order to estimate possible collision situations. Results are passed to the following stage: [Colllision stage](#collision-stage).
|
||||
|
||||
__Related .cpp files:__ `LocalizationStage.cpp` and `LocalizationUtils.cpp`.
|
||||
|
||||
##### Stage 2- Collision stage
|
||||
##### Stage 2- Collision Stage
|
||||
|
||||
Second stage in the [control loop](#control-loop). Triggers collision hazards.
|
||||
|
||||
* Receives a list of pairs of vehicles with possible overlapping paths from the [Localization stage](#localization-stage).
|
||||
* Receives a list of pairs of vehicles with possible overlapping paths from the [Localization Stage](#localization-stage).
|
||||
* For every pair, extends bounding boxes along the path ahead (geodesic boundaries), to check if they actually overlap and the risk of collision is real.
|
||||
* Hazards for all the possible collisions will be sent to the [Motion Planner stage](#motion-planner-stage) to modify the path accordingly.
|
||||
* Hazards for all the possible collisions will be sent to the [Motion Planner Stage](#motion-planner-stage) to modify the path accordingly.
|
||||
|
||||
__Related .cpp files:__ `CollisionStage.cpp`.
|
||||
|
||||
##### Stage 3- Traffic Light stage
|
||||
##### Stage 3- Traffic Light Stage
|
||||
|
||||
Third stage in the [control loop](#control-loop). Triggers hazards to follow traffic regulations such as traffic lights, stop signs, and priority at junctions.
|
||||
|
||||
|
@ -169,11 +169,11 @@ Third stage in the [control loop](#control-loop). Triggers hazards to follow tra
|
|||
|
||||
__Related .cpp files:__ `TrafficLightStage.cpp`.
|
||||
|
||||
##### Stage 4- Motion Planner stage
|
||||
##### Stage 4- Motion Planner Stage
|
||||
|
||||
Fourth and last stage in the [control loop](#control-loop). Generates the CARLA command that will be applied to the vehicle.
|
||||
|
||||
* Gathers all the information so far: position and velocity of the vehicles ([simulation state](#simulation-state)), their path ([PBVT](#pbvt)), hazards ([Collision stage](#collision-stage) and [Traffic Light State](#traffic-light-state)).
|
||||
* Gathers all the information so far: position and velocity of the vehicles ([simulation state](#simulation-state)), their path ([PBVT](#pbvt)), hazards ([Collision Stage](#collision-stage) and [Traffic Light State](#traffic-light-state)).
|
||||
* Makes high-level decisins about how should the vehicle move, for example computing the brake needed to prevent a collision hazard. A [PID controller](#pid-controller) is used to estimate behaviors according to target values.
|
||||
* Translates the desired movement to a [carla.VehicleControl](#python_api.md#carla.VehicleControl) that can be applied to the vehicle.
|
||||
* Sends the resulting CARLA commands to the [command array](#command-array).
|
||||
|
|
Loading…
Reference in New Issue