Eclipse SUMO - Simulation of Urban MObility
Person.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2020 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 // C++ TraCI client API implementation
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <vector>
24 #include <libsumo/TraCIDefs.h>
25 #include <libsumo/VehicleType.h>
26 #ifndef LIBTRACI
28 #endif
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 #ifndef LIBTRACI
35 class MSPerson;
36 class PositionVector;
37 namespace libsumo {
38 class VariableWrapper;
39 }
40 #endif
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
50 namespace LIBSUMO_NAMESPACE {
51 class Person {
52 public:
53  static double getSpeed(const std::string& personID);
54  static libsumo::TraCIPosition getPosition(const std::string& personID, const bool includeZ = false);
55  static libsumo::TraCIPosition getPosition3D(const std::string& personID);
56  static std::string getRoadID(const std::string& personID);
57  static std::string getLaneID(const std::string& personID);
58  static std::string getTypeID(const std::string& personID);
59  static double getWaitingTime(const std::string& personID);
60  static std::string getNextEdge(const std::string& personID);
61  static std::string getVehicle(const std::string& personID);
62  static int getRemainingStages(const std::string& personID);
63  static libsumo::TraCIStage getStage(const std::string& personID, int nextStageIndex = 0);
64  static std::vector<std::string> getEdges(const std::string& personID, int nextStageIndex = 0);
65  static double getAngle(const std::string& personID);
66  static double getSlope(const std::string& personID);
67  static double getLanePosition(const std::string& personID);
68 
69  static std::vector<libsumo::TraCIReservation> getTaxiReservations(int onlyNew = false);
70 
73 
74  static void add(const std::string& personID, const std::string& edgeID, double pos, double depart = libsumo::DEPARTFLAG_NOW, const std::string typeID = "DEFAULT_PEDTYPE");
75  static void appendStage(const std::string& personID, const libsumo::TraCIStage& stage);
76  static void replaceStage(const std::string& personID, const int stageIndex, const libsumo::TraCIStage& stage);
77  static void appendWaitingStage(const std::string& personID, double duration, const std::string& description = "waiting", const std::string& stopID = "");
78  static void appendWalkingStage(const std::string& personID, const std::vector<std::string>& edgeIDs, double arrivalPos, double duration = -1, double speed = -1, const std::string& stopID = "");
79  static void appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID = "");
80  static void removeStage(const std::string& personID, int nextStageIndex);
81  static void rerouteTraveltime(const std::string& personID);
82  static void moveTo(const std::string& personID, const std::string& edgeID, double position);
83  static void moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle = libsumo::INVALID_DOUBLE_VALUE, const int keepRoute = 1);
84  static void setSpeed(const std::string& personID, double speed);
85  static void setType(const std::string& personID, const std::string& typeID);
86 
88 
90 
91 #ifndef LIBTRACI
96  static void storeShape(const std::string& id, PositionVector& shape);
97 
98  static std::shared_ptr<VariableWrapper> makeWrapper();
99 
100  static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper);
101 
102 private:
103  static MSPerson* getPerson(const std::string& id);
104  static MSStage* convertTraCIStage(const TraCIStage& stage, const std::string personID);
105 
106 private:
109 #endif
110 
111 private:
113  Person() = delete;
114 
115 };
116 
117 
118 }
#define LIBSUMO_ID_PARAMETER_API
Definition: TraCIDefs.h:97
#define LIBSUMO_SUBSCRIPTION_API
Definition: TraCIDefs.h:44
#define LIBSUMO_VEHICLE_TYPE_GETTER
Definition: VehicleType.h:27
#define LIBSUMO_VEHICLE_TYPE_SETTER
Definition: VehicleType.h:51
static void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
static std::shared_ptr< VariableWrapper > makeWrapper()
static double getSpeed(const std::string &personID)
static double getLanePosition(const std::string &personID)
static void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
static SubscriptionResults mySubscriptionResults
Definition: Person.h:107
static libsumo::TraCIPosition getPosition(const std::string &personID, const bool includeZ=false)
static double getWaitingTime(const std::string &personID)
static void removeStage(const std::string &personID, int nextStageIndex)
static void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
static void moveToXY(const std::string &personID, const std::string &edgeID, const double x, const double y, double angle=libsumo::INVALID_DOUBLE_VALUE, const int keepRoute=1)
static double getSlope(const std::string &personID)
static libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0)
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
static std::string getVehicle(const std::string &personID)
LIBSUMO_VEHICLE_TYPE_SETTER static LIBSUMO_SUBSCRIPTION_API void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
LIBSUMO_ID_PARAMETER_API static LIBSUMO_VEHICLE_TYPE_GETTER void add(const std::string &personID, const std::string &edgeID, double pos, double depart=libsumo::DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
static void moveTo(const std::string &personID, const std::string &edgeID, double position)
static std::string getLaneID(const std::string &personID)
static MSPerson * getPerson(const std::string &id)
static void appendWalkingStage(const std::string &personID, const std::vector< std::string > &edgeIDs, double arrivalPos, double duration=-1, double speed=-1, const std::string &stopID="")
static void setType(const std::string &personID, const std::string &typeID)
static double getAngle(const std::string &personID)
static std::vector< libsumo::TraCIReservation > getTaxiReservations(int onlyNew=false)
static std::string getRoadID(const std::string &personID)
Person()=delete
invalidated standard constructor
static int getRemainingStages(const std::string &personID)
static std::string getTypeID(const std::string &personID)
static void replaceStage(const std::string &personID, const int stageIndex, const libsumo::TraCIStage &stage)
static void rerouteTraveltime(const std::string &personID)
static std::string getNextEdge(const std::string &personID)
static MSStage * convertTraCIStage(const TraCIStage &stage, const std::string personID)
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Person.h:108
static libsumo::TraCIPosition getPosition3D(const std::string &personID)
static void setSpeed(const std::string &personID, double speed)
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
A list of positions.
TRACI_CONST double INVALID_DOUBLE_VALUE
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:250
TRACI_CONST int DEPARTFLAG_NOW
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:251
A 3D-position.
Definition: TraCIDefs.h:141