Eclipse SUMO - Simulation of Urban MObility
libtraci/Person.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2017-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 #include <config.h>
21 
22 #define LIBTRACI 1
23 #include "Domain.h"
24 #include <libsumo/Person.h>
25 
26 // TODO remove the following lines once the implementation is mature
27 #ifdef _MSC_VER
28 #pragma warning(disable: 4100)
29 #else
30 #pragma GCC diagnostic ignored "-Wunused-parameter"
31 #endif
32 
33 namespace libtraci {
34 
35 typedef Domain<libsumo::CMD_GET_PERSON_VARIABLE, libsumo::CMD_SET_PERSON_VARIABLE> Dom;
36 
37 // ===========================================================================
38 // static member definitions
39 // ===========================================================================
40 std::vector<std::string>
41 Person::getIDList() {
43 }
44 
45 
46 int
47 Person::getIDCount() {
48  return Dom::getInt(libsumo::ID_COUNT, "");
49 }
50 
51 
53 Person::getPosition(const std::string& personID, const bool includeZ) {
54  return includeZ ? getPosition3D(personID) : Dom::getPos(libsumo::VAR_POSITION, personID);
55 }
56 
57 
59 Person::getPosition3D(const std::string& personID) {
60  return Dom::getPos3D(libsumo::VAR_POSITION3D, personID);
61 }
62 
63 
64 double
65 Person::getAngle(const std::string& personID) {
66  return Dom::getDouble(libsumo::VAR_ANGLE, personID);
67 }
68 
69 
70 double
71 Person::getSlope(const std::string& personID) {
72  return Dom::getDouble(libsumo::VAR_SLOPE, personID);
73 }
74 
75 
76 double
77 Person::getSpeed(const std::string& personID) {
78  return Dom::getDouble(libsumo::VAR_SPEED, personID);
79 }
80 
81 
82 std::string
83 Person::getRoadID(const std::string& personID) {
84  return Dom::getString(libsumo::VAR_ROAD_ID, personID);
85 }
86 
87 
88 std::string
89 Person::getLaneID(const std::string& personID) {
90  return Dom::getString(libsumo::VAR_LANE_ID, personID);
91 }
92 
93 
94 double
95 Person::getLanePosition(const std::string& personID) {
96  return Dom::getDouble(libsumo::VAR_LANEPOSITION, personID);
97 }
98 
99 
100 std::vector<libsumo::TraCIReservation>
101 Person::getTaxiReservations(int onlyNew) {
102  std::vector<libsumo::TraCIReservation> result;
103  // TODO
104  return result;
105 }
106 
107 
109 Person::getColor(const std::string& personID) {
110  return Dom::getCol(libsumo::VAR_COLOR, personID);
111 }
112 
113 
114 std::string
115 Person::getTypeID(const std::string& personID) {
116  return Dom::getString(libsumo::VAR_TYPE, personID);
117 }
118 
119 
120 double
121 Person::getWaitingTime(const std::string& personID) {
122  return Dom::getDouble(libsumo::VAR_WAITING_TIME, personID);
123 }
124 
125 
126 std::string
127 Person::getNextEdge(const std::string& personID) {
128  return Dom::getString(libsumo::VAR_NEXT_EDGE, personID);
129 }
130 
131 
132 std::vector<std::string>
133 Person::getEdges(const std::string& personID, int nextStageIndex) {
134  std::vector<std::string> edgeIDs;
135  // TODO
136  return edgeIDs;
137 }
138 
139 
141 Person::getStage(const std::string& personID, int nextStageIndex) {
142  libsumo::TraCIStage result;
143  // TODO
144  return result;
145 }
146 
147 
148 int
149 Person::getRemainingStages(const std::string& personID) {
150  return Dom::getInt(libsumo::VAR_STAGES_REMAINING, personID);
151 }
152 
153 
154 std::string
155 Person::getVehicle(const std::string& personID) {
156  return Dom::getString(libsumo::VAR_VEHICLE, personID);
157 }
158 
159 
160 std::string
161 Person::getEmissionClass(const std::string& personID) {
162  return Dom::getString(libsumo::VAR_EMISSIONCLASS, personID);
163 }
164 
165 
166 std::string
167 Person::getShapeClass(const std::string& personID) {
168  return Dom::getString(libsumo::VAR_SHAPECLASS, personID);
169 }
170 
171 
172 double
173 Person::getLength(const std::string& personID) {
174  return Dom::getDouble(libsumo::VAR_LENGTH, personID);
175 }
176 
177 
178 double
179 Person::getSpeedFactor(const std::string& personID) {
180  return Dom::getDouble(libsumo::VAR_SPEED_FACTOR, personID);
181 }
182 
183 
184 double
185 Person::getAccel(const std::string& personID) {
186  return Dom::getDouble(libsumo::VAR_ACCEL, personID);
187 }
188 
189 
190 double
191 Person::getDecel(const std::string& personID) {
192  return Dom::getDouble(libsumo::VAR_DECEL, personID);
193 }
194 
195 
196 double Person::getEmergencyDecel(const std::string& personID) {
198 }
199 
200 
201 double Person::getApparentDecel(const std::string& personID) {
203 }
204 
205 
206 double Person::getActionStepLength(const std::string& personID) {
208 }
209 
210 
211 double
212 Person::getTau(const std::string& personID) {
213  return Dom::getDouble(libsumo::VAR_TAU, personID);
214 }
215 
216 
217 double
218 Person::getImperfection(const std::string& personID) {
219  return Dom::getDouble(libsumo::VAR_IMPERFECTION, personID);
220 }
221 
222 
223 double
224 Person::getSpeedDeviation(const std::string& personID) {
226 }
227 
228 
229 std::string
230 Person::getVehicleClass(const std::string& personID) {
231  return Dom::getString(libsumo::VAR_VEHICLECLASS, personID);
232 }
233 
234 
235 double
236 Person::getMinGap(const std::string& personID) {
237  return Dom::getDouble(libsumo::VAR_MINGAP, personID);
238 }
239 
240 
241 double
242 Person::getMinGapLat(const std::string& personID) {
243  return Dom::getDouble(libsumo::VAR_MINGAP_LAT, personID);
244 }
245 
246 
247 double
248 Person::getMaxSpeed(const std::string& personID) {
249  return Dom::getDouble(libsumo::VAR_MAXSPEED, personID);
250 }
251 
252 
253 double
254 Person::getMaxSpeedLat(const std::string& personID) {
255  return Dom::getDouble(libsumo::VAR_MAXSPEED_LAT, personID);
256 }
257 
258 
259 std::string
260 Person::getLateralAlignment(const std::string& personID) {
261  return Dom::getString(libsumo::VAR_LATALIGNMENT, personID);
262 }
263 
264 
265 double
266 Person::getWidth(const std::string& personID) {
267  return Dom::getDouble(libsumo::VAR_WIDTH, personID);
268 }
269 
270 
271 double
272 Person::getHeight(const std::string& personID) {
273  return Dom::getDouble(libsumo::VAR_HEIGHT, personID);
274 }
275 
276 
277 int
278 Person::getPersonCapacity(const std::string& personID) {
279  return Dom::getInt(libsumo::VAR_PERSON_CAPACITY, personID);
280 }
281 
282 
284 
285 
286 void
287 Person::setSpeed(const std::string& personID, double speed) {
288  Dom::setDouble(libsumo::VAR_SPEED, personID, speed);
289 }
290 
291 
292 void
293 Person::setType(const std::string& personID, const std::string& typeID) {
294  Dom::setString(libsumo::VAR_TYPE, personID, typeID);
295 }
296 
297 
298 void
299 Person::add(const std::string& personID, const std::string& edgeID, double pos, double departInSecs, const std::string typeID) {
300  // TODO
301 }
302 
303 
304 void
305 Person::appendStage(const std::string& personID, const libsumo::TraCIStage& stage) {
306  // TODO
307 }
308 
309 
310 void
311 Person::replaceStage(const std::string& personID, const int stageIndex, const libsumo::TraCIStage& stage) {
312  // TODO
313 }
314 
315 
316 void
317 Person::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
318  // TODO
319 }
320 
321 
322 void
323 Person::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
324  // TODO
325 }
326 
327 
328 void
329 Person::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edgeIDs, double arrivalPos, double duration, double speed, const std::string& stopID) {
330  // TODO
331 }
332 
333 
334 void
335 Person::removeStage(const std::string& personID, int nextStageIndex) {
336  // TODO
337 }
338 
339 
340 void
341 Person::rerouteTraveltime(const std::string& personID) {
342  // TODO
343 }
344 
345 
346 void
347 Person::moveTo(const std::string& personID, const std::string& edgeID, double /* position */) {
348  // TODO
349 }
350 
351 
352 void
353 Person::moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle, const int keepRoute) {
354  // TODO
355 }
356 
357 
360 void
361 Person::setLength(const std::string& personID, double length) {
362  Dom::setDouble(libsumo::VAR_LENGTH, personID, length);
363 }
364 
365 
366 void
367 Person::setMaxSpeed(const std::string& personID, double speed) {
368  Dom::setDouble(libsumo::VAR_MAXSPEED, personID, speed);
369 }
370 
371 
372 void
373 Person::setVehicleClass(const std::string& personID, const std::string& clazz) {
374  Dom::setString(libsumo::VAR_VEHICLECLASS, personID, clazz);
375 }
376 
377 
378 void
379 Person::setShapeClass(const std::string& personID, const std::string& clazz) {
380  Dom::setString(libsumo::VAR_SHAPECLASS, personID, clazz);
381 }
382 
383 
384 void
385 Person::setEmissionClass(const std::string& personID, const std::string& clazz) {
386  Dom::setString(libsumo::VAR_EMISSIONCLASS, personID, clazz);
387 }
388 
389 
390 void
391 Person::setWidth(const std::string& personID, double width) {
392  Dom::setDouble(libsumo::VAR_WIDTH, personID, width);
393 }
394 
395 
396 void
397 Person::setHeight(const std::string& personID, double height) {
398  Dom::setDouble(libsumo::VAR_HEIGHT, personID, height);
399 }
400 
401 
402 void
403 Person::setMinGap(const std::string& personID, double minGap) {
404  Dom::setDouble(libsumo::VAR_MINGAP, personID, minGap);
405 }
406 
407 
408 void
409 Person::setAccel(const std::string& personID, double accel) {
410  Dom::setDouble(libsumo::VAR_ACCEL, personID, accel);
411 }
412 
413 
414 void
415 Person::setDecel(const std::string& personID, double decel) {
416  Dom::setDouble(libsumo::VAR_DECEL, personID, decel);
417 }
418 
419 
420 void
421 Person::setEmergencyDecel(const std::string& personID, double decel) {
423 }
424 
425 
426 void
427 Person::setApparentDecel(const std::string& personID, double decel) {
429 }
430 
431 
432 void
433 Person::setImperfection(const std::string& personID, double imperfection) {
434  Dom::setDouble(libsumo::VAR_IMPERFECTION, personID, imperfection);
435 }
436 
437 
438 void
439 Person::setTau(const std::string& personID, double tau) {
440  Dom::setDouble(libsumo::VAR_TAU, personID, tau);
441 }
442 
443 
444 void
445 Person::setMinGapLat(const std::string& personID, double minGapLat) {
446  Dom::setDouble(libsumo::VAR_MINGAP_LAT, personID, minGapLat);
447 }
448 
449 
450 void
451 Person::setMaxSpeedLat(const std::string& personID, double speed) {
452  Dom::setDouble(libsumo::VAR_MAXSPEED_LAT, personID, speed);
453 }
454 
455 
456 void
457 Person::setLateralAlignment(const std::string& personID, const std::string& latAlignment) {
458  Dom::setString(libsumo::VAR_LATALIGNMENT, personID, latAlignment);
459 }
460 
461 
462 void
463 Person::setSpeedFactor(const std::string& personID, double factor) {
464  Dom::setDouble(libsumo::VAR_SPEED_FACTOR, personID, factor);
465 }
466 
467 
468 void
469 Person::setActionStepLength(const std::string& personID, double actionStepLength, bool resetActionOffset) {
470  if (!resetActionOffset) {
471  actionStepLength *= -1;
472  }
473  Dom::setDouble(libsumo::VAR_ACTIONSTEPLENGTH, personID, actionStepLength);
474 }
475 
476 
477 void
478 Person::setColor(const std::string& personID, const libsumo::TraCIColor& color) {
479  Dom::setCol(libsumo::VAR_COLOR, personID, color);
480 }
481 
482 
484 
485 
486 }
487 
488 
489 /****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:36
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:74
C++ TraCI client API implementation.
static void setDouble(int var, const std::string &id, double value)
Definition: Domain.h:156
static libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:128
static void setCol(int var, const std::string &id, const libsumo::TraCIColor value)
Definition: Domain.h:168
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:140
static libsumo::TraCIColor getCol(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:144
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:136
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:116
static libsumo::TraCIPosition getPos3D(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:132
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:120
static void setString(int var, const std::string &id, const std::string &value)
Definition: Domain.h:160
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int VAR_TYPE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int VAR_VEHICLE
TRACI_CONST int VAR_SHAPECLASS
TRACI_CONST int VAR_WAITING_TIME
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int VAR_ACTIONSTEPLENGTH
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_TAU
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_WIDTH
TRACI_CONST int VAR_PERSON_CAPACITY
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int VAR_SLOPE
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_APPARENT_DECEL
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_DECEL
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int VAR_NEXT_EDGE
TRACI_CONST int VAR_EMERGENCY_DECEL
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int VAR_ACCEL
TRACI_CONST int VAR_STAGES_REMAINING
TRACI_CONST int VAR_SPEED_DEVIATION
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
A 3D-position.
Definition: TraCIDefs.h:141