Skip to content

Commit

Permalink
Add a subproject "veins_inet" which uses Veins to drive mobility in I…
Browse files Browse the repository at this point in the history
…NET 3.4.0

...and remove support for INET 2.3.0
  • Loading branch information
sommer committed Jan 24, 2017
1 parent 8e83ad2 commit 90d4586
Show file tree
Hide file tree
Showing 38 changed files with 1,297 additions and 137 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,18 @@ tests/**/err.tmp

examples/**/results
examples/**/.tkenvrc
examples/**/.cmdenv-log
examples/**/valgrind.out

subprojects/veins_inet/src/Makefile
subprojects/veins_inet/src/*.so
subprojects/veins_inet/src/**/*_m.h
subprojects/veins_inet/src/**/*_m.cc
subprojects/veins_inet/out
subprojects/veins_inet/run
subprojects/veins_inet/debug
subprojects/veins_inet/memcheck
subprojects/veins_inet/examples/**/results
subprojects/veins_inet/examples/**/.tkenvrc
subprojects/veins_inet/examples/**/.cmdenv-log
subprojects/veins_inet/examples/**/valgrind.out
26 changes: 0 additions & 26 deletions .oppfeatures

This file was deleted.

31 changes: 5 additions & 26 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ Creates Makefile(s) for building Veins.

import os
import sys
from subprocess import check_call
import subprocess
from logging import warning, error
from optparse import OptionParser
import fnmatch


# Option handling
parser = OptionParser()
parser.add_option("--with-inet", dest="inet", help="link Veins with a version of the INET Framework installed in PATH [default: do not link with INET]", metavar="PATH")
parser.add_option("--with-inet", dest="inet", help='Option discontinued in favor of a subproject in subprojects/veins_inet/')
(options, args) = parser.parse_args()

if args:
Expand All @@ -27,31 +26,11 @@ run_libs = [os.path.join('src', 'veins')]
run_neds = [os.path.join('src', 'veins')]


# Add flags for INET
# --with-inet has been discontinued
if options.inet:
fname = os.path.join(options.inet, 'Version')
try:
with open(fname, 'r') as file:
version = file.read().rstrip()
if not version == 'inet-2.3.0':
warning('Unsupported INET Version. Expecting inet-2.3.0, found "%s"' % version)
except IOError as e:
error('Could not determine INET Version (from file %s): %s. Check the path to INET and the INET version (should be 2.3.0)' % (fname, e))
error('--with-inet has been discontinued in favor of a subproject in subprojects/veins_inet/')
sys.exit(1)

inet_header_dirs = set()
inet_src_path = os.path.join(options.inet, 'src')
for root, dirnames, filenames in os.walk(inet_src_path):
for filename in fnmatch.filter(filenames, '*.h'):
inet_header_dirs.add(os.path.relpath(os.path.dirname(os.path.join(root, filename)), 'src'))
inet_includes = ['-I' + s for s in inet_header_dirs]
inet_link = ["-L" + os.path.join(os.path.relpath(options.inet, 'src'), 'src'), "-linet"]
inet_defs = ["-DINET_IMPORT", "-DWITH_INET"]

makemake_flags += inet_includes + inet_link + inet_defs
run_libs = [os.path.relpath(os.path.join(options.inet, 'src', 'inet'))] + run_libs
run_neds = [os.path.relpath(os.path.join(options.inet, 'src'))] + run_neds


# Start creating files
if not os.path.isdir('out'):
Expand All @@ -62,6 +41,6 @@ f.write('run_libs = %s\n' % repr(run_libs))
f.write('run_neds = %s\n' % repr(run_neds))
f.close()

check_call(['env', 'opp_makemake'] + makemake_flags, cwd='src')
subprocess.check_call(['env', 'opp_makemake'] + makemake_flags, cwd='src')

print 'Configure done. You can now run "make".'
7 changes: 0 additions & 7 deletions src/veins/base/utils/Coord.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
* part of: framework implementation developed by tkn
**************************************************************************/

// if we're linking with the INET Framework, Coord.cc is provided by there...
#ifdef WITH_INET
#else
// ...otherwise we provide our own in this file.

#include "assert.h"
#include "Coord.h"

Expand Down Expand Up @@ -52,5 +47,3 @@ double Coord::sqrTorusDist(const Coord& b, const Coord& size) const {
double zDist = dist(z, b.z, size.z);
return xDist * xDist + yDist * yDist + zDist * zDist;
}

#endif // WITH_INET
11 changes: 1 addition & 10 deletions src/veins/base/utils/Coord.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@
**************************************************************************/


// if we're linking with the INET Framework, Coord.h is provided by there...
#ifdef WITH_INET
#include "base/Coord.h"
#else
// ...otherwise we provide our own in this file.

#ifndef _COORD_H
#define _COORD_H

#include <omnetpp.h>
#include "veins/base/utils/MiXiMDefs.h"
#include "FWMath.h"
#include "veins/base/utils/FWMath.h"


/**
Expand Down Expand Up @@ -254,6 +248,3 @@ inline std::string Coord::info() const {
}

#endif


#endif // WITH_INET
7 changes: 0 additions & 7 deletions src/veins/base/utils/FWMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
* part of: framework implementation developed by tkn
**************************************************************************/

// if we're linking with the INET Framework, FWMath.h is provided by there...
#ifdef WITH_INET
#else
// ...otherwise we provide our own in this file.

#ifndef FWMATH_H
#define FWMATH_H

Expand Down Expand Up @@ -174,5 +169,3 @@ class MIXIM_API FWMath {
};

#endif

#endif // WITH_INET
54 changes: 29 additions & 25 deletions src/veins/modules/mobility/traci/TraCIScenarioManager.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2006-2012 Christoph Sommer <christoph.sommer@uibk.ac.at>
// Copyright (C) 2006-2017 Christoph Sommer <sommer@ccs-labs.org>
//
// Documentation for these modules is at http://veins.car2x.org/
//
Expand Down Expand Up @@ -31,7 +31,6 @@
#include "veins/modules/mobility/traci/TraCIConstants.h"
#include "veins/modules/mobility/traci/TraCIMobility.h"
#include "veins/modules/obstacle/ObstacleControl.h"
#include "veins/modules/mobility/traci/TraCIScenarioManagerInet.h"

using Veins::TraCIScenarioManager;
using Veins::TraCIBuffer;
Expand Down Expand Up @@ -240,10 +239,8 @@ void TraCIScenarioManager::initialize(int stage) {
autoShutdownTriggered = false;

world = FindModule<BaseWorldUtility*>::findGlobalModule();
if (world == NULL) error("Could not find BaseWorldUtility module");

cc = FindModule<BaseConnectionManager*>::findGlobalModule();
if (cc == NULL) error("Could not find BaseConnectionManager module");

ASSERT(firstStepAt > connectAt);
connectAndStartTrigger = new cMessage("connect");
Expand Down Expand Up @@ -287,7 +284,9 @@ void TraCIScenarioManager::init_traci() {
TraCICoord netbounds2 = TraCICoord(x2, y2);
MYDEBUG << "TraCI reports network boundaries (" << x1 << ", " << y1 << ")-(" << x2 << ", " << y2 << ")" << endl;
connection->setNetbounds(netbounds1, netbounds2, par("margin"));
if ((connection->traci2omnet(netbounds2).x > world->getPgs()->x) || (connection->traci2omnet(netbounds1).y > world->getPgs()->y)) MYDEBUG << "WARNING: Playground size (" << world->getPgs()->x << ", " << world->getPgs()->y << ") might be too small for vehicle at network bounds (" << connection->traci2omnet(netbounds2).x << ", " << connection->traci2omnet(netbounds1).y << ")" << endl;
if (world && ((connection->traci2omnet(netbounds2).x > world->getPgs()->x) || (connection->traci2omnet(netbounds1).y > world->getPgs()->y))) {
MYDEBUG << "WARNING: Playground size (" << world->getPgs()->x << ", " << world->getPgs()->y << ") might be too small for vehicle at network bounds (" << connection->traci2omnet(netbounds2).x << ", " << connection->traci2omnet(netbounds1).y << ")" << endl;
}
}

{
Expand Down Expand Up @@ -397,10 +396,28 @@ void TraCIScenarioManager::handleSelfMsg(cMessage *msg) {
error("TraCIScenarioManager received unknown self-message");
}

void TraCIScenarioManager::preInitializeModule(cModule* mod, const std::string& nodeId, const Coord& position, const std::string& road_id, double speed, double angle, VehicleSignal signals) {
// pre-initialize TraCIMobility
for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) {
cModule* submod = SUBMODULE_ITERATOR_TO_MODULE(iter);
TraCIMobility* mm = dynamic_cast<TraCIMobility*>(submod);
if (!mm) continue;
mm->preInitialize(nodeId, position, road_id, speed, angle);
}
}

void TraCIScenarioManager::updateModulePosition(cModule* mod, const Coord& p, const std::string& edge, double speed, double angle, VehicleSignal signals) {
// update position in TraCIMobility
for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) {
cModule* submod = SUBMODULE_ITERATOR_TO_MODULE(iter);
TraCIMobility* mm = dynamic_cast<TraCIMobility*>(submod);
if (!mm) continue;
mm->nextPosition(p, edge, speed, angle, signals);
}
}

// name: host;Car;i=vehicle.gif
void TraCIScenarioManager::addModule(std::string nodeId, std::string type, std::string name, std::string displayString, const Coord& position, std::string road_id, double speed, double angle) {
void TraCIScenarioManager::addModule(std::string nodeId, std::string type, std::string name, std::string displayString, const Coord& position, std::string road_id, double speed, double angle, VehicleSignal signals) {

if (hosts.find(nodeId) != hosts.end()) error("tried adding duplicate module");

Expand Down Expand Up @@ -430,14 +447,7 @@ void TraCIScenarioManager::addModule(std::string nodeId, std::string type, std::
mod->buildInside();
mod->scheduleStart(simTime() + updateInterval);

// pre-initialize TraCIMobility
for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) {
cModule* submod = SUBMODULE_ITERATOR_TO_MODULE(iter);
ifInetTraCIMobilityCallPreInitialize(submod, nodeId, position, road_id, speed, angle);
TraCIMobility* mm = dynamic_cast<TraCIMobility*>(submod);
if (!mm) continue;
mm->preInitialize(nodeId, position, road_id, speed, angle);
}
preInitializeModule(mod, nodeId, position, road_id, speed, angle, signals);

mod->callInitialize();
hosts[nodeId] = mod;
Expand Down Expand Up @@ -466,8 +476,8 @@ void TraCIScenarioManager::deleteManagedModule(std::string nodeId) {
if (!mod) error("no vehicle with Id \"%s\" found", nodeId.c_str());

cModule* nic = mod->getSubmodule("nic");
if (nic) {
cc->unregisterNic(nic);
if (cc && nic) {
cc->unregisterNic(nic);
}

hosts.erase(nodeId);
Expand Down Expand Up @@ -877,19 +887,13 @@ void TraCIScenarioManager::processVehicleSubscription(std::string objectId, TraC
}

if (mType != "0") {
addModule(objectId, mType, mName, mDisplayString, p, edge, speed, angle);
addModule(objectId, mType, mName, mDisplayString, p, edge, speed, angle, VehicleSignal(signals));
MYDEBUG << "Added vehicle #" << objectId << endl;
}
} else {
// module existed - update position
for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) {
cModule* submod = SUBMODULE_ITERATOR_TO_MODULE(iter);
ifInetTraCIMobilityCallNextPosition(submod, p, edge, speed, angle);
TraCIMobility* mm = dynamic_cast<TraCIMobility*>(submod);
if (!mm) continue;
MYDEBUG << "module " << objectId << " moving to " << p.x << "," << p.y << endl;
mm->nextPosition(p, edge, speed, angle, VehicleSignal(signals));
}
MYDEBUG << "module " << objectId << " moving to " << p.x << "," << p.y << endl;
updateModulePosition(mod, p, edge, speed, angle, VehicleSignal(signals));
}

}
Expand Down
6 changes: 4 additions & 2 deletions src/veins/modules/mobility/traci/TraCIScenarioManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2006-2012 Christoph Sommer <christoph.sommer@uibk.ac.at>
// Copyright (C) 2006-2017 Christoph Sommer <sommer@ccs-labs.org>
//
// Documentation for these modules is at http://veins.car2x.org/
//
Expand Down Expand Up @@ -153,7 +153,9 @@ class TraCIScenarioManager : public cSimpleModule

virtual void init_traci();

void addModule(std::string nodeId, std::string type, std::string name, std::string displayString, const Coord& position, std::string road_id = "", double speed = -1, double angle = -1);
virtual void preInitializeModule(cModule* mod, const std::string& nodeId, const Coord& position, const std::string& road_id, double speed, double angle, VehicleSignal signals);
virtual void updateModulePosition(cModule* mod, const Coord& p, const std::string& edge, double speed, double angle, VehicleSignal signals);
void addModule(std::string nodeId, std::string type, std::string name, std::string displayString, const Coord& position, std::string road_id = "", double speed = -1, double angle = -1, VehicleSignal signals = VehicleSignal::VEH_SIGNAL_UNDEF);
cModule* getManagedModule(std::string nodeId); /**< returns a pointer to the managed module named moduleName, or 0 if no module can be found */
void deleteManagedModule(std::string nodeId);

Expand Down
32 changes: 0 additions & 32 deletions src/veins/modules/mobility/traci/TraCIScenarioManagerInet.cc

This file was deleted.

2 changes: 0 additions & 2 deletions src/veins/modules/mobility/traci/TraCIScenarioManagerInet.h

This file was deleted.

0 comments on commit 90d4586

Please sign in to comment.