Skip to content

Commit

Permalink
adding departSpeed=avg refs #2024
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Dec 23, 2021
1 parent 25cd7ea commit d66ca6c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/xsd/routeTypes.xsd
Expand Up @@ -677,6 +677,7 @@
<xsd:enumeration value="desired"/>
<xsd:enumeration value="speedLimit"/>
<xsd:enumeration value="last"/>
<xsd:enumeration value="avg"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
Expand Down
5 changes: 5 additions & 0 deletions src/microsim/MSLane.cpp
Expand Up @@ -522,6 +522,11 @@ MSLane::getDepartSpeed(const MSVehicle& veh, bool& patchSpeed) {
patchSpeed = false;
break;
}
case DepartSpeedDefinition::AVG: {
speed = MIN2(getVehicleMaxSpeed(&veh), getMeanSpeed());
patchSpeed = false;
break;
}
case DepartSpeedDefinition::DEFAULT:
default:
// speed = 0 was set before
Expand Down
2 changes: 2 additions & 0 deletions src/traci-server/TraCIServerAPI_Vehicle.cpp
Expand Up @@ -958,6 +958,8 @@ TraCIServerAPI_Vehicle::processSet(TraCIServer& server, tcpip::Storage& inputSto
departSpeed = "speedLimit";
} else if (-departSpeedCode == (int)DepartSpeedDefinition::LAST) {
departSpeed = "last";
} else if (-departSpeedCode == (int)DepartSpeedDefinition::AVG) {
departSpeed = "avg";
}

int departLaneCode;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/vehicle/SUMOVehicleParameter.cpp
Expand Up @@ -427,6 +427,8 @@ SUMOVehicleParameter::parseDepartSpeed(const std::string& val, const std::string
dsd = DepartSpeedDefinition::LIMIT;
} else if (val == "last") {
dsd = DepartSpeedDefinition::LAST;
} else if (val == "avg") {
dsd = DepartSpeedDefinition::AVG;
} else {
try {
speed = StringUtils::toDouble(val);
Expand Down
4 changes: 3 additions & 1 deletion src/utils/vehicle/SUMOVehicleParameter.h
Expand Up @@ -208,7 +208,9 @@ enum class DepartSpeedDefinition {
/// @brief The maximum lane speed is used (speedLimit)
LIMIT,
/// @brief The speed of the last vehicle. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on the departLane yet.
LAST
LAST,
/// @brief The average speed on the lane. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on the departLane yet.
AVG
};


Expand Down

0 comments on commit d66ca6c

Please sign in to comment.