Eclipse SUMO - Simulation of Urban MObility
libsumo::Helper Class Reference

C++ TraCI client API implementation. More...

#include <Helper.h>

Collaboration diagram for libsumo::Helper:

Data Structures

class  LaneUtility
 
class  SubscriptionWrapper
 
class  VehicleStateListener
 

Static Public Member Functions

static void applySubscriptionFilters (const Subscription &s, std::set< std::string > &objIDs)
 Filter the given ID-Set (which was obtained from an R-Tree search) according to the filters set by the subscription or firstly build the object ID list if if the filters rather demand searching along the road network than considering a geometric range. More...
 
static void cleanup ()
 
static void clearVehicleStates ()
 
static void collectObjectsInRange (int domain, const PositionVector &shape, double range, std::set< std::string > &into)
 
static std::pair< MSLane *, double > convertCartesianToRoadMap (const Position &pos, const SUMOVehicleClass vClass)
 
static void findObjectShape (int domain, const std::string &id, PositionVector &shape)
 
static MSEdgegetEdge (const std::string &edgeID)
 
static const MSLanegetLaneChecking (const std::string &edgeID, int laneIndex, double pos)
 
static MSVehiclegetVehicle (const std::string &id)
 
static const std::vector< std::string > & getVehicleStateChanges (const MSNet::VehicleState state)
 
static const MSVehicleTypegetVehicleType (const std::string &vehicleID)
 
static void handleSubscriptions (const SUMOTime t)
 
static Position makePosition (const TraCIPosition &position)
 
static PositionVector makePositionVector (const TraCIPositionVector &vector)
 
static RGBColor makeRGBColor (const TraCIColor &color)
 
static TraCIColor makeTraCIColor (const RGBColor &color)
 
static TraCIPosition makeTraCIPosition (const Position &position, const bool includeZ=false)
 
static TraCIPositionVector makeTraCIPositionVector (const PositionVector &positionVector)
 helper functions More...
 
static void postProcessRemoteControl ()
 
static void registerVehicleStateListener ()
 
