Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monaco SUMO Traffic Scenario for Artery #355

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
[submodule "extern/sim0mqpp"]
path = extern/sim0mqpp
url = https://github.com/riebl/sim0mqpp.git
[submodule "scenarios/most/MoSTScenario"]
path = scenarios/most/MoSTScenario
url = https://github.com/lcodeca/MoSTScenario.git
1 change: 1 addition & 0 deletions scenarios/most/MoSTScenario
Submodule MoSTScenario added at b29b2f
3 changes: 3 additions & 0 deletions scenarios/most/most.roi_parking.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<viewsettings>
<viewport zoom="3740.43" x="5135.86" y="2727.76" angle="0.00"/>
</viewsettings>
151 changes: 151 additions & 0 deletions scenarios/most/omnetpp.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
[General]
network = artery.envmod.World

result-dir = /tmp/most/

# Store results in SQLite database
outputvectormanager-class="omnetpp::envir::SqliteOutputVectorManager"
outputscalarmanager-class="omnetpp::envir::SqliteOutputScalarManager"

repeat = 1

*.traci.core.version = -1
*.traci.launcher.typename = "PosixLauncher"

**.vehicle_rate = ${mprate= 0.1, 0.2, 0.4, 0.6, 0.8, 1.0}
**.plain_rate = ${plain= 0.9, 0.8, 0.6, 0.4, 0.2, 0.0 ! mprate}


# warmup and simulation configuration
*.warmupDuration = ${ warmupDuration = 5s }
*.simulationDuration = ${ simulationDuration = 60s }

# see above for configuration of mapper's random number generator (rng)
*.traci.mapper.typename = "traci.MultiVClassMultiTypeModuleMapper"
*.traci.mapper.basicNodeManager = "traci.nodes"
*.traci.mapper.vehicleTypes = xml \
("\
<roadusers> \
<vehicles vClass=\"passenger evehicle taxi bus coach trailer delivery truck trailer\"> \
<vehicle type=\"artery.envmod.Car\" rate=\"${mprate}\" /> \
<vehicle type=\"artery.envmod.PlainVehicle\" rate=\"${plain}\" /> \
</vehicles> \
<vehicles vClass=\"emergency authority army\"> \
<vehicle type=\"artery.envmod.Car\" rate=\"1.0\" /> \
</vehicles> \
<vehicles vClass=\"rail\"> \
<vehicle type=\"artery.envmod.PlainVehicle\" rate=\"1.0\" /> \
</vehicles> \
<vehicles vClass=\"moped motorcycle bicycle\"> \
<vehicle type=\"artery.envmod.PlainVehicle\" rate=\"1.0\" /> \
</vehicles> \
</roadusers> \
")

*.traci.mapper.personTypes = xml \
("\
<roadusers> \
<persons vClass=\"pedestrian\"> \
<person type=\"artery.envmod.PlainPerson\" rate=\"1.0\" /> \
</persons> \
</roadusers> \
")

*.node[*].wlan[*].typename = "VanetNic"
*.node[*].wlan[*].radio.channelNumber = 180
*.node[*].wlan[*].radio.carrierFrequency = 5.9 GHz
*.node[*].wlan[*].radio.transmitter.power = 200 mW

# Disable all other metrics from WLAN stack (irrelevant to us):
**.wlan[*].**.statistic-recording = false

# Radio Simulation Configuration
*.radioMedium.pathLossType = "Gemv2"
*.radioMedium.pathLoss.withSmallScaleVariations = false

# DCC configuration
**.vanetza[*].dcc.typename = "LimericDccEntity"
**.vanetza[*].dcc.ChannelProbeProcessor = "SmoothingLocal"
**.vanetza[*].dcc.queueLength = 2
**.vanetza[*].dcc.targetCbr = 0.68
**.vanetza[*].dcc.enableDualAlpha = true


# Middleware Configuration
*.node[*].middleware.updateInterval = 0.1s
*.node[*].middleware.datetime = "2023-06-01 12:35:00"
*.node[*].middleware.services = xmldoc("services.xml")

