Eclipse SUMO - Simulation of Urban MObility
MSPModel.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2014-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The pedestrian following model (prototype)
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <cmath>
23 #include <algorithm>
25 #include <microsim/MSNet.h>
26 #include <microsim/MSEdge.h>
27 #include <microsim/MSJunction.h>
28 #include <microsim/MSLane.h>
29 #include <microsim/MSGlobals.h>
30 #include "MSPModel_Striping.h"
32 #include "MSPModel.h"
33 
34 
35 // ===========================================================================
36 // static members
37 // ===========================================================================
38 // named constants
39 const int MSPModel::FORWARD(1);
40 const int MSPModel::BACKWARD(-1);
42 
43 // parameters shared by all models
44 const double MSPModel::SAFETY_GAP(1.0);
45 const double MSPModel::SIDEWALK_OFFSET(3);
46 
47 
48 // ===========================================================================
49 // MSPModel method definitions
50 // ===========================================================================
51 int
52 MSPModel::canTraverse(int dir, const ConstMSEdgeVector& route) {
53  const MSJunction* junction = nullptr;
54  for (ConstMSEdgeVector::const_iterator it = route.begin(); it != route.end(); ++it) {
55  const MSEdge* edge = *it;
56  if (junction != nullptr) {
57  //std::cout << " junction=" << junction->getID() << " edge=" << edge->getID() << "\n";
58  if (junction == edge->getFromJunction()) {
59  dir = FORWARD;
60  } else if (junction == edge->getToJunction()) {
61  dir = BACKWARD;
62  } else {
63  return UNDEFINED_DIRECTION;
64  }
65  }
66  junction = dir == FORWARD ? edge->getToJunction() : edge->getFromJunction();
67  }
68  return dir;
69 }
70 
71 
72 /****************************************************************************/
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
A road/street connecting two junctions.
Definition: MSEdge.h:77
const MSJunction * getFromJunction() const
Definition: MSEdge.h:397
const MSJunction * getToJunction() const
Definition: MSEdge.h:401
The base class for an intersection.
Definition: MSJunction.h:58
static const int BACKWARD
Definition: MSPModel.h:109
static int canTraverse(int dir, const ConstMSEdgeVector &route)
Definition: MSPModel.cpp:52
static const int FORWARD
Definition: MSPModel.h:108
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk
Definition: MSPModel.h:116
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:110
static const double SAFETY_GAP
Definition: MSPModel.h:113