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

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

#include <Helper.h>

Collaboration diagram for libsumo::Helper:
Collaboration graph

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 (Position pos)
 
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 const std::vector< std::string > & getVehicleStateChanges (const MSNet::VehicleState state)
 
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, 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, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
 
static bool findCloserLane (const MSEdge *edge, const Position &pos, 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 103 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 437 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(), libsumo::Vehicle::getVehicle(), 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 314 of file Helper.cpp.

Referenced by MSNet::clearAll().

◆ clearVehicleStates()

void libsumo::Helper::clearVehicleStates ( )
static

Definition at line 337 of file Helper.cpp.

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

◆ collectObjectsInRange()

◆ convertCartesianToRoadMap()

◆ findCloserLane()

bool libsumo::Helper::findCloserLane ( const MSEdge edge,
const Position pos,
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 192 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

◆ getVehicleStateChanges()

◆ handleSingleSubscription()

◆ handleSubscriptions()

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

Definition at line 131 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 220 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

helper functions

Definition at line 210 of file Helper.cpp.

Referenced by libsumo::Polygon::getShape(), libsumo::Junction::getShape(), and TraCIServerAPI_Polygon::processSet().

◆ moveToXYMap()

◆ moveToXYMap_matchingRoutePosition()

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

◆ postProcessRemoteControl()

void libsumo::Helper::postProcessRemoteControl ( )
static

Definition at line 754 of file Helper.cpp.

References MSNet::getInstance(), and WRITE_WARNING.

Referenced by MSNet::simulationStep().

◆ registerVehicleStateListener()

void libsumo::Helper::registerVehicleStateListener ( )
static

Definition at line 325 of file Helper.cpp.

References MSNet::addVehicleStateListener(), and MSNet::getInstance().

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

◆ 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

Definition at line 119 of file Helper.cpp.

References INVALID_DOUBLE_VALUE, STEPS2TIME, SUMOTime_MAX, and TIME2STEPS.

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

Field Documentation

◆ myLaneTree

LANE_RTREE_QUAL * libsumo::Helper::myLaneTree
staticprivate

A storage of lanes.

Definition at line 234 of file Helper.h.

◆ myObjects

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

A storage of objects.

Definition at line 231 of file Helper.h.

◆ myRemoteControlledPersons

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

Definition at line 237 of file Helper.h.

◆ myRemoteControlledVehicles

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

Definition at line 236 of file Helper.h.

◆ mySubscriptions

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

The list of known, still valid subscriptions.

Definition at line 222 of file Helper.h.

◆ myVehicleStateListener

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

Changes in the states of simulated vehicles.

Definition at line 228 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 225 of file Helper.h.


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