# Environment Model Configuration
**.identityRegistryModule = "idRegistry"
*.environmentModel.drawObstacles = true
*.environmentModel.drawVehicles = true
*.environmentModel.traciModule = "traci"
*.environmentModel.nodeMobilityModule = ".mobility"
*.node[*].environmentModel.sensors = xmldoc("sensors.xml")


[Config most]
*.traci.nodes.typename = "ExtensibleNodeManager"
*.traci.ignorePersons = false
*.traci.nodes.handleParkingVehicles = true
*.traci.nodes.numVehiclePolicies = 3
# only simulated the inner city area
*.traci.nodes.vehiclePolicy[0].typename = "RegionOfInterestVehiclePolicy"
*.traci.nodes.vehiclePolicy[0].regionsOfInterest = xmldoc("roi_urban.xml")
# remove overlapping vehicles in parking lots
*.traci.nodes.vehiclePolicy[1].typename = "OverlappingVehiclesPolicy"
*.traci.nodes.vehiclePolicy[1].subscriptionManager = "traci.subscriptions"
*.traci.nodes.vehiclePolicy[1].basicNodeManager = "traci.nodes"
# add insertion delay to vehicles
*.traci.nodes.vehiclePolicy[2].typename = "InsertionDelayVehiclePolicy"

*.traci.launcher.sumocfg = ${sumocfg = "MoSTScenario/scenario/most.sumocfg"}
*.traci.launcher.extraOptions = "--step-length 0.1 --default.action-step-length 0.3"
*.traci.launcher.seed = 42 # default

# consider buldings as obstacles for GEMV2 path loss model
*.radioMedium.pathLoss.obstacles.filterTypes = "building building.castle building.church building.commercial building.fort building.yes building.public building.office building.sports_hall building.industrial building.residential"

# consider buldings as obstacles for environment model
*.environmentModel.obstacleTypes = "building building.castle building.church building.commercial building.fort building.yes building.public building.office building.sports_hall building.industrial building.residential"

# scenario offset is 14400s (4AM), simulation takes place at 28800s (8:00AM)
*.traci.core.startTime = ${traciStartTime = 14400}s
#*.traci.core.startTime = ${traciStartTime = 10000}s
warmup-period = ${${traciStartTime}s+$warmupDuration}
sim-time-limit = ${${traciStartTime}s+$warmupDuration+$simulationDuration}



[Config most_overlap]
*.traci.nodes.typename = "ExtensibleNodeManager"
*.traci.ignorePersons = false
*.traci.nodes.handleParkingVehicles = true
*.traci.nodes.numVehiclePolicies = 2
# only simulated the inner city area
*.traci.nodes.vehiclePolicy[0].typename = "RegionOfInterestVehiclePolicy"
*.traci.nodes.vehiclePolicy[0].regionsOfInterest = xmldoc("roi_parking.xml")
# remove overlapping vehicles in parking lots
*.traci.nodes.vehiclePolicy[1].typename = "OverlappingVehiclesPolicy"
*.traci.nodes.vehiclePolicy[1].subscriptionManager = "traci.subscriptions"
*.traci.nodes.vehiclePolicy[1].basicNodeManager = "traci.nodes"
# add insertion delay to vehicles
#*.traci.nodes.vehiclePolicy[2].typename = "InsertionDelayVehiclePolicy"

*.traci.launcher.sumo = "sumo-gui"
*.traci.launcher.sumocfg = ${sumocfg = "MoSTScenario/scenario/most.sumocfg"}
*.traci.launcher.extraOptions = "--step-length 0.1 --default.action-step-length 0.3 --gui-settings-file most.roi_parking.xml"
*.traci.launcher.seed = 42 # default

# consider buldings as obstacles for GEMV2 path loss model
*.radioMedium.pathLoss.obstacles.filterTypes = "building building.castle building.church building.commercial building.fort building.yes building.public building.office building.sports_hall building.industrial building.residential"

# consider buldings as obstacles for environment model
*.environmentModel.obstacleTypes = "building building.castle building.church building.commercial building.fort building.yes building.public building.office building.sports_hall building.industrial building.residential"

# scenario offset is 14400s (4AM), simulation takes place at 28800s (8:00AM)
*.traci.core.startTime = ${traciStartTime = 4000}s
#*.traci.core.startTime = ${traciStartTime = 10000}s
warmup-period = 0s
sim-time-limit = 14400s
9 changes: 9 additions & 0 deletions scenarios/most/roi_parking.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<regions>
<polygon name="parkingArea:1104">
<point x="5118.70" y="2736.36" />
<point x="5066.56" y="2687.10" />
<point x="5091.18" y="2667.70" />
<point x="5144.84" y="2729.62" />
</polygon>
</regions>
11 changes: 11 additions & 0 deletions scenarios/most/roi_urban.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<regions>
<polygon name="urban">
<point x="4182.04" y="379.95" />
<point x="3628.42" y="1368.03" />
<point x="4420.35" y="2851.07" />
<point x="5391.93" y="3798.82" />
<point x="6702.66" y="3974.80" />
<point x="6180.20" y="1793.32" />
</polygon>
</regions>
5 changes: 5 additions & 0 deletions scenarios/most/sensors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<sensors>
<sensor name="FrontShortRangeRadar" type="artery.envmod.sensor.FrontRadar" />
<sensor type="artery.envmod.sensor.CamSensor" />
</sensors>
6 changes: 6 additions & 0 deletions scenarios/most/services.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<services>
<service type="artery.application.CaService" name="CS">
<listener port="2001" />
</service>
</services>
55 changes: 53 additions & 2 deletions src/traci/BasicNodeManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ static const std::set<int> sVehicleVariables {
libsumo::VAR_POSITION, libsumo::VAR_SPEED, libsumo::VAR_ANGLE
};
static const std::set<int> sSimulationVariables {
libsumo::VAR_DEPARTED_VEHICLES_IDS, libsumo::VAR_ARRIVED_VEHICLES_IDS, libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS,
libsumo::VAR_DEPARTED_VEHICLES_IDS,
libsumo::VAR_ARRIVED_VEHICLES_IDS,
libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS,
libsumo::VAR_PARKING_STARTING_VEHICLES_IDS,
libsumo::VAR_PARKING_ENDING_VEHICLES_IDS,
libsumo::VAR_TIME
};

Expand Down Expand Up @@ -81,7 +85,7 @@ void BasicNodeManager::initialize()
m_subscriptions = inet::getModuleFromPar<SubscriptionManager>(par("subscriptionsModule"), this);
m_destroy_vehicles_on_crash = par("destroyVehiclesOnCrash");
m_ignore_persons = par("ignorePersons");

m_handle_parking_vehicles = par("handleParkingVehicles");
}

void BasicNodeManager::finish()
Expand Down Expand Up @@ -123,6 +127,8 @@ void BasicNodeManager::traciStep()
processPersons();
}
emit(updateNodeSignal, getNumberOfNodes());

m_ended_parking_vehicles.clear();
}

void BasicNodeManager::traciClose()
Expand Down Expand Up @@ -157,6 +163,22 @@ void BasicNodeManager::processVehicles()
}
}

if (m_handle_parking_vehicles) {
// handle vehicles that start to park
const auto& parked = sim_cache->get<libsumo::VAR_PARKING_STARTING_VEHICLES_IDS>();
EV_DETAIL << "TraCI: " << parked.size() << " vehicles started parking" << endl;
for (const auto& id : parked) {
startVehicleParking(id);
}

// handle vehicles that end parking
const auto& starting = sim_cache->get<libsumo::VAR_PARKING_ENDING_VEHICLES_IDS>();
EV_DETAIL << "TraCI: " << starting.size() << " vehicles ended parking" << endl;
for (const auto& id : starting) {
endVehicleParking(id);
}
}

for (auto& vehicle : m_vehicles) {
const std::string& id = vehicle.first;
VehicleSink* sink = vehicle.second;
Expand Down Expand Up @@ -188,6 +210,7 @@ void BasicNodeManager::removeVehicle(const std::string& id)
emit(removeVehicleSignal, id.c_str());
removeNodeModule(id);
m_vehicles.erase(id);
m_removed_vehicles.insert(id);
}

void BasicNodeManager::updateVehicle(const std::string& id, VehicleSink* sink)
Expand Down Expand Up @@ -263,6 +286,24 @@ void BasicNodeManager::updatePerson(const std::string& id, PersonSink* sink)
}
}

