|
Autopysta
|
Class representing a moving vehicle on the road. More...
#include <vehicle.h>
Public Member Functions | |
| vehicle (std::vector< double > x, int l) | |
| Create a vehicle with a predefined trajectory and a single lane. | |
| vehicle (std::vector< double > x, std::vector< int > l) | |
| Create a vehicle with a predefined trajectory across multiple lanes. | |
| vehicle (std::vector< point * > p) | |
| Create a vehicle with a predefined trajectory based on points. | |
| vehicle (model *m, double x, double v, int l) | |
| Create a vehicle with a model, initial position, speed, and lane. | |
| vehicle (model *m, point *p) | |
| Create a vehicle with a model and a starting point. | |
| void | initialize_vehicle () |
| Initialize the vehicle’s trajectory with real points. | |
| params * | p () |
| Get the model parameters associated with the vehicle. | |
| point * | current () override |
| Get the current point of the vehicle. | |
| void | update (road_object *leader) override |
| Update the vehicle's state based on a leader vehicle. | |
| ~vehicle () | |
Destructor for the vehicle class. | |
Public Member Functions inherited from road_object | |
| virtual | ~road_object () |
Virtual destructor for the road_object class. | |
Public Attributes | |
| bool | needs_initialization = false |
| Flag indicating if the vehicle requires initialization within the simulation. | |
| std::vector< point * > | placeholder_points |
| A vector of placeholder points used before simulation starts. | |
Public Attributes inherited from road_object | |
| model * | m = nullptr |
| Pointer to the model associated with the object (optional). | |
| generalized_trajectory * | traj = nullptr |
| Object's trajectory, which defines its movement and positions over time. | |
| std::queue< point * > | defined_t |
| A queue of defined trajectory points provided by the user. | |
Class representing a moving vehicle on the road.
The vehicle class models a moving vehicle, which can either follow a predefined trajectory or behave according to a dynamic model. It offers multiple constructors to accommodate different ways of specifying the vehicle’s movement, including position history, points, or models that dictate its behavior.
| vehicle::vehicle | ( | std::vector< double > | x, |
| int | l ) |
Create a vehicle with a predefined trajectory and a single lane.
This constructor initializes a vehicle with a list of X positions and a single lane. It assumes that the positions are equally spaced in time, with a fixed delta time between points.
| x | A vector of X positions representing the vehicle’s position over time. |
| l | The lane in which the vehicle is moving. |
| vehicle::vehicle | ( | std::vector< double > | x, |
| std::vector< int > | l ) |
Create a vehicle with a predefined trajectory across multiple lanes.
This constructor initializes a vehicle with a list of X positions and a list of lane positions. It assumes that the positions are equally spaced in time, with a fixed delta time between points.
| x | A vector of X positions representing the vehicle’s position over time. |
| l | A vector of lane positions corresponding to each X position. |
| Exception | If the size of x and l do not match. |
| vehicle::vehicle | ( | std::vector< point * > | p | ) |
Create a vehicle with a predefined trajectory based on points.
This constructor initializes a vehicle with a list of point objects that define its trajectory over time.
| p | A vector of pointers to point objects representing the vehicle's trajectory. |
| Exception | If the size of the trajectory is too short. |
| vehicle::vehicle | ( | model * | m, |
| double | x, | ||
| double | v, | ||
| int | l ) |
Create a vehicle with a model, initial position, speed, and lane.
This constructor initializes a vehicle with a dynamic model that dictates its behavior, along with its initial position, speed, and lane.
| m | Pointer to the model that will describe the vehicle's behavior. |
| x | The initial X position of the vehicle. |
| v | The initial speed of the vehicle. |
| l | The lane in which the vehicle starts. |
Create a vehicle with a model and a starting point.
This constructor initializes a vehicle with a dynamic model and a starting point, which contains information about its position, speed, and lane.
| m | Pointer to the model that will describe the vehicle's behavior. |
| p | Pointer to the initial point of the vehicle. |
| vehicle::~vehicle | ( | ) |
Destructor for the vehicle class.
Cleans up dynamically allocated memory associated with the vehicle's trajectory.
|
overridevirtual |
Get the current point of the vehicle.
This method returns the vehicle's current position and state based on its trajectory.
Implements road_object.
| void vehicle::initialize_vehicle | ( | ) |
Initialize the vehicle’s trajectory with real points.
This method initializes the placeholder points of a vehicle that was created with a predefined trajectory, replacing them with real points in the simulation.
| params * vehicle::p | ( | ) |
Get the model parameters associated with the vehicle.
params).
|
overridevirtual |
Update the vehicle's state based on a leader vehicle.
This method updates the vehicle's state (position, speed, etc.) based on the trajectory of a leading vehicle. If no leader is provided, the vehicle's state is updated according to its model or predefined trajectory.
| leader | A pointer to the road object acting as the leader vehicle. |
| Exception | If the vehicle runs out of predefined points for the simulation. |
Implements road_object.