Modelling connected vehicles using Aimsun API: Cooperative Adaptive Cruise Control
Technical Note #22
January 2017
By Paolo Rinelli and Dimitris Triantafyllos
Did you know that you can use the Aimsun micro Advanced Programming Interface (API) to model some connected vehicle applications, such as Cooperative Adaptive Cruise Control (CACC)?
For this application, you need functions to:
Read the state of a vehicle and that of the preceding vehicle (to check that the two are within the maximum communication range of the system and to read the information that would be transmitted between the two, such as: position, speed, acceleration, etc.)
Modify the behavioral parameters of a vehicle to emulate the transition from human to machine control
Control the speed of a vehicle during the simulation
The API provides all of the functions to perform these tasks.
Cooperative Adaptive Cruise Control
Cooperative Adaptive Cruise Control relies on inter-vehicle communication to access the speed, distance and acceleration of the leader vehicle(s) to calculate the speed or acceleration that the follower vehicle should adopt.
An example of CACC logic (see Bart van Arem et al., The Impact of Cooperative Adaptive Cruise Control on Traffic Flow Characteristics, 2006) is:
ad = k3a + k2ev + k1ex, k1, k2, k3 > 0
where:
ad is the acceleration that the follower should apply a is the acceleration of the leader ev,i is the velocity error, equal to the relative speed between leader and follower exi is the clearance error, equal to the difference between the desired clearance xd,i and the current clearance xr,i k1, k2, k3 are controller feedback loop gains for acceleration a, velocity vx and clearance error ex
Aimsun micro API implementation
The attached source code provides an example of implementation of the CACC logic described above. The implementation relies on the following functionality.
All vehicles entering the network must be set as tracked so that you can modify their speed afterwards.
Explanation: Set a vehicle as tracked
int AKIVehSetAsTracked(int aidVeh)
Step 1
At every simulation step we get the number of vehicles in a single one-lane section* using the following function:
Explanation: Read the total number of vehicles in a section
int AKIVehStateGetNbVehiclesSection(int aidSec, bool considerAllSegments)
* In this example, finding the leader is trivial because there is only one section and one lane and the API returns the vehicles ordered from the end to the beginning of the section. You should rewrite this function if you want to deal with more complex situations that have multiple lanes and sections.
Obtain the state of each vehicle and that of its leader using the following function:
Explanation: Read the information of a vehicle in a section
infVeh = AKIVehStateGetVehicleInfSection(id, i)
Step 2
Check whether the distance between the two vehicles is within the maximum communication range of the system, in which case CACC is activated. The activation of CACC is modelled by altering some vehicle parameters that reflect human driving behavior.
To change the behavioral parameters of a vehicle, for example reactionTime, reactionTimeAtStop, reactionTimeAtTrafficLight, sensitivityFactor, minDistanceVeh, you use the following function*:
Explanation: Modify the static parameters of a tracked vehicle. Static parameters are those that are set once when the vehicle was generated
* Don’t forget to cache the initial values of these parameters to be able to restore them when the CACC is deactivated.
Step 3
Calculate the speed using the CACC formula described above and apply the new speed using the following function:
Explanation: Modify the speed of a tracked vehicle for the next simulation step
int AKIVehTrackedModifySpeed(int aidVeh, double newSpeed)
Note that Aimsun doesn’t allow you to set a speed higher than that it calculates applying the default car-following. The vehicle parameters that we set when CACC is activated aim at making the default car-following speed less restrictive than the CACC speed.
If the leader of a CACC vehicle leaves the platoon, the following vehicle must return to manual driving conditions. This is achieved by restoring the initial values of the vehicle parameters.
Running the sample API
Download the sample files below and ensure that all files are located in the same directory:
Remember that the Aimsun AAPI file must be consistent with the Aimsun version currently in use. You can retrieve it here: C:\Program Files\TSS-Transport Simulation Systems\Aimsun\programming\Aimsun API\AAPIPython\Micro
Procedure
Launch Aimsun and then open the CACC.ang file provided
Execute the Replication. See Log window for detailed feedback about the operation of the CACC
License: Note that you need an API license to run this example. For more information, please contact info@aimsun.com
This website uses cookies to enhance your browsing experience. AcceptRead More
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SHARE
Citar Aimsun Next
Texto sin formato
BibTeX
RIS
Aimsun Next 23
Aimsun (2023). Aimsun Next 23 Manual del usuario, Aimsun Next Versión 23.0.0, Barcelona, España. Acceso: 19, 2023. [Online]. Disponible en: https://docs.aimsun.com/next/23.0.0/
Aimsun Next 20.0.5
Aimsun (2021). Aimsun Next 20.0.5 Manual del usuario, Aimsun Next Versión 20.0.3, Barcelona, España. Acceso: May. 1, 2021. [En software]. Disponible: qthelp://aimsun.com.aimsun.20.0/doc/UsersManual/Intro.html
Aimsun Next 23
@manual {AimsunManual,
título = {Aimsun Next 23 User’s Manual}, autor = {Aimsun}, edición = {Aimsun Next 23.0.0}, domicilio = {Barcelona, Spain}, año = {2023. [Online]}, mes = {Accessed on: Month, Day, Year}, url = {https://docs.aimsun.com/next/23.0.0/}, }
Aimsun Next 20.0.5
@manual {AimsunManual,
título = {Aimsun Next 20.0.5 User’s Manual}, autor = {Aimsun}, edición = {Aimsun Next 20.0.5}, domicilio = {Barcelona, Spain}, año = {2021. [En software]}, mes = {Accessed on: Month, Day, Year}, url = {qthelp://aimsun.com.aimsun.20.0/doc/UsersManual/Intro.html}, }
Aimsun Next 23
TY – COMP T1 – Manual del usuario de Aimsun Next 23 A1 – Aimsun ET – Aimsun Next Version 23.0.0 Y1 – 2023 Y2 – Acceso: Mes, Día, Año CY – Barcelona, España PB – Aimsun UR – [En software]. Disponible en: https://docs.aimsun.com/next/23.0.0/
Aimsun Next 20.0.5
TY – COMP T1 – Manual del usuario de Aimsun Next 20.0.5 A1 – Aimsun ET – Aimsun Next Version 20.0.5 Y1 – 2021 Y2 – Acceso: Mes, Día, Año CY – Barcelona, España PB – Aimsun UR – [In software]. Available: qthelp://aimsun.com.aimsun.20.0/doc/UsersManual/Intro.html