Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file CC_VehicleVariables.cpp
15 : /// @author Michele Segata
16 : /// @date Mon, 7 Mar 2016
17 : ///
18 : /****************************************************************************/
19 : #include "CC_VehicleVariables.h"
20 :
21 : //initialize default L and K matrices
22 : const int CC_VehicleVariables::defaultL[][MAX_N_CARS] = {
23 : {0, 0, 0, 0, 0, 0, 0, 0},
24 : {1, 0, 0, 0, 0, 0, 0, 0},
25 : {1, 1, 0, 0, 0, 0, 0, 0},
26 : {1, 0, 1, 0, 0, 0, 0, 0},
27 : {1, 0, 0, 1, 0, 0, 0, 0},
28 : {1, 0, 0, 0, 1, 0, 0, 0},
29 : {1, 0, 0, 0, 0, 1, 0, 0},
30 : {1, 0, 0, 0, 0, 0, 1, 0}
31 : };
32 : const double CC_VehicleVariables::defaultK[][MAX_N_CARS] = {
33 : {0, 0, 0, 0, 0, 0, 0, 0},
34 : {460, 0, 0, 0, 0, 0, 0, 0},
35 : {80, 860, 0, 0, 0, 0, 0, 0},
36 : {80, 0, 860, 0, 0, 0, 0, 0},
37 : {80, 0, 0, 860, 0, 0, 0, 0},
38 : {80, 0, 0, 0, 860, 0, 0, 0},
39 : {80, 0, 0, 0, 0, 860, 0, 0},
40 : {80, 0, 0, 0, 0, 0, 860, 0}
41 : };
42 : const double CC_VehicleVariables::defaultB[MAX_N_CARS] = {1800, 1800, 1800, 1800, 1800, 1800, 1800, 1800};
43 : const double CC_VehicleVariables::defaultH[MAX_N_CARS] = {0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8};
44 :
45 0 : CC_VehicleVariables::CC_VehicleVariables() :
46 0 : controllerAcceleration(0), frontSpeed(0), frontAcceleration(0),
47 0 : frontControllerAcceleration(0), frontDataReadTime(0), frontAngle(0), frontInitialized(false),
48 0 : autoFeed(false), leaderVehicle(nullptr), leaderVehicleId(""), frontVehicle(nullptr), frontVehicleId(""),
49 0 : isLeader(true),
50 0 : accHeadwayTime(1.5), accLambda(0.1),
51 0 : useControllerAcceleration(true), leaderSpeed(0),
52 0 : leaderAcceleration(0), leaderControllerAcceleration(0), leaderDataReadTime(0), leaderAngle(0),
53 0 : leaderInitialized(false), caccInitialized(false),
54 0 : useFixedAcceleration(0), fixedAcceleration(0),
55 0 : crashed(false),
56 0 : ccDesiredSpeed(14), ccKp(1), activeController(Plexe::DRIVER),
57 0 : nInitialized(0), position(-1), nCars(8),
58 0 : caccXi(-1), caccOmegaN(-1), caccC1(-1), caccAlpha1(-1), caccAlpha2(-1),
59 0 : caccAlpha3(-1), caccAlpha4(-1), caccAlpha5(-1), caccSpacing(5),
60 0 : engineTau(0.5),
61 0 : uMin(-1e6), uMax(1e6),
62 0 : ploegH(0.5), ploegKp(0.2), ploegKd(0.7),
63 0 : flatbedKa(2.4), flatbedKv(0.6), flatbedKp(12), flatbedD(5), flatbedH(4),
64 0 : engine(0), engineModel(CC_ENGINE_MODEL_FOLM),
65 0 : usePrediction(false),
66 0 : autoLaneChange(false),
67 0 : platoonFixedLane(-1),
68 0 : commitToLaneChange(true), noCommitReason(0), laneChangeCommitTime(-1) {
69 0 : fakeData.frontAcceleration = 0;
70 0 : fakeData.frontControllerAcceleration = 0;
71 0 : fakeData.frontDistance = 0;
72 0 : fakeData.frontSpeed = 0;
73 0 : fakeData.leaderAcceleration = 0;
74 0 : fakeData.leaderControllerAcceleration = 0;
75 0 : fakeData.leaderSpeed = 0;
76 : leaderPosition.set(0, 0);
77 : frontPosition.set(0, 0);
78 : //init L, K, b, and h with default values
79 0 : memcpy(L, defaultL, sizeof(int)*MAX_N_CARS * MAX_N_CARS);
80 0 : memcpy(K, defaultK, sizeof(double)*MAX_N_CARS * MAX_N_CARS);
81 0 : memcpy(b, defaultB, sizeof(double)*MAX_N_CARS);
82 0 : memcpy(h, defaultH, sizeof(double)*MAX_N_CARS);
83 : //no data about any vehicle has been set
84 0 : for (int i = 0; i < MAX_N_CARS; i++) {
85 0 : initialized[i] = false;
86 : }
87 0 : }
88 :
89 0 : CC_VehicleVariables::~CC_VehicleVariables() {
90 0 : if (engine) {
91 0 : delete engine;
92 : }
93 0 : }
|