void BasicNodeManager::startVehicleParking(const std::string& id)
{
/* removeVehicle(id); */
m_parking_vehicles.insert(id);
}

void BasicNodeManager::endVehicleParking(const std::string& id)
{
// check that vehicle is not added again after OverlappingVehiclesPolicy had removed it
auto match = m_removed_vehicles.find(id);
if (match != m_removed_vehicles.end()) {
// vehicle has been removed before, so it can be added again without duplication
addVehicle(id);
}
m_parking_vehicles.erase(id);
m_ended_parking_vehicles.insert(id);
}

cModule* BasicNodeManager::createModule(const std::string&, cModuleType* type)
{
cModule* module = type->create("node", getSystemModule(), m_nodeIndex, m_nodeIndex);
Expand Down Expand Up @@ -352,4 +393,14 @@ PersonSink* BasicNodeManager::getPersonSink(const std::string& id)
return found != m_persons.end() ? found->second : nullptr;
}

std::unordered_set<std::string>& BasicNodeManager::getParkingVehicles()
{
return m_parking_vehicles;
}

std::unordered_set<std::string>& BasicNodeManager::getEndedParkingVehicles()
{
return m_ended_parking_vehicles;
}

} // namespace traci
9 changes: 9 additions & 0 deletions src/traci/BasicNodeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class BasicNodeManager : public NodeManager, public Listener, public omnetpp::cS
std::shared_ptr<API> getAPI() override { return m_api; }
SubscriptionManager* getSubscriptions() { return m_subscriptions; }
std::size_t getNumberOfNodes() const override;
std::unordered_set<std::string>& getParkingVehicles();
std::unordered_set<std::string>& getEndedParkingVehicles();

/**
* VehicleObject wraps variable cache of a subscribed TraCI vehicle
Expand Down Expand Up @@ -76,6 +78,8 @@ class BasicNodeManager : public NodeManager, public Listener, public omnetpp::cS
virtual void addVehicle(const std::string&);
virtual void removeVehicle(const std::string&);
virtual void updateVehicle(const std::string&, VehicleSink*);
virtual void startVehicleParking(const std::string&);
virtual void endVehicleParking(const std::string&);
virtual omnetpp::cModule* createModule(const std::string&, omnetpp::cModuleType*);
virtual omnetpp::cModule* addNodeModule(const std::string&, omnetpp::cModuleType*, NodeInitializer&);
virtual void removeNodeModule(const std::string&);
Expand Down Expand Up @@ -105,6 +109,11 @@ class BasicNodeManager : public NodeManager, public Listener, public omnetpp::cS
bool m_destroy_vehicles_on_crash;
bool m_ignore_persons;
omnetpp::SimTime m_offset = omnetpp::SimTime::ZERO;

bool m_handle_parking_vehicles;
std::unordered_set<std::string> m_parking_vehicles;
std::unordered_set<std::string> m_ended_parking_vehicles;
std::unordered_set<std::string> m_removed_vehicles;
};

} // namespace traci
Expand Down
1 change: 1 addition & 0 deletions src/traci/BasicNodeManager.ned
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ simple BasicNodeManager like NodeManager
string subscriptionsModule;
bool destroyVehiclesOnCrash = default(false);
bool ignorePersons;
bool handleParkingVehicles = default(false);
}
2 changes: 2 additions & 0 deletions src/traci/BasicSubscriptionManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ void BasicSubscriptionManager::traciInit()
VAR_ARRIVED_VEHICLES_IDS,
VAR_DELTA_T,
VAR_TELEPORT_STARTING_VEHICLES_IDS,
VAR_PARKING_STARTING_VEHICLES_IDS,
VAR_PARKING_ENDING_VEHICLES_IDS,
VAR_TIME
};
subscribeSimulationVariables(vars);
Expand Down
2 changes: 2 additions & 0 deletions src/traci/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ set(SOURCES
InsertionDelayVehiclePolicy.cc
Listener.cc
MultiTypeModuleMapper.cc
MultiVClassMultiTypeModuleMapper.cc
OverlappingVehiclesPolicy.cc
PosixLauncher.cc
RegionsOfInterest.cc
RegionOfInterestVehiclePolicy.cc
Expand Down
Loading