Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Person.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2012-2024 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 <vector>
22#include <libsumo/TraCIDefs.h>
23#include <libsumo/VehicleType.h>
24
25
26// ===========================================================================
27// class declarations
28// ===========================================================================
29#ifndef LIBTRACI
30class MSPerson;
31class MSStage;
32struct Reservation;
33class PositionVector;
34#endif
35
36
37// ===========================================================================
38// class definitions
39// ===========================================================================
44namespace LIBSUMO_NAMESPACE {
45class Person {
46public:
47 static double getSpeed(const std::string& personID);
48 static libsumo::TraCIPosition getPosition(const std::string& personID, const bool includeZ = false);
49 static libsumo::TraCIPosition getPosition3D(const std::string& personID);
50 static std::string getRoadID(const std::string& personID);
51 static std::string getLaneID(const std::string& personID);
52 static std::string getTypeID(const std::string& personID);
53 static double getWaitingTime(const std::string& personID);
54 static std::string getNextEdge(const std::string& personID);
55 static std::string getVehicle(const std::string& personID);
56 static int getRemainingStages(const std::string& personID);
57 static libsumo::TraCIStage getStage(const std::string& personID, int nextStageIndex = 0);
58 static std::vector<std::string> getEdges(const std::string& personID, int nextStageIndex = 0);
59 static double getAngle(const std::string& personID);
60 static double getSlope(const std::string& personID);
61 static double getLanePosition(const std::string& personID);
62
63 static std::vector<libsumo::TraCIReservation> getTaxiReservations(int onlyNew = 0);
64 static std::string splitTaxiReservation(std::string reservationID, const std::vector<std::string>& personIDs);
65
68
69 static void add(const std::string& personID, const std::string& edgeID, double pos, double depart = libsumo::DEPARTFLAG_NOW, const std::string typeID = "DEFAULT_PEDTYPE");
70 static void appendStage(const std::string& personID, const libsumo::TraCIStage& stage);
71 static void replaceStage(const std::string& personID, const int stageIndex, const libsumo::TraCIStage& stage);
72 static void appendWaitingStage(const std::string& personID, double duration, const std::string& description = "waiting", const std::string& stopID = "");
73 static void appendWalkingStage(const std::string& personID, const std::vector<std::string>& edges, double arrivalPos, double duration = -1, double speed = -1, const std::string& stopID = "");
74 static void appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID = "");
75 static void removeStage(const std::string& personID, int nextStageIndex);
76 static void rerouteTraveltime(const std::string& personID);
77 static void moveTo(const std::string& personID, const std::string& laneID, double pos, double posLat = libsumo::INVALID_DOUBLE_VALUE);
78 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, double matchThreshold = 100);
79 static void remove(const std::string& personID, char reason = libsumo::REMOVE_VAPORIZED);
80 static void setSpeed(const std::string& personID, double speed);
81 static void setType(const std::string& personID, const std::string& typeID);
82
84
86
87#ifndef LIBTRACI
88#ifndef SWIG
93 static void storeShape(const std::string& id, PositionVector& shape);
94
95 static std::shared_ptr<VariableWrapper> makeWrapper();
96
97 static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData);
98
99private:
100 static MSPerson* getPerson(const std::string& id);
101 static MSStage* convertTraCIStage(const TraCIStage& stage, const std::string personID);
102 static bool filterReservation(int stateFilter, const Reservation* res, std::vector<libsumo::TraCIReservation>& reservations);
103
106 public:
109
111 int operator()(const TraCIReservation& r1, const TraCIReservation& r2) const;
112 };
113
114private:
115 static SubscriptionResults mySubscriptionResults;
116 static ContextSubscriptionResults myContextSubscriptionResults;
117#endif
118#endif
119
120private:
122 Person() = delete;
123
124};
125
126
127}
#define LIBSUMO_ID_PARAMETER_API
Definition TraCIDefs.h:116
#define LIBSUMO_SUBSCRIPTION_API
Definition TraCIDefs.h:62
#define LIBSUMO_VEHICLE_TYPE_GETTER
Definition VehicleType.h:27
#define LIBSUMO_VEHICLE_TYPE_SETTER
Definition VehicleType.h:56
static void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
static std::string splitTaxiReservation(std::string reservationID, const std::vector< std::string > &personIDs)
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:115
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 double getSlope(const std::string &personID)
static libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0)
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.
static std::vector< libsumo::TraCIReservation > getTaxiReservations(int onlyNew=0)
static void appendWalkingStage(const std::string &personID, const std::vector< std::string > &edges, double arrivalPos, double duration=-1, double speed=-1, const std::string &stopID="")
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 std::string getLaneID(const std::string &personID)
static MSPerson * getPerson(const std::string &id)
static void setType(const std::string &personID, const std::string &typeID)
static double getAngle(const std::string &personID)
static std::string getRoadID(const std::string &personID)
Person()=delete
invalidated standard constructor
static int getRemainingStages(const std::string &personID)
static bool filterReservation(int stateFilter, const Reservation *res, std::vector< libsumo::TraCIReservation > &reservations)
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 bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
static void moveTo(const std::string &personID, const std::string &laneID, double pos, double posLat=libsumo::INVALID_DOUBLE_VALUE)
static MSStage * convertTraCIStage(const TraCIStage &stage, const std::string personID)
static ContextSubscriptionResults myContextSubscriptionResults
Definition Person.h:116
static libsumo::TraCIPosition getPosition3D(const std::string &personID)
static void setSpeed(const std::string &personID, double speed)
static void remove(const std::string &personID, char reason=libsumo::REMOVE_VAPORIZED)
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, double matchThreshold=100)
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
A list of positions.
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int DEPARTFLAG_NOW
TRACI_CONST int REMOVE_VAPORIZED
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
Definition TraCIDefs.h:178