Eclipse SUMO - Simulation of Urban MObility
libtraci/Vehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2017-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 /****************************************************************************/
20 // C++ TraCI client API implementation
21 /****************************************************************************/
22 #include <config.h>
23 #include <sstream>
24 
25 #define LIBTRACI 1
26 #include <libsumo/StorageHelper.h>
27 #include <libsumo/Vehicle.h>
28 #include "Domain.h"
29 
30 namespace libtraci {
31 
32 typedef Domain<libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::CMD_SET_VEHICLE_VARIABLE> Dom;
33 
34 
35 // ===========================================================================
36 // static member definitions
37 // ===========================================================================
38 std::vector<std::string>
39 Vehicle::getIDList() {
41 }
42 
43 
44 int
45 Vehicle::getIDCount() {
46  return Dom::getInt(libsumo::ID_COUNT, "");
47 }
48 
49 
52 
53 double
54 Vehicle::getSpeed(const std::string& vehID) {
55  return Dom::getDouble(libsumo::VAR_SPEED, vehID);
56 }
57 
58 double
59 Vehicle::getLateralSpeed(const std::string& vehID) {
61 }
62 
63 double
64 Vehicle::getAcceleration(const std::string& vehID) {
66 }
67 
68 
69 double
70 Vehicle::getSpeedWithoutTraCI(const std::string& vehID) {
72 }
73 
74 
76 Vehicle::getPosition(const std::string& vehID, const bool includeZ) {
77  return includeZ ? getPosition3D(vehID) : Dom::getPos(libsumo::VAR_POSITION, vehID);
78 }
79 
80 
82 Vehicle::getPosition3D(const std::string& vehID) {
84 }
85 
86 
87 double
88 Vehicle::getAngle(const std::string& vehID) {
89  return Dom::getDouble(libsumo::VAR_ANGLE, vehID);
90 }
91 
92 
93 double
94 Vehicle::getSlope(const std::string& vehID) {
95  return Dom::getDouble(libsumo::VAR_SLOPE, vehID);
96 }
97 
98 
99 std::string
100 Vehicle::getRoadID(const std::string& vehID) {
101  return Dom::getString(libsumo::VAR_ROAD_ID, vehID);
102 }
103 
104 
105 double
106 Vehicle::getDeparture(const std::string& vehID) {
107  return Dom::getDouble(libsumo::VAR_DEPARTURE, vehID);
108 }
109 
110 
111 double
112 Vehicle::getDepartDelay(const std::string& vehID) {
114 }
115 
116 
117 std::string
118 Vehicle::getLaneID(const std::string& vehID) {
119  return Dom::getString(libsumo::VAR_LANE_ID, vehID);
120 }
121 
122 
123 int
124 Vehicle::getLaneIndex(const std::string& vehID) {
125  return Dom::getInt(libsumo::VAR_LANE_INDEX, vehID);
126 }
127 
128 
129 std::string
130 Vehicle::getTypeID(const std::string& vehID) {
131  return Dom::getString(libsumo::VAR_TYPE, vehID);
132 }
133 
134 
135 std::string
136 Vehicle::getRouteID(const std::string& vehID) {
137  return Dom::getString(libsumo::VAR_ROUTE_ID, vehID);
138 }
139 
140 
141 int
142 Vehicle::getRouteIndex(const std::string& vehID) {
143  return Dom::getInt(libsumo::VAR_ROUTE_INDEX, vehID);
144 }
145 
146 
148 Vehicle::getColor(const std::string& vehID) {
149  return Dom::getCol(libsumo::VAR_COLOR, vehID);
150 }
151 
152 double
153 Vehicle::getLanePosition(const std::string& vehID) {
155 }
156 
157 double
158 Vehicle::getLateralLanePosition(const std::string& vehID) {
160 }
161 
162 double
163 Vehicle::getCO2Emission(const std::string& vehID) {
165 }
166 
167 double
168 Vehicle::getCOEmission(const std::string& vehID) {
170 }
171 
172 double
173 Vehicle::getHCEmission(const std::string& vehID) {
175 }
176 
177 double
178 Vehicle::getPMxEmission(const std::string& vehID) {
180 }
181 
182 double
183 Vehicle::getNOxEmission(const std::string& vehID) {
185 }
186 
187 double
188 Vehicle::getFuelConsumption(const std::string& vehID) {
190 }
191 
192 double
193 Vehicle::getNoiseEmission(const std::string& vehID) {
195 }
196 
197 double
198 Vehicle::getElectricityConsumption(const std::string& vehID) {
200 }
201 
202 int
203 Vehicle::getPersonNumber(const std::string& vehID) {
205 }
206 
207 int
208 Vehicle::getPersonCapacity(const std::string& vehID) {
210 }
211 
212 
213 double
214 Vehicle::getBoardingDuration(const std::string& vehID) {
216 }
217 
218 
219 double
220 Vehicle::getImpatience(const std::string& vehID) {
222 }
223 
224 
225 std::vector<std::string>
226 Vehicle::getPersonIDList(const std::string& vehID) {
228 }
229 
230 std::pair<std::string, double>
231 Vehicle::getLeader(const std::string& vehID, double dist) {
232  tcpip::Storage content;
233  StoHelp::writeTypedDouble(content, dist);
234  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
235  tcpip::Storage& ret = Dom::get(libsumo::VAR_LEADER, vehID, &content);
236  ret.readInt(); // components
237  ret.readUnsignedByte();
238  const std::string leaderID = ret.readString();
239  ret.readUnsignedByte();
240  const double gap = ret.readDouble();
241  return std::make_pair(leaderID, gap);
242 }
243 
244 
245 std::pair<std::string, double>
246 Vehicle::getFollower(const std::string& vehID, double dist) {
247  tcpip::Storage content;
248  StoHelp::writeTypedDouble(content, dist);
249  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
250  tcpip::Storage& ret = Dom::get(libsumo::VAR_FOLLOWER, vehID, &content);
251  ret.readInt(); // components
252  const std::string leaderID = StoHelp::readTypedString(ret);
253  return std::make_pair(leaderID, StoHelp::readTypedDouble(ret));
254 }
255 
256 
257 std::vector<libsumo::TraCIJunctionFoe>
258 Vehicle::getJunctionFoes(const std::string& vehID, double dist) {
259  std::vector<libsumo::TraCIJunctionFoe> result;
260  tcpip::Storage content;
261  StoHelp::writeTypedDouble(content, dist);
262  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
263  tcpip::Storage& ret = Dom::get(libsumo::VAR_FOES, vehID, &content);
264  ret.readInt(); // compound size
265  const int n = StoHelp::readTypedInt(ret); // number of foe informations
266  for (int i = 0; i < n; ++i) {
268  info.foeId = StoHelp::readTypedString(ret);
269  info.egoDist = StoHelp::readTypedDouble(ret);
270  info.foeDist = StoHelp::readTypedDouble(ret);
273  info.egoLane = StoHelp::readTypedString(ret);
274  info.foeLane = StoHelp::readTypedString(ret);
275  info.egoResponse = StoHelp::readBool(ret);
276  info.foeResponse = StoHelp::readBool(ret);
277  result.emplace_back(info);
278  }
279  return result;
280 }
281 
282 
283 double
284 Vehicle::getWaitingTime(const std::string& vehID) {
286 }
287 
288 
289 double
290 Vehicle::getAccumulatedWaitingTime(const std::string& vehID) {
292 }
293 
294 
295 double
296 Vehicle::getAdaptedTraveltime(const std::string& vehID, double time, const std::string& edgeID) {
297  tcpip::Storage content;
298  StoHelp::writeCompound(content, 2);
299  StoHelp::writeTypedDouble(content, time);
300  StoHelp::writeTypedString(content, edgeID);
301  return Dom::getDouble(libsumo::VAR_EDGE_TRAVELTIME, vehID, &content);
302 }
303 
304 
305 double
306 Vehicle::getEffort(const std::string& vehID, double time, const std::string& edgeID) {
307  tcpip::Storage content;
308  StoHelp::writeCompound(content, 2);
309  StoHelp::writeTypedDouble(content, time);
310  StoHelp::writeTypedString(content, edgeID);
311  return Dom::getDouble(libsumo::VAR_EDGE_EFFORT, vehID, &content);
312 }
313 
314 
315 bool
316 Vehicle::isRouteValid(const std::string& vehID) {
317  return Dom::getInt(libsumo::VAR_ROUTE_VALID, vehID) != 0;
318 }
319 
320 
321 std::vector<std::string>
322 Vehicle::getRoute(const std::string& vehID) {
324 }
325 
326 
327 int
328 Vehicle::getSignals(const std::string& vehID) {
329  return Dom::getInt(libsumo::VAR_SIGNALS, vehID);
330 }
331 
332 
333 std::vector<libsumo::TraCIBestLanesData>
334 Vehicle::getBestLanes(const std::string& vehID) {
335  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
336  std::vector<libsumo::TraCIBestLanesData> result;
338  ret.readInt();
339  ret.readUnsignedByte();
340 
341  const int n = ret.readInt(); // number of following edge information
342  for (int i = 0; i < n; ++i) {
344  ret.readUnsignedByte();
345  info.laneID = ret.readString();
346 
347  ret.readUnsignedByte();
348  info.length = ret.readDouble();
349 
350  ret.readUnsignedByte();
351  info.occupation = ret.readDouble();
352 
353  ret.readUnsignedByte();
354  info.bestLaneOffset = ret.readByte();
355 
356  ret.readUnsignedByte();
357  info.allowsContinuation = (ret.readUnsignedByte() == 1);
358 
359  ret.readUnsignedByte();
360  int m = ret.readInt();
361  while (m-- > 0) {
362  info.continuationLanes.push_back(ret.readString());
363  }
364  result.push_back(info);
365  }
366  return result;
367 }
368 
369 
370 std::vector<libsumo::TraCINextTLSData>
371 Vehicle::getNextTLS(const std::string& vehID) {
372  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
373  std::vector<libsumo::TraCINextTLSData> result;
375  ret.readInt(); // components
376  // number of items
377  ret.readUnsignedByte();
378  const int n = ret.readInt();
379  for (int i = 0; i < n; ++i) {
381  ret.readUnsignedByte();
382  d.id = ret.readString();
383 
384  ret.readUnsignedByte();
385  d.tlIndex = ret.readInt();
386 
387  ret.readUnsignedByte();
388  d.dist = ret.readDouble();
389 
390  ret.readUnsignedByte();
391  d.state = (char)ret.readByte();
392 
393  result.push_back(d);
394  }
395  return result;
396 }
397 
398 std::vector<libsumo::TraCINextStopData>
399 Vehicle::getNextStops(const std::string& vehID) {
400  return getStops(vehID, 0);
401 }
402 
403 std::vector<libsumo::TraCIConnection>
404 Vehicle::getNextLinks(const std::string& vehID) {
405  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
406  std::vector<libsumo::TraCIConnection> result;
408  ret.readInt(); // components
409  // number of items
410  ret.readUnsignedByte();
411 
412  const int linkNo = ret.readInt();
413  for (int i = 0; i < linkNo; ++i) {
417  con.hasPrio = StoHelp::readBool(ret);
418  con.isOpen = StoHelp::readBool(ret);
419  con.hasFoe = StoHelp::readBool(ret);
420  con.state = StoHelp::readTypedString(ret);
422  con.length = StoHelp::readTypedDouble(ret);
423  result.emplace_back(con);
424  }
425  return result;
426 }
427 
428 std::vector<libsumo::TraCINextStopData>
429 Vehicle::getStops(const std::string& vehID, int limit) {
430  std::vector<libsumo::TraCINextStopData> result;
431  tcpip::Storage content;
432  StoHelp::writeTypedInt(content, limit);
433  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
434  tcpip::Storage& ret = Dom::get(libsumo::VAR_NEXT_STOPS2, vehID, &content);
435  ret.readInt(); // components
436  // number of items
437  const int n = StoHelp::readCompound(ret);
438  for (int i = 0; i < n; ++i) {
456  result.emplace_back(s);
457  }
458  return result;
459 }
460 
461 std::string
462 Vehicle::getStopParameter(const std::string& vehID, int nextStopIndex, const std::string& param, bool customParam) {
463  tcpip::Storage content;
464  StoHelp::writeCompound(content, 3);
465  StoHelp::writeTypedInt(content, nextStopIndex);
466  StoHelp::writeTypedString(content, param);
467  StoHelp::writeTypedByte(content, customParam);
468  return Dom::getString(libsumo::VAR_STOP_PARAMETER, vehID, &content);
469 }
470 
471 int
472 Vehicle::getStopState(const std::string& vehID) {
473  return Dom::getInt(libsumo::VAR_STOPSTATE, vehID);
474 }
475 
476 
477 double
478 Vehicle::getDistance(const std::string& vehID) {
479  return Dom::getDouble(libsumo::VAR_DISTANCE, vehID);
480 }
481 
482 
483 double
484 Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int laneIndex) {
485  tcpip::Storage content;
486  StoHelp::writeCompound(content, 2);
488  content.writeString(edgeID);
489  content.writeDouble(pos);
490  content.writeUnsignedByte(laneIndex);
492  return Dom::getDouble(libsumo::DISTANCE_REQUEST, vehID, &content);
493 }
494 
495 
496 double
497 Vehicle::getDrivingDistance2D(const std::string& vehID, double x, double y) {
498  tcpip::Storage content;
499  StoHelp::writeCompound(content, 2);
501  content.writeDouble(x);
502  content.writeDouble(y);
504  return Dom::getDouble(libsumo::DISTANCE_REQUEST, vehID, &content);
505 }
506 
507 
508 double
509 Vehicle::getAllowedSpeed(const std::string& vehID) {
511 }
512 
513 
514 double
515 Vehicle::getSpeedFactor(const std::string& vehID) {
517 }
518 
519 
520 int
521 Vehicle::getSpeedMode(const std::string& vehID) {
522  return Dom::getInt(libsumo::VAR_SPEEDSETMODE, vehID);
523 }
524 
525 
526 int
527 Vehicle::getLaneChangeMode(const std::string& vehID) {
529 }
530 
531 
532 int
533 Vehicle::getRoutingMode(const std::string& vehID) {
534  return Dom::getInt(libsumo::VAR_ROUTING_MODE, vehID);
535 }
536 
537 
538 std::string
539 Vehicle::getLine(const std::string& vehID) {
540  return Dom::getString(libsumo::VAR_LINE, vehID);
541 }
542 
543 
544 
545 std::vector<std::string>
546 Vehicle::getVia(const std::string& vehID) {
547  return Dom::getStringVector(libsumo::VAR_VIA, vehID);
548 }
549 
550 
551 std::pair<int, int>
552 Vehicle::getLaneChangeState(const std::string& vehID, int direction) {
553  tcpip::Storage content;
554  StoHelp::writeTypedInt(content, direction);
555  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
556  tcpip::Storage& ret = Dom::get(libsumo::CMD_CHANGELANE, vehID, &content);
557  ret.readInt(); // components
558  ret.readUnsignedByte();
559  const int stateWithoutTraCI = ret.readInt();
560  ret.readUnsignedByte();
561  const int state = ret.readInt();
562  return std::make_pair(stateWithoutTraCI, state);
563 }
564 
565 
566 std::vector<std::pair<std::string, double> >
567 Vehicle::getNeighbors(const std::string& vehID, const int mode) {
568  std::vector<std::pair<std::string, double> > neighs;
569  tcpip::Storage content;
571  content.writeUnsignedByte(mode);
572  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
573  tcpip::Storage& ret = Dom::get(libsumo::VAR_NEIGHBORS, vehID, &content);
574  const int items = ret.readInt(); // components
575  for (int i = 0; i < items; i++) {
576  const std::string neighID = ret.readString();
577  neighs.emplace_back(neighID, ret.readDouble());
578  }
579  return neighs;
580 }
581 
582 
583 double
584 Vehicle::getFollowSpeed(const std::string& vehID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
585  tcpip::Storage content;
586  StoHelp::writeCompound(content, 5);
587  StoHelp::writeTypedDouble(content, speed);
588  StoHelp::writeTypedDouble(content, gap);
589  StoHelp::writeTypedDouble(content, leaderSpeed);
590  StoHelp::writeTypedDouble(content, leaderMaxDecel);
591  StoHelp::writeTypedString(content, leaderID);
592  return Dom::getDouble(libsumo::VAR_FOLLOW_SPEED, vehID, &content);
593 }
594 
595 
596 double
597 Vehicle::getSecureGap(const std::string& vehID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
598  tcpip::Storage content;
599  StoHelp::writeCompound(content, 4);
600  StoHelp::writeTypedDouble(content, speed);
601  StoHelp::writeTypedDouble(content, leaderSpeed);
602  StoHelp::writeTypedDouble(content, leaderMaxDecel);
603  StoHelp::writeTypedString(content, leaderID);
604  return Dom::getDouble(libsumo::VAR_SECURE_GAP, vehID, &content);
605 }
606 
607 
608 double
609 Vehicle::getStopSpeed(const std::string& vehID, const double speed, double gap) {
610  tcpip::Storage content;
611  StoHelp::writeCompound(content, 2);
612  StoHelp::writeTypedDouble(content, speed);
613  StoHelp::writeTypedDouble(content, gap);
614  return Dom::getDouble(libsumo::VAR_STOP_SPEED, vehID, &content);
615 }
616 
617 double
618 Vehicle::getStopDelay(const std::string& vehID) {
620 }
621 
622 double
623 Vehicle::getStopArrivalDelay(const std::string& vehID) {
625 }
626 
627 double
628 Vehicle::getTimeLoss(const std::string& vehID) {
629  return Dom::getDouble(libsumo::VAR_TIMELOSS, vehID);
630 }
631 
632 std::vector<std::string>
633 Vehicle::getTaxiFleet(int taxiState) {
634  tcpip::Storage content;
635  StoHelp::writeTypedInt(content, taxiState);
636  return Dom::getStringVector(libsumo::VAR_TAXI_FLEET, "", &content);
637 }
638 
639 std::vector<std::string>
640 Vehicle::getLoadedIDList() {
642 }
643 
644 std::vector<std::string>
645 Vehicle::getTeleportingIDList() {
647 }
648 
649 std::string
650 Vehicle::getEmissionClass(const std::string& vehID) {
652 }
653 
654 std::string
655 Vehicle::getShapeClass(const std::string& vehID) {
657 }
658 
659 
660 double
661 Vehicle::getLength(const std::string& vehID) {
662  return Dom::getDouble(libsumo::VAR_LENGTH, vehID);
663 }
664 
665 
666 double
667 Vehicle::getAccel(const std::string& vehID) {
668  return Dom::getDouble(libsumo::VAR_ACCEL, vehID);
669 }
670 
671 
672 double
673 Vehicle::getDecel(const std::string& vehID) {
674  return Dom::getDouble(libsumo::VAR_DECEL, vehID);
675 }
676 
677 
678 double Vehicle::getEmergencyDecel(const std::string& vehID) {
680 }
681 
682 
683 double Vehicle::getApparentDecel(const std::string& vehID) {
685 }
686 
687 
688 double Vehicle::getActionStepLength(const std::string& vehID) {
690 }
691 
692 
693 double Vehicle::getLastActionTime(const std::string& vehID) {
695 }
696 
697 
698 double
699 Vehicle::getTau(const std::string& vehID) {
700  return Dom::getDouble(libsumo::VAR_TAU, vehID);
701 }
702 
703 
704 double
705 Vehicle::getImperfection(const std::string& vehID) {
707 }
708 
709 
710 double
711 Vehicle::getSpeedDeviation(const std::string& vehID) {
713 }
714 
715 
716 std::string
717 Vehicle::getVehicleClass(const std::string& vehID) {
719 }
720 
721 
722 double
723 Vehicle::getMinGap(const std::string& vehID) {
724  return Dom::getDouble(libsumo::VAR_MINGAP, vehID);
725 }
726 
727 
728 double
729 Vehicle::getMinGapLat(const std::string& vehID) {
731 }
732 
733 
734 double
735 Vehicle::getMaxSpeed(const std::string& vehID) {
736  return Dom::getDouble(libsumo::VAR_MAXSPEED, vehID);
737 }
738 
739 
740 double
741 Vehicle::getMaxSpeedLat(const std::string& vehID) {
743 }
744 
745 
746 std::string
747 Vehicle::getLateralAlignment(const std::string& vehID) {
749 }
750 
751 
752 double
753 Vehicle::getWidth(const std::string& vehID) {
754  return Dom::getDouble(libsumo::VAR_WIDTH, vehID);
755 }
756 
757 
758 double
759 Vehicle::getHeight(const std::string& vehID) {
760  return Dom::getDouble(libsumo::VAR_HEIGHT, vehID);
761 }
762 
763 
764 void
765 Vehicle::setStop(const std::string& vehID,
766  const std::string& edgeID,
767  double pos,
768  int laneIndex,
769  double duration,
770  int flags,
771  double startPos,
772  double until) {
773  tcpip::Storage content;
774  StoHelp::writeCompound(content, 7);
775  StoHelp::writeTypedString(content, edgeID);
776  StoHelp::writeTypedDouble(content, pos);
777  StoHelp::writeTypedByte(content, laneIndex);
778  StoHelp::writeTypedDouble(content, duration);
779  StoHelp::writeTypedByte(content, flags);
780  StoHelp::writeTypedDouble(content, startPos);
781  StoHelp::writeTypedDouble(content, until);
782  Dom::set(libsumo::CMD_STOP, vehID, &content);
783 }
784 
785 
786 void
787 Vehicle::replaceStop(const std::string& vehID,
788  int nextStopIndex,
789  const std::string& edgeID,
790  double pos,
791  int laneIndex,
792  double duration,
793  int flags,
794  double startPos,
795  double until,
796  int teleport) {
797  tcpip::Storage content;
798  StoHelp::writeCompound(content, 9);
799  StoHelp::writeTypedString(content, edgeID);
800  StoHelp::writeTypedDouble(content, pos);
801  StoHelp::writeTypedByte(content, laneIndex);
802  StoHelp::writeTypedDouble(content, duration);
803  StoHelp::writeTypedInt(content, flags);
804  StoHelp::writeTypedDouble(content, startPos);
805  StoHelp::writeTypedDouble(content, until);
806  StoHelp::writeTypedInt(content, nextStopIndex);
807  StoHelp::writeTypedByte(content, teleport);
808  Dom::set(libsumo::CMD_REPLACE_STOP, vehID, &content);
809 }
810 
811 
812 void
813 Vehicle::insertStop(const std::string& vehID,
814  int nextStopIndex,
815  const std::string& edgeID,
816  double pos,
817  int laneIndex,
818  double duration,
819  int flags,
820  double startPos,
821  double until,
822  int teleport) {
823  tcpip::Storage content;
824  StoHelp::writeCompound(content, 9);
825  StoHelp::writeTypedString(content, edgeID);
826  StoHelp::writeTypedDouble(content, pos);
827  StoHelp::writeTypedByte(content, laneIndex);
828  StoHelp::writeTypedDouble(content, duration);
829  StoHelp::writeTypedInt(content, flags);
830  StoHelp::writeTypedDouble(content, startPos);
831  StoHelp::writeTypedDouble(content, until);
832  StoHelp::writeTypedInt(content, nextStopIndex);
833  StoHelp::writeTypedByte(content, teleport);
834  Dom::set(libsumo::CMD_INSERT_STOP, vehID, &content);
835 }
836 
837 
838 void
839 Vehicle::setStopParameter(const std::string& vehID, int nextStopIndex,
840  const std::string& param, const std::string& value,
841  bool customParam) {
842  tcpip::Storage content;
843  StoHelp::writeCompound(content, 4);
844  StoHelp::writeTypedInt(content, nextStopIndex);
845  StoHelp::writeTypedString(content, param);
846  StoHelp::writeTypedString(content, value);
847  StoHelp::writeTypedByte(content, customParam);
848  Dom::set(libsumo::VAR_STOP_PARAMETER, vehID, &content);
849 }
850 
851 
852 void
853 Vehicle::rerouteParkingArea(const std::string& vehID, const std::string& parkingAreaID) {
854  tcpip::Storage content;
855  StoHelp::writeCompound(content, 1);
856  StoHelp::writeTypedString(content, parkingAreaID);
857  Dom::set(libsumo::CMD_REROUTE_TO_PARKING, vehID, &content);
858 }
859 
860 
861 void
862 Vehicle::resume(const std::string& vehID) {
863  tcpip::Storage content;
864  StoHelp::writeCompound(content, 0);
865  Dom::set(libsumo::CMD_RESUME, vehID, &content);
866 }
867 
868 
869 void
870 Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
872 }
873 
874 
875 void
876 Vehicle::changeLane(const std::string& vehID, int laneIndex, double duration) {
877  tcpip::Storage content;
878  StoHelp::writeCompound(content, 2);
879  StoHelp::writeTypedByte(content, laneIndex);
880  StoHelp::writeTypedDouble(content, duration);
881  Dom::set(libsumo::CMD_CHANGELANE, vehID, &content);
882 }
883 
884 void
885 Vehicle::changeLaneRelative(const std::string& vehID, int indexOffset, double duration) {
886  tcpip::Storage content;
887  StoHelp::writeCompound(content, 3);
888  StoHelp::writeTypedByte(content, indexOffset);
889  StoHelp::writeTypedDouble(content, duration);
890  StoHelp::writeTypedByte(content, 1);
891  Dom::set(libsumo::CMD_CHANGELANE, vehID, &content);
892 }
893 
894 
895 void
896 Vehicle::changeSublane(const std::string& vehID, double latDist) {
898 }
899 
900 
901 void
902 Vehicle::add(const std::string& vehID,
903  const std::string& routeID,
904  const std::string& typeID,
905  const std::string& depart,
906  const std::string& departLane,
907  const std::string& departPos,
908  const std::string& departSpeed,
909  const std::string& arrivalLane,
910  const std::string& arrivalPos,
911  const std::string& arrivalSpeed,
912  const std::string& fromTaz,
913  const std::string& toTaz,
914  const std::string& line,
915  int personCapacity,
916  int personNumber) {
917  tcpip::Storage content;
918  StoHelp::writeCompound(content, 14);
919  StoHelp::writeTypedString(content, routeID);
920  StoHelp::writeTypedString(content, typeID);
921  StoHelp::writeTypedString(content, depart);
922  StoHelp::writeTypedString(content, departLane);
923  StoHelp::writeTypedString(content, departPos);
924  StoHelp::writeTypedString(content, departSpeed);
925 
926  StoHelp::writeTypedString(content, arrivalLane);
927  StoHelp::writeTypedString(content, arrivalPos);
928  StoHelp::writeTypedString(content, arrivalSpeed);
929 
930  StoHelp::writeTypedString(content, fromTaz);
931  StoHelp::writeTypedString(content, toTaz);
932  StoHelp::writeTypedString(content, line);
933 
934  StoHelp::writeTypedInt(content, personCapacity);
935  StoHelp::writeTypedInt(content, personNumber);
936 
937  Dom::set(libsumo::ADD_FULL, vehID, &content);
938 }
939 
940 
941 void
942 Vehicle::moveToXY(const std::string& vehID, const std::string& edgeID, const int laneIndex,
943  const double x, const double y, double angle, const int keepRoute, double matchThreshold) {
944  tcpip::Storage content;
945  StoHelp::writeCompound(content, 7);
946  StoHelp::writeTypedString(content, edgeID);
947  StoHelp::writeTypedInt(content, laneIndex);
948  StoHelp::writeTypedDouble(content, x);
949  StoHelp::writeTypedDouble(content, y);
950  StoHelp::writeTypedDouble(content, angle);
951  StoHelp::writeTypedByte(content, keepRoute);
952  StoHelp::writeTypedDouble(content, matchThreshold);
953  Dom::set(libsumo::MOVE_TO_XY, vehID, &content);
954 }
955 
956 void
957 Vehicle::slowDown(const std::string& vehID, double speed, double duration) {
958  tcpip::Storage content;
959  StoHelp::writeCompound(content, 2);
960  StoHelp::writeTypedDouble(content, speed);
961  StoHelp::writeTypedDouble(content, duration);
962  Dom::set(libsumo::CMD_SLOWDOWN, vehID, &content);
963 }
964 
965 void
966 Vehicle::openGap(const std::string& vehID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, const std::string& referenceVehID) {
967  tcpip::Storage content;
968  StoHelp::writeCompound(content, referenceVehID != "" ? 6 : 5);
969  StoHelp::writeTypedDouble(content, newTimeHeadway);
970  StoHelp::writeTypedDouble(content, newSpaceHeadway);
971  StoHelp::writeTypedDouble(content, duration);
972  StoHelp::writeTypedDouble(content, changeRate);
973  StoHelp::writeTypedDouble(content, maxDecel);
974  if (referenceVehID != "") {
975  StoHelp::writeTypedString(content, referenceVehID);
976  }
977  Dom::set(libsumo::CMD_OPENGAP, vehID, &content);
978 }
979 
980 void
981 Vehicle::deactivateGapControl(const std::string& vehID) {
982  openGap(vehID, -1, -1, -1, -1);
983 }
984 
985 void
986 Vehicle::requestToC(const std::string& vehID, double leadTime) {
987  std::ostringstream oss;
988  oss.setf(std::ios::fixed, std::ios::floatfield);
989  oss << std::setprecision(2);
990  oss << leadTime;
991  setParameter(vehID, "device.toc.requestToC", oss.str());
992 }
993 
994 void
995 Vehicle::setSpeed(const std::string& vehID, double speed) {
996  Dom::setDouble(libsumo::VAR_SPEED, vehID, speed);
997 }
998 
999 void
1000 Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
1001  tcpip::Storage content;
1002  StoHelp::writeCompound(content, 2);
1003  StoHelp::writeTypedDouble(content, acceleration);
1004  StoHelp::writeTypedDouble(content, duration);
1005  Dom::set(libsumo::VAR_ACCELERATION, vehID, &content);
1006 }
1007 
1008 void
1009 Vehicle::setPreviousSpeed(const std::string& vehID, double prevSpeed, double prevAcceleration) {
1010  tcpip::Storage content;
1011  StoHelp::writeCompound(content, 2);
1012  StoHelp::writeTypedDouble(content, prevSpeed);
1013  StoHelp::writeTypedDouble(content, prevAcceleration);
1014  Dom::set(libsumo::VAR_PREV_SPEED, vehID, &content);
1015 }
1016 
1017 void
1018 Vehicle::setSpeedMode(const std::string& vehID, int speedMode) {
1019  Dom::setInt(libsumo::VAR_SPEEDSETMODE, vehID, speedMode);
1020 }
1021 
1022 void
1023 Vehicle::setLaneChangeMode(const std::string& vehID, int laneChangeMode) {
1024  Dom::setInt(libsumo::VAR_LANECHANGE_MODE, vehID, laneChangeMode);
1025 }
1026 
1027 void
1028 Vehicle::setRoutingMode(const std::string& vehID, int routingMode) {
1029  Dom::setInt(libsumo::VAR_ROUTING_MODE, vehID, routingMode);
1030 }
1031 
1032 void
1033 Vehicle::setType(const std::string& vehID, const std::string& typeID) {
1034  Dom::setString(libsumo::VAR_TYPE, vehID, typeID);
1035 }
1036 
1037 void
1038 Vehicle::setRouteID(const std::string& vehID, const std::string& routeID) {
1039  Dom::setString(libsumo::VAR_ROUTE_ID, vehID, routeID);
1040 }
1041 
1042 void
1043 Vehicle::setRoute(const std::string& vehID, const std::string& edgeID) {
1044  setRoute(vehID, std::vector<std::string>({edgeID}));
1045 }
1046 
1047 void
1048 Vehicle::setRoute(const std::string& vehID, const std::vector<std::string>& edgeIDs) {
1049  Dom::setStringVector(libsumo::VAR_ROUTE, vehID, edgeIDs);
1050 }
1051 
1052 void
1053 Vehicle::setLateralLanePosition(const std::string& vehID, double posLat) {
1055 }
1056 
1057 void
1058 Vehicle::updateBestLanes(const std::string& vehID) {
1059  tcpip::Storage content;
1060  Dom::set(libsumo::VAR_UPDATE_BESTLANES, vehID, &content);
1061 }
1062 
1063 
1064 void
1065 Vehicle::setAdaptedTraveltime(const std::string& vehID, const std::string& edgeID,
1066  double time, double begSeconds, double endSeconds) {
1067  tcpip::Storage content;
1068  if (time == libsumo::INVALID_DOUBLE_VALUE) {
1069  // reset
1070  StoHelp::writeCompound(content, 1);
1071  StoHelp::writeTypedString(content, edgeID);
1072  } else if (begSeconds == libsumo::INVALID_DOUBLE_VALUE) {
1073  // set value for the whole simulation
1074  StoHelp::writeCompound(content, 2);
1075  StoHelp::writeTypedString(content, edgeID);
1076  StoHelp::writeTypedDouble(content, time);
1077  } else {
1078  StoHelp::writeCompound(content, 4);
1079  StoHelp::writeTypedDouble(content, begSeconds);
1080  StoHelp::writeTypedDouble(content, endSeconds);
1081  StoHelp::writeTypedString(content, edgeID);
1082  StoHelp::writeTypedDouble(content, time);
1083  }
1084  Dom::set(libsumo::VAR_EDGE_TRAVELTIME, vehID, &content);
1085 }
1086 
1087 
1088 void
1089 Vehicle::setEffort(const std::string& vehID, const std::string& edgeID,
1090  double effort, double begSeconds, double endSeconds) {
1091  tcpip::Storage content;
1092  if (effort == libsumo::INVALID_DOUBLE_VALUE) {
1093  // reset
1094  StoHelp::writeCompound(content, 1);
1095  StoHelp::writeTypedString(content, edgeID);
1096  } else if (begSeconds == libsumo::INVALID_DOUBLE_VALUE) {
1097  // set value for the whole simulation
1098  StoHelp::writeCompound(content, 2);
1099  StoHelp::writeTypedString(content, edgeID);
1100  StoHelp::writeTypedDouble(content, effort);
1101  } else {
1102  StoHelp::writeCompound(content, 4);
1103  StoHelp::writeTypedDouble(content, begSeconds);
1104  StoHelp::writeTypedDouble(content, endSeconds);
1105  StoHelp::writeTypedString(content, edgeID);
1106  StoHelp::writeTypedDouble(content, effort);
1107  }
1108  Dom::set(libsumo::VAR_EDGE_EFFORT, vehID, &content);
1109 }
1110 
1111 
1112 void
1113 Vehicle::rerouteTraveltime(const std::string& vehID, const bool /* currentTravelTimes */) {
1114  tcpip::Storage content;
1115  StoHelp::writeCompound(content, 0);
1116  Dom::set(libsumo::CMD_REROUTE_TRAVELTIME, vehID, &content);
1117 }
1118 
1119 
1120 void
1121 Vehicle::rerouteEffort(const std::string& vehID) {
1122  tcpip::Storage content;
1123  StoHelp::writeCompound(content, 0);
1124  Dom::set(libsumo::CMD_REROUTE_EFFORT, vehID, &content);
1125 }
1126 
1127 
1128 void
1129 Vehicle::setSignals(const std::string& vehID, int signals) {
1130  Dom::setInt(libsumo::VAR_SIGNALS, vehID, signals);
1131 }
1132 
1133 
1134 void
1135 Vehicle::moveTo(const std::string& vehID, const std::string& laneID, double position, int reason) {
1136  tcpip::Storage content;
1137  StoHelp::writeCompound(content, 3);
1138  StoHelp::writeTypedString(content, laneID);
1139  StoHelp::writeTypedDouble(content, position);
1140  StoHelp::writeTypedInt(content, reason);
1141  Dom::set(libsumo::VAR_MOVE_TO, vehID, &content);
1142 }
1143 
1144 
1145 void
1146 Vehicle::setActionStepLength(const std::string& vehID, double actionStepLength, bool resetActionOffset) {
1147  //if (actionStepLength < 0) {
1148  // raise TraCIException("Invalid value for actionStepLength. Given value must be non-negative.")
1149  //{
1150  // Use negative value to indicate resetActionOffset == False
1151  if (!resetActionOffset) {
1152  actionStepLength *= -1;
1153  }
1154  Dom::setDouble(libsumo::VAR_ACTIONSTEPLENGTH, vehID, actionStepLength);
1155 }
1156 
1157 
1158 void
1159 Vehicle::remove(const std::string& vehID, char reason) {
1160  tcpip::Storage content;
1162  content.writeUnsignedByte(reason);
1163  Dom::set(libsumo::REMOVE, vehID, &content);
1164 }
1165 
1166 
1167 void
1168 Vehicle::setColor(const std::string& vehID, const libsumo::TraCIColor& color) {
1169  Dom::setCol(libsumo::VAR_COLOR, vehID, color);
1170 }
1171 
1172 
1173 void
1174 Vehicle::setSpeedFactor(const std::string& vehID, double factor) {
1175  Dom::setDouble(libsumo::VAR_SPEED_FACTOR, vehID, factor);
1176 }
1177 
1178 
1179 void
1180 Vehicle::setLine(const std::string& vehID, const std::string& line) {
1181  Dom::setString(libsumo::VAR_LINE, vehID, line);
1182 }
1183 
1184 
1185 void
1186 Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
1187  Dom::setStringVector(libsumo::VAR_VIA, vehID, edgeList);
1188 }
1189 
1190 
1191 void
1192 Vehicle::setLength(const std::string& vehID, double length) {
1193  Dom::setDouble(libsumo::VAR_LENGTH, vehID, length);
1194 }
1195 
1196 
1197 void
1198 Vehicle::setMaxSpeed(const std::string& vehID, double speed) {
1199  Dom::setDouble(libsumo::VAR_MAXSPEED, vehID, speed);
1200 }
1201 
1202 
1203 void
1204 Vehicle::setVehicleClass(const std::string& vehID, const std::string& clazz) {
1206 }
1207 
1208 
1209 void
1210 Vehicle::setShapeClass(const std::string& vehID, const std::string& clazz) {
1211  Dom::setString(libsumo::VAR_SHAPECLASS, vehID, clazz);
1212 }
1213 
1214 
1215 void
1216 Vehicle::setEmissionClass(const std::string& vehID, const std::string& clazz) {
1218 }
1219 
1220 
1221 void
1222 Vehicle::setWidth(const std::string& vehID, double width) {
1223  Dom::setDouble(libsumo::VAR_WIDTH, vehID, width);
1224 }
1225 
1226 
1227 void
1228 Vehicle::setHeight(const std::string& vehID, double height) {
1229  Dom::setDouble(libsumo::VAR_HEIGHT, vehID, height);
1230 }
1231 
1232 
1233 void
1234 Vehicle::setMinGap(const std::string& vehID, double minGap) {
1235  Dom::setDouble(libsumo::VAR_MINGAP, vehID, minGap);
1236 }
1237 
1238 
1239 void
1240 Vehicle::setAccel(const std::string& vehID, double accel) {
1241  Dom::setDouble(libsumo::VAR_ACCEL, vehID, accel);
1242 }
1243 
1244 
1245 void
1246 Vehicle::setDecel(const std::string& vehID, double decel) {
1247  Dom::setDouble(libsumo::VAR_DECEL, vehID, decel);
1248 }
1249 
1250 
1251 void
1252 Vehicle::setEmergencyDecel(const std::string& vehID, double decel) {
1254 }
1255 
1256 
1257 void
1258 Vehicle::setApparentDecel(const std::string& vehID, double decel) {
1260 }
1261 
1262 
1263 void
1264 Vehicle::setImperfection(const std::string& vehID, double imperfection) {
1265  Dom::setDouble(libsumo::VAR_IMPERFECTION, vehID, imperfection);
1266 }
1267 
1268 
1269 void
1270 Vehicle::setTau(const std::string& vehID, double tau) {
1271  Dom::setDouble(libsumo::VAR_TAU, vehID, tau);
1272 }
1273 
1274 
1275 void
1276 Vehicle::setMinGapLat(const std::string& vehID, double minGapLat) {
1277  Dom::setDouble(libsumo::VAR_MINGAP_LAT, vehID, minGapLat);
1278 }
1279 
1280 
1281 void
1282 Vehicle::setMaxSpeedLat(const std::string& vehID, double speed) {
1284 }
1285 
1286 
1287 void
1288 Vehicle::setLateralAlignment(const std::string& vehID, const std::string& latAlignment) {
1289  Dom::setString(libsumo::VAR_LATALIGNMENT, vehID, latAlignment);
1290 }
1291 
1292 
1293 void
1294 Vehicle::setImpatience(const std::string& vehID, double impatience) {
1295  Dom::setDouble(libsumo::VAR_IMPATIENCE, vehID, impatience);
1296 }
1297 
1298 void
1299 Vehicle::setBoardingDuration(const std::string& vehID, double boardingDuration) {
1300  Dom::setDouble(libsumo::VAR_BOARDING_DURATION, vehID, boardingDuration);
1301 }
1302 
1303 
1304 void
1305 Vehicle::highlight(const std::string& vehID, const libsumo::TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
1306  tcpip::Storage content;
1307  StoHelp::writeCompound(content, alphaMax > 0 ? 5 : 2);
1309  content.writeUnsignedByte(col.r);
1310  content.writeUnsignedByte(col.g);
1311  content.writeUnsignedByte(col.b);
1312  content.writeUnsignedByte(col.a);
1313  StoHelp::writeTypedDouble(content, size);
1314  if (alphaMax > 0) {
1316  content.writeUnsignedByte(alphaMax);
1317  StoHelp::writeTypedDouble(content, duration);
1319  content.writeUnsignedByte(type);
1320  }
1321  Dom::set(libsumo::VAR_HIGHLIGHT, vehID, &content);
1322 }
1323 
1324 void
1325 Vehicle::dispatchTaxi(const std::string& vehID, const std::vector<std::string>& reservations) {
1326  Dom::setStringVector(libsumo::CMD_TAXI_DISPATCH, vehID, reservations);
1327 }
1328 
1329 
1330 void
1331 Vehicle::subscribeLeader(const std::string& vehID, double dist, double begin, double end) {
1332  subscribe(vehID, std::vector<int>({ libsumo::VAR_LEADER }), begin, end,
1333  libsumo::TraCIResults({ {libsumo::VAR_LEADER, std::make_shared<libsumo::TraCIDouble>(dist)} }));
1334 }
1335 
1336 
1337 void
1338 Vehicle::addSubscriptionFilterLanes(const std::vector<int>& lanes, bool noOpposite, double downstreamDist, double upstreamDist) {
1339  tcpip::Storage content;
1340  content.writeUnsignedByte((int)lanes.size());
1341  for (int lane : lanes) {
1342  content.writeUnsignedByte(lane < 0 ? lane + 256 : lane);
1343  }
1345  if (noOpposite) {
1346  addSubscriptionFilterNoOpposite();
1347  }
1348  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1349  addSubscriptionFilterDownstreamDistance(downstreamDist);
1350  }
1351  if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1352  addSubscriptionFilterUpstreamDistance(upstreamDist);
1353  }
1354 }
1355 
1356 
1357 void
1358 Vehicle::addSubscriptionFilterNoOpposite() {
1360 }
1361 
1362 
1363 void
1364 Vehicle::addSubscriptionFilterDownstreamDistance(double dist) {
1365  tcpip::Storage content;
1366  StoHelp::writeTypedDouble(content, dist);
1368 }
1369 
1370 
1371 void
1372 Vehicle::addSubscriptionFilterUpstreamDistance(double dist) {
1373  tcpip::Storage content;
1374  StoHelp::writeTypedDouble(content, dist);
1376 }
1377 
1378 
1379 void
1380 Vehicle::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) {
1381  addSubscriptionFilterLeadFollow(std::vector<int>(1));
1382  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1383  addSubscriptionFilterDownstreamDistance(downstreamDist);
1384  }
1385  if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1386  addSubscriptionFilterUpstreamDistance(upstreamDist);
1387  }
1388 }
1389 
1390 
1391 void
1392 Vehicle::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) {
1393  if (direction == libsumo::INVALID_INT_VALUE) {
1394  addSubscriptionFilterLeadFollow({ -1, 0, 1 });
1395  } else if (direction != -1 && direction != 1) {
1396  // warnings.warn("Ignoring lane change subscription filter with non-neighboring lane offset direction=%s." % direction)
1397  return;
1398  } else {
1399  addSubscriptionFilterLeadFollow({ 0, direction });
1400  }
1401  if (noOpposite) {
1402  addSubscriptionFilterNoOpposite();
1403  }
1404  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1405  addSubscriptionFilterDownstreamDistance(downstreamDist);
1406  }
1407  if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1408  addSubscriptionFilterUpstreamDistance(upstreamDist);
1409  }
1410 }
1411 
1412 
1413 void
1414 Vehicle::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) {
1416  addSubscriptionFilterLanes(lanes);
1417 }
1418 
1419 
1420 void
1421 Vehicle::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) {
1422  tcpip::Storage content;
1423  StoHelp::writeTypedDouble(content, foeDistToJunction);
1425  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1426  addSubscriptionFilterDownstreamDistance(downstreamDist);
1427  }
1428 }
1429 
1430 
1431 void
1432 Vehicle::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) {
1433  tcpip::Storage content;
1434  StoHelp::writeTypedStringList(content, vClasses);
1436 }
1437 
1438 
1439 void
1440 Vehicle::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) {
1441  tcpip::Storage content;
1442  StoHelp::writeTypedStringList(content, vTypes);
1444 }
1445 
1446 
1447 void
1448 Vehicle::addSubscriptionFilterFieldOfVision(double openingAngle) {
1449  tcpip::Storage content;
1450  StoHelp::writeTypedDouble(content, openingAngle);
1452 }
1453 
1454 
1455 void
1456 Vehicle::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) {
1457  tcpip::Storage content;
1458  StoHelp::writeTypedDouble(content, lateralDist);
1460  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1461  addSubscriptionFilterDownstreamDistance(downstreamDist);
1462  }
1463  if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1464  addSubscriptionFilterUpstreamDistance(upstreamDist);
1465  }
1466 }
1467 
1468 
1469 }
1470 
1471 
1472 /****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:38
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:77
C++ TraCI client API implementation.
Definition: Vehicle.h:34
static void writeTypedDouble(tcpip::Storage &content, double value)
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
Definition: StorageHelper.h:85
static bool readBool(tcpip::Storage &ret, const std::string &error="")
Definition: StorageHelper.h:96
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
Definition: StorageHelper.h:50
static void writeCompound(tcpip::Storage &content, int size)
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
Definition: StorageHelper.h:71
static void writeTypedInt(tcpip::Storage &content, int value)
static void writeTypedStringList(tcpip::Storage &content, const std::vector< std::string > &value)
static void writeTypedByte(tcpip::Storage &content, int value)
static void writeTypedString(tcpip::Storage &content, const std::string &value)
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
Definition: StorageHelper.h:64
std::string approachedLane
Definition: TraCIDefs.h:404
std::string approachedInternal
Definition: TraCIDefs.h:408
void addFilter(int var, tcpip::Storage *add=nullptr)
Definition: Connection.cpp:342
std::mutex & getMutex() const
Definition: Connection.h:76
static Connection & getActive()
Definition: Connection.h:57
static void setDouble(int var, const std::string &id, double value)
Definition: Domain.h:231
static libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
Definition: Domain.h:153
static void setCol(int var, const std::string &id, const libsumo::TraCIColor value)
Definition: Domain.h:252
static void setStringVector(int var, const std::string &id, const std::vector< std::string > &value)
Definition: Domain.h:245
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:177
static libsumo::TraCIColor getCol(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:187
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:172
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:125
static void set(int var, const std::string &id, tcpip::Storage *add)
Definition: Domain.h:219
static libsumo::TraCIPosition getPos3D(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
Definition: Domain.h:162
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:130
static tcpip::Storage & get(int var, const std::string &id, tcpip::Storage *add=nullptr, int expectedType=libsumo::TYPE_COMPOUND)
Definition: Domain.h:111
static void setInt(int var, const std::string &id, int value)
Definition: Domain.h:224
static void setString(int var, const std::string &id, const std::string &value)
Definition: Domain.h:238
virtual std::string readString()
Definition: storage.cpp:180
virtual void writeString(const std::string &s)
Definition: storage.cpp:197
virtual void writeDouble(double)
Definition: storage.cpp:354
virtual int readUnsignedByte()
Definition: storage.cpp:155
virtual void writeUnsignedByte(int)
Definition: storage.cpp:165
virtual int readByte()
Definition: storage.cpp:128
virtual double readDouble()
Definition: storage.cpp:362
virtual int readInt()
Definition: storage.cpp:311
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int VAR_LASTACTIONTIME
TRACI_CONST int TYPE_COLOR
TRACI_CONST int FILTER_TYPE_DOWNSTREAM_DIST
TRACI_CONST int VAR_EDGES
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_NOXEMISSION
TRACI_CONST int VAR_LANECHANGE_MODE
TRACI_CONST int LAST_STEP_PERSON_ID_LIST
TRACI_CONST int FILTER_TYPE_NOOPPOSITE
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_IMPATIENCE
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int VAR_TYPE
TRACI_CONST int CMD_CHANGESUBLANE
TRACI_CONST int VAR_DEPARTURE
TRACI_CONST int VAR_ROUTING_MODE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int CMD_TAXI_DISPATCH
TRACI_CONST int VAR_SECURE_GAP
TRACI_CONST int VAR_SHAPECLASS
TRACI_CONST int VAR_WAITING_TIME
TRACI_CONST int CMD_STOP
TRACI_CONST int VAR_LINE
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int VAR_TIMELOSS
TRACI_CONST int CMD_RESUME
TRACI_CONST int VAR_ACTIONSTEPLENGTH
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int MOVE_TO_XY
TRACI_CONST int VAR_FOLLOW_SPEED
TRACI_CONST int VAR_STOP_ARRIVALDELAY
TRACI_CONST int VAR_SPEED_LAT
TRACI_CONST int FILTER_TYPE_FIELD_OF_VISION
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_TAU
TRACI_CONST int VAR_NEXT_TLS
TRACI_CONST int VAR_EDGE_EFFORT
TRACI_CONST int VAR_ROUTE
TRACI_CONST int VAR_BEST_LANES
TRACI_CONST int VAR_ALLOWED_SPEED
TRACI_CONST int VAR_LANE_INDEX
TRACI_CONST int VAR_PMXEMISSION
TRACI_CONST int VAR_SPEED_WITHOUT_TRACI
TRACI_CONST int VAR_HIGHLIGHT
TRACI_CONST int VAR_BOARDING_DURATION
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int VAR_MOVE_TO
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int VAR_COEMISSION
TRACI_CONST int VAR_UPDATE_BESTLANES
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_STOP_PARAMETER
TRACI_CONST int POSITION_2D
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int VAR_LEADER
TRACI_CONST int CMD_CHANGETARGET
TRACI_CONST int ADD_FULL
TRACI_CONST int VAR_CO2EMISSION
TRACI_CONST int CMD_REROUTE_TO_PARKING
TRACI_CONST int FILTER_TYPE_VTYPE
TRACI_CONST int VAR_TELEPORTING_LIST
TRACI_CONST int CMD_REROUTE_TRAVELTIME
TRACI_CONST int VAR_TAXI_FLEET
TRACI_CONST int VAR_PREV_SPEED
TRACI_CONST int VAR_ROUTE_VALID
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int CMD_REPLACE_STOP
TRACI_CONST int VAR_FUELCONSUMPTION
TRACI_CONST int VAR_SLOPE
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int CMD_REROUTE_EFFORT
TRACI_CONST int VAR_HCEMISSION
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int REMOVE
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int CMD_INSERT_STOP
TRACI_CONST int VAR_STOP_SPEED
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_APPARENT_DECEL
TRACI_CONST int VAR_NOISEEMISSION
TRACI_CONST int FILTER_TYPE_LEAD_FOLLOW
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_DECEL
TRACI_CONST int VAR_SIGNALS
TRACI_CONST int FILTER_TYPE_UPSTREAM_DIST
TRACI_CONST int VAR_ACCUMULATED_WAITING_TIME
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int VAR_NEXT_LINKS
TRACI_CONST int VAR_ROUTE_INDEX
TRACI_CONST int VAR_NEXT_STOPS2
TRACI_CONST int CMD_SLOWDOWN
TRACI_CONST int FILTER_TYPE_TURN
TRACI_CONST int VAR_ACCELERATION
TRACI_CONST int VAR_ROUTE_ID
TRACI_CONST int DISTANCE_REQUEST
TRACI_CONST int TYPE_BYTE
TRACI_CONST int CMD_OPENGAP
TRACI_CONST int VAR_LANEPOSITION_LAT
TRACI_CONST int FILTER_TYPE_VCLASS
TRACI_CONST int CMD_CHANGELANE
TRACI_CONST int VAR_STOP_DELAY
TRACI_CONST int VAR_NEIGHBORS
TRACI_CONST int VAR_EMERGENCY_DECEL
TRACI_CONST int VAR_STOPSTATE
TRACI_CONST int VAR_FOLLOWER
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int VAR_LOADED_LIST
TRACI_CONST int FILTER_TYPE_LANES
TRACI_CONST int VAR_ACCEL
TRACI_CONST int VAR_DEPART_DELAY
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
Definition: TraCIDefs.h:335
TRACI_CONST int VAR_FOES
TRACI_CONST int VAR_DISTANCE
TRACI_CONST int FILTER_TYPE_LATERAL_DIST
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
TRACI_CONST int VAR_SPEED_DEVIATION
TRACI_CONST int VAR_VIA
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
double length
The length than can be driven from that lane without lane change.
Definition: TraCIDefs.h:544
double occupation
The traffic density along length.
Definition: TraCIDefs.h:546
bool allowsContinuation
Whether this lane allows continuing the route.
Definition: TraCIDefs.h:550
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:548
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:552
std::string laneID
The id of the lane.
Definition: TraCIDefs.h:542
std::string foeId
the id of the vehicle with intersecting trajectory
Definition: TraCIDefs.h:679
std::string stoppingPlaceID
Id assigned to the stop.
Definition: TraCIDefs.h:493
std::string lane
The lane to stop at.
Definition: TraCIDefs.h:487
int stopFlags
Stop flags.
Definition: TraCIDefs.h:495
std::string actType
additional information for this stop
Definition: TraCIDefs.h:511
std::string tripId
id of the trip within a cyclical public transport route
Definition: TraCIDefs.h:513
double startPos
The stopping position start.
Definition: TraCIDefs.h:489
double arrival
The actual arrival time (only for past stops)
Definition: TraCIDefs.h:503
double depart
The time at which this stop was ended.
Definition: TraCIDefs.h:505
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
Definition: TraCIDefs.h:509
double speed
the speed at which this stop counts as reached (waypoint mode)
Definition: TraCIDefs.h:517
double intendedArrival
The intended arrival time.
Definition: TraCIDefs.h:501
double endPos
The stopping position end.
Definition: TraCIDefs.h:491
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
Definition: TraCIDefs.h:507
std::string line
the new line id of the trip within a cyclical public transport route
Definition: TraCIDefs.h:515
double duration
The intended (minimum) stopping duration.
Definition: TraCIDefs.h:497
double until
The time at which the vehicle may continue its journey.
Definition: TraCIDefs.h:499
double dist
The distance to the tls.
Definition: TraCIDefs.h:436
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:434
std::string id
The id of the next tls.
Definition: TraCIDefs.h:432
char state
The current state of the tls.
Definition: TraCIDefs.h:438
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
Definition: TraCIDefs.h:178