static void setRemoteControlled (MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
 
static void setRemoteControlled (MSPerson *p, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
 
static void subscribe (const int commandId, const std::string &id, const std::vector< int > &variables, const double beginTime, const double endTime, const int contextDomain=0, const double range=0.)
 
functions for moveToXY
static bool moveToXYMap (const Position &pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string &origID, const double angle, double speed, const ConstMSEdgeVector &currentRoute, const int routePosition, MSLane *currentLane, double currentLanePos, bool onRoad, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
 
static bool moveToXYMap_matchingRoutePosition (const Position &pos, const std::string &origID, const ConstMSEdgeVector &currentRoute, int routeIndex, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
 
static bool findCloserLane (const MSEdge *edge, const Position &pos, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane)
 

Private Member Functions

 Helper ()=delete
 invalidated standard constructor More...
 

Static Private Member Functions

static void fuseLaneCoverage (std::shared_ptr< LaneCoverageInfo > aggregatedLaneCoverage, const std::shared_ptr< LaneCoverageInfo > newLaneCoverage)
 Adds lane coverage information from newLaneCoverage into aggregatedLaneCoverage. More...
 
static void handleSingleSubscription (const Subscription &s)
 

Static Private Attributes

static LANE_RTREE_QUALmyLaneTree
 A storage of lanes. More...
 
static std::map< int, NamedRTree * > myObjects
 A storage of objects. More...
 
static std::map< std::string, MSPerson * > myRemoteControlledPersons
 
static std::map< std::string, MSVehicle * > myRemoteControlledVehicles
 
static std::vector< SubscriptionmySubscriptions
 The list of known, still valid subscriptions. More...
 
static VehicleStateListener myVehicleStateListener
 Changes in the states of simulated vehicles. More...
 
static std::map< int, std::shared_ptr< VariableWrapper > > myWrapper
 Map of commandIds -> their executors; applicable if the executor applies to the method footprint. More...
 

Detailed Description

C++ TraCI client API implementation.

Definition at line 106 of file Helper.h.

Constructor & Destructor Documentation

◆ Helper()

libsumo::Helper::Helper ( )
privatedelete

invalidated standard constructor

Member Function Documentation

◆ applySubscriptionFilters()

void libsumo::Helper::applySubscriptionFilters ( const Subscription s,
std::set< std::string > &  objIDs 
)
static

Filter the given ID-Set (which was obtained from an R-Tree search) according to the filters set by the subscription or firstly build the object ID list if if the filters rather demand searching along the road network than considering a geometric range.

Parameters
[in]sSubscription which holds the filter specification to be applied

Definition at line 484 of file Helper.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterDownstreamDist, libsumo::Subscription::filterLanes, libsumo::Subscription::filterUpstreamDist, libsumo::Subscription::filterVClasses, libsumo::Subscription::filterVTypes, MSLink::getApproaching(), MSVehicle::getBestLanesContinuation(), MSLane::getEdge(), MSLane::getFollower(), Named::getID(), MSBaseVehicle::getID(), MSVehicleType::getID(), MSLane::getIndex(), MSVehicle::getLane(), MSEdge::getLanes(), MSLane::getLeader(), MSBaseVehicle::getLength(), MSLane::getLength(), MSEdge::getLength(), MSEdge::getOppositeEdge(), MSLane::getParallelLane(), MSVehicle::getPositionOnLane(), MSLane::getSurroundingVehicles(), MSLane::getUpcomingLinks(), MSVehicleType::getVehicleClass(), MSLane::getVehiclesInRange(), MSBaseVehicle::getVehicleType(), libsumo::Subscription::id, MSVehicle::isOnRoad(), MAX2(), libsumo::Subscription::range, SIMTIME, libsumo::SUBS_FILTER_DOWNSTREAM_DIST, libsumo::SUBS_FILTER_LANES, libsumo::SUBS_FILTER_LEAD_FOLLOW, libsumo::SUBS_FILTER_MANEUVER, libsumo::SUBS_FILTER_NO_RTREE, libsumo::SUBS_FILTER_NOOPPOSITE, libsumo::SUBS_FILTER_TURN, libsumo::SUBS_FILTER_UPSTREAM_DIST, libsumo::SUBS_FILTER_VCLASS, libsumo::SUBS_FILTER_VTYPE, toString(), and WRITE_WARNING.

Referenced by TraCIServer::processSingleSubscription().

◆ cleanup()

void libsumo::Helper::cleanup ( )
static

Definition at line 359 of file Helper.cpp.

Referenced by MSNet::clearAll().

◆ clearVehicleStates()

void libsumo::Helper::clearVehicleStates ( )
static

Definition at line 384 of file Helper.cpp.

Referenced by libsumo::Simulation::step().

◆ collectObjectsInRange()

◆ convertCartesianToRoadMap()

◆ findCloserLane()

bool libsumo::Helper::findCloserLane ( const MSEdge edge,
const Position pos,
SUMOVehicleClass  vClass,
double &  bestDistance,
MSLane **  lane 
)
static

◆ findObjectShape()

◆ fuseLaneCoverage()

void libsumo::Helper::fuseLaneCoverage ( std::shared_ptr< LaneCoverageInfo aggregatedLaneCoverage,
const std::shared_ptr< LaneCoverageInfo newLaneCoverage 
)
staticprivate

Adds lane coverage information from newLaneCoverage into aggregatedLaneCoverage.

Parameters

Definition at line 206 of file Helper.cpp.

References MAX2(), and MIN2().

◆ getEdge()

MSEdge * libsumo::Helper::getEdge ( const std::string &  edgeID)
static

◆ getLaneChecking()

const MSLane * libsumo::Helper::getLaneChecking ( const std::string &  edgeID,
int  laneIndex,
double  pos 
)
static

◆ getVehicle()

MSVehicle * libsumo::Helper::getVehicle ( const std::string &  id)
static

Definition at line 339 of file Helper.cpp.

References MSNet::getInstance(), MSVehicleControl::getVehicle(), and MSNet::getVehicleControl().

Referenced by libsumo::Vehicle::changeLane(), libsumo::Vehicle::changeLaneRelative(), libsumo::Vehicle::changeSublane(), libsumo::Vehicle::changeTarget(), libsumo::Vehicle::deactivateGapControl(), libsumo::Vehicle::getAcceleration(), libsumo::Vehicle::getAccumulatedWaitingTime(), libsumo::Vehicle::getAdaptedTraveltime(), libsumo::Vehicle::getAllowedSpeed(), libsumo::Vehicle::getAngle(), libsumo::Vehicle::getBestLanes(), libsumo::Vehicle::getCO2Emission(), libsumo::Vehicle::getCOEmission(), libsumo::Vehicle::getDistance(), libsumo::Vehicle::getDrivingDistance(), libsumo::Vehicle::getDrivingDistance2D(), libsumo::Vehicle::getEffort(), libsumo::Vehicle::getElectricityConsumption(), libsumo::Vehicle::getFuelConsumption(), libsumo::Vehicle::getHCEmission(), libsumo::Vehicle::getLaneChangeMode(), libsumo::Vehicle::getLaneChangeState(), libsumo::Vehicle::getLaneID(), libsumo::Vehicle::getLaneIndex(), libsumo::Vehicle::getLanePosition(), libsumo::Vehicle::getLastActionTime(), libsumo::Vehicle::getLateralLanePosition(), libsumo::Vehicle::getLateralSpeed(), libsumo::Vehicle::getLeader(), libsumo::Vehicle::getLine(), libsumo::Vehicle::getNeighbors(), libsumo::Vehicle::getNextStops(), libsumo::Vehicle::getNextTLS(), libsumo::Vehicle::getNoiseEmission(), libsumo::Vehicle::getNOxEmission(), libsumo::Vehicle::getParameter(), libsumo::Vehicle::getPersonIDList(), libsumo::Vehicle::getPersonNumber(), libsumo::Vehicle::getPMxEmission(), libsumo::Vehicle::getPosition(), libsumo::Vehicle::getRoadID(), libsumo::Vehicle::getRoute(), libsumo::Vehicle::getRouteID(), libsumo::Vehicle::getRouteIndex(), libsumo::Vehicle::getRoutingMode(), libsumo::Vehicle::getSignals(), libsumo::Vehicle::getSlope(), libsumo::Vehicle::getSpeed(), libsumo::Vehicle::getSpeedMode(), libsumo::Vehicle::getSpeedWithoutTraCI(), libsumo::Vehicle::getStopState(), libsumo::Vehicle::getVia(), libsumo::Vehicle::getWaitingTime(), libsumo::Vehicle::highlight(), libsumo::Vehicle::isRouteValid(), libsumo::Vehicle::moveTo(), libsumo::Vehicle::moveToXY(), libsumo::Vehicle::openGap(), libsumo::Vehicle::remove(), libsumo::Vehicle::rerouteEffort(), libsumo::Vehicle::rerouteParkingArea(), libsumo::Vehicle::rerouteTraveltime(), libsumo::Vehicle::resume(), libsumo::Vehicle::setAdaptedTraveltime(), libsumo::Vehicle::setEffort(), libsumo::Vehicle::setLaneChangeMode(), libsumo::Vehicle::setLine(), libsumo::Vehicle::setParameter(), libsumo::Vehicle::setRoute(), libsumo::Vehicle::setRouteID(), libsumo::Vehicle::setRoutingMode(), libsumo::Vehicle::setSignals(), libsumo::Vehicle::setSpeed(), libsumo::Vehicle::setSpeedMode(), libsumo::Vehicle::setStop(), libsumo::Vehicle::setType(), libsumo::Vehicle::setVia(), libsumo::Vehicle::slowDown(), libsumo::Vehicle::storeShape(), and libsumo::Vehicle::updateBestLanes().

◆ getVehicleStateChanges()

◆ getVehicleType()

const MSVehicleType & libsumo::Helper::getVehicleType ( const std::string &  vehicleID)
static

◆ handleSingleSubscription()

◆ handleSubscriptions()

void libsumo::Helper::handleSubscriptions ( const SUMOTime  t)
static

Definition at line 133 of file Helper.cpp.

Referenced by libsumo::Simulation::step().

◆ makePosition()

Position libsumo::Helper::makePosition ( const TraCIPosition position)
static

◆ makePositionVector()

PositionVector libsumo::Helper::makePositionVector ( const TraCIPositionVector vector)
static

Definition at line 234 of file Helper.cpp.

Referenced by libsumo::Polygon::add(), and libsumo::Polygon::setShape().

◆ makeRGBColor()

◆ makeTraCIColor()

◆ makeTraCIPosition()

◆ makeTraCIPositionVector()

TraCIPositionVector libsumo::Helper::makeTraCIPositionVector ( const PositionVector positionVector)
static

◆ moveToXYMap()

bool libsumo::Helper::moveToXYMap ( const Position pos,
double  maxRouteDistance,
bool  mayLeaveNetwork,
const std::string &  origID,
const double  angle,
double  speed,
const ConstMSEdgeVector currentRoute,
const int  routePosition,
MSLane currentLane,
double  currentLanePos,
bool  onRoad,
SUMOVehicleClass  vClass,
double &  bestDistance,
MSLane **  lane,
double &  lanePos,
int &  routeOffset,
ConstMSEdgeVector edges 
)
static

◆ moveToXYMap_matchingRoutePosition()

bool libsumo::Helper::moveToXYMap_matchingRoutePosition ( const Position pos,
const std::string &  origID,
const ConstMSEdgeVector currentRoute,
int  routeIndex,
SUMOVehicleClass  vClass,
double &  bestDistance,
MSLane **  lane,
double &  lanePos,
int &  routeOffset 
)
static

◆ postProcessRemoteControl()

void libsumo::Helper::postProcessRemoteControl ( )
static

Definition at line 801 of file Helper.cpp.

References MSNet::getInstance(), and WRITE_WARNING.

Referenced by MSNet::simulationStep().

◆ registerVehicleStateListener()

void libsumo::Helper::registerVehicleStateListener ( )
static

◆ setRemoteControlled() [1/2]

void libsumo::Helper::setRemoteControlled ( MSVehicle v,
Position  xyPos,
MSLane l,
double  pos,
double  posLat,
double  angle,
int  edgeOffset,
ConstMSEdgeVector  route,
SUMOTime  t 
)
static

◆ setRemoteControlled() [2/2]

void libsumo::Helper::setRemoteControlled ( MSPerson p,
Position  xyPos,
MSLane l,
double  pos,
double  posLat,
double  angle,
int  edgeOffset,
ConstMSEdgeVector  route,
SUMOTime  t 
)
static

◆ subscribe()

void libsumo::Helper::subscribe ( const int  commandId,
const std::string &  id,
const std::vector< int > &  variables,
const double  beginTime,
const double  endTime,
const int  contextDomain = 0,
const double  range = 0. 
)
static

Field Documentation

◆ myLaneTree

LANE_RTREE_QUAL * libsumo::Helper::myLaneTree
staticprivate

A storage of lanes.

Definition at line 244 of file Helper.h.

◆ myObjects

std::map< int, NamedRTree * > libsumo::Helper::myObjects
staticprivate

A storage of objects.

Definition at line 241 of file Helper.h.

◆ myRemoteControlledPersons

std::map< std::string, MSPerson * > libsumo::Helper::myRemoteControlledPersons
staticprivate

Definition at line 247 of file Helper.h.

◆ myRemoteControlledVehicles

std::map< std::string, MSVehicle * > libsumo::Helper::myRemoteControlledVehicles
staticprivate

Definition at line 246 of file Helper.h.

◆ mySubscriptions

std::vector< Subscription > libsumo::Helper::mySubscriptions
staticprivate

The list of known, still valid subscriptions.

Definition at line 232 of file Helper.h.

◆ myVehicleStateListener

Helper::VehicleStateListener libsumo::Helper::myVehicleStateListener
staticprivate

Changes in the states of simulated vehicles.

Definition at line 238 of file Helper.h.

◆ myWrapper

std::map< int, std::shared_ptr< VariableWrapper > > libsumo::Helper::myWrapper
staticprivate

Map of commandIds -> their executors; applicable if the executor applies to the method footprint.

Definition at line 235 of file Helper.h.


The documentation for this class was generated from the following files: