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::getSegmentID(const std::string& vehID) {
132 }
133 
134 
135 int
136 Vehicle::getSegmentIndex(const std::string& vehID) {
138 }
139 
140 
141 std::string
142 Vehicle::getTypeID(const std::string& vehID) {
143  return Dom::getString(libsumo::VAR_TYPE, vehID);
144 }
145 
146 
147 std::string
148 Vehicle::getRouteID(const std::string& vehID) {
149  return Dom::getString(libsumo::VAR_ROUTE_ID, vehID);
150 }
151 
152 
153 int
154 Vehicle::getRouteIndex(const std::string& vehID) {
155  return Dom::getInt(libsumo::VAR_ROUTE_INDEX, vehID);
156 }
157 
158 
160 Vehicle::getColor(const std::string& vehID) {
161  return Dom::getCol(libsumo::VAR_COLOR, vehID);
162 }
163 
164 double
165 Vehicle::getLanePosition(const std::string& vehID) {
167 }
168 
169 double
170 Vehicle::getLateralLanePosition(const std::string& vehID) {
172 }
173 
174 double
175 Vehicle::getCO2Emission(const std::string& vehID) {
177 }
178 
179 double
180 Vehicle::getCOEmission(const std::string& vehID) {
182 }
183 
184 double
185 Vehicle::getHCEmission(const std::string& vehID) {
187 }
188 
189 double
190 Vehicle::getPMxEmission(const std::string& vehID) {
192 }
193 
194 double
195 Vehicle::getNOxEmission(const std::string& vehID) {
197 }
198 
199 double
200 Vehicle::getFuelConsumption(const std::string& vehID) {
202 }
203 
204 double
205 Vehicle::getNoiseEmission(const std::string& vehID) {
207 }
208 
209 double
210 Vehicle::getElectricityConsumption(const std::string& vehID) {
212 }
213 
214 int
215 Vehicle::getPersonNumber(const std::string& vehID) {
217 }
218 
219 int
220 Vehicle::getPersonCapacity(const std::string& vehID) {
222 }
223 
224 
225 double
226 Vehicle::getBoardingDuration(const std::string& vehID) {
228 }
229 
230 
231 double
232 Vehicle::getImpatience(const std::string& vehID) {
234 }
235 
236 
237 std::vector<std::string>
238 Vehicle::getPersonIDList(const std::string& vehID) {
240 }
241 
242 std::pair<std::string, double>
243 Vehicle::getLeader(const std::string& vehID, double dist) {
244  tcpip::Storage content;
245  StoHelp::writeTypedDouble(content, dist);
246  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
247  tcpip::Storage& ret = Dom::get(libsumo::VAR_LEADER, vehID, &content);
248  ret.readInt(); // components
249  ret.readUnsignedByte();
250  const std::string leaderID = ret.readString();
251  ret.readUnsignedByte();
252  const double gap = ret.readDouble();
253  return std::make_pair(leaderID, gap);
254 }
255 
256 
257 std::pair<std::string, double>
258 Vehicle::getFollower(const std::string& vehID, double dist) {
259  tcpip::Storage content;
260  StoHelp::writeTypedDouble(content, dist);
261  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
262  tcpip::Storage& ret = Dom::get(libsumo::VAR_FOLLOWER, vehID, &content);
263  ret.readInt(); // components
264  const std::string leaderID = StoHelp::readTypedString(ret);
265  return std::make_pair(leaderID, StoHelp::readTypedDouble(ret));
266 }
267 
268 
269 std::vector<libsumo::TraCIJunctionFoe>
270 Vehicle::getJunctionFoes(const std::string& vehID, double dist) {
271  std::vector<libsumo::TraCIJunctionFoe> result;
272  tcpip::Storage content;
273  StoHelp::writeTypedDouble(content, dist);
274  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
275  tcpip::Storage& ret = Dom::get(libsumo::VAR_FOES, vehID, &content);
276  ret.readInt(); // compound size
277  const int n = StoHelp::readTypedInt(ret); // number of foe informations
278  for (int i = 0; i < n; ++i) {
280  info.foeId = StoHelp::readTypedString(ret);
281  info.egoDist = StoHelp::readTypedDouble(ret);
282  info.foeDist = StoHelp::readTypedDouble(ret);
285  info.egoLane = StoHelp::readTypedString(ret);
286  info.foeLane = StoHelp::readTypedString(ret);
287  info.egoResponse = StoHelp::readBool(ret);
288  info.foeResponse = StoHelp::readBool(ret);
289  result.emplace_back(info);
290  }
291  return result;
292 }
293 
294 
295 double
296 Vehicle::getWaitingTime(const std::string& vehID) {
298 }
299 
300 
301 double
302 Vehicle::getAccumulatedWaitingTime(const std::string& vehID) {
304 }
305 
306 
307 double
308 Vehicle::getAdaptedTraveltime(const std::string& vehID, double time, const std::string& edgeID) {
309  tcpip::Storage content;
310  StoHelp::writeCompound(content, 2);
311  StoHelp::writeTypedDouble(content, time);
312  StoHelp::writeTypedString(content, edgeID);
313  return Dom::getDouble(libsumo::VAR_EDGE_TRAVELTIME, vehID, &content);
314 }
315 
316 
317 double
318 Vehicle::getEffort(const std::string& vehID, double time, const std::string& edgeID) {
319  tcpip::Storage content;
320  StoHelp::writeCompound(content, 2);
321  StoHelp::writeTypedDouble(content, time);
322  StoHelp::writeTypedString(content, edgeID);
323  return Dom::getDouble(libsumo::VAR_EDGE_EFFORT, vehID, &content);
324 }
325 
326 
327 bool
328 Vehicle::isRouteValid(const std::string& vehID) {
329  return Dom::getInt(libsumo::VAR_ROUTE_VALID, vehID) != 0;
330 }
331 
332 
333 std::vector<std::string>
334 Vehicle::getRoute(const std::string& vehID) {
336 }
337 
338 
339 int
340 Vehicle::getSignals(const std::string& vehID) {
341  return Dom::getInt(libsumo::VAR_SIGNALS, vehID);
342 }
343 
344 
345 std::vector<libsumo::TraCIBestLanesData>
346 Vehicle::getBestLanes(const std::string& vehID) {
347  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
348  std::vector<libsumo::TraCIBestLanesData> result;
350  ret.readInt();
351  ret.readUnsignedByte();
352 
353  const int n = ret.readInt(); // number of following edge information
354  for (int i = 0; i < n; ++i) {
356  ret.readUnsignedByte();
357  info.laneID = ret.readString();
358 
359  ret.readUnsignedByte();
360  info.length = ret.readDouble();
361 
362  ret.readUnsignedByte();
363  info.occupation = ret.readDouble();
364 
365  ret.readUnsignedByte();
366  info.bestLaneOffset = ret.readByte();
367 
368  ret.readUnsignedByte();
369  info.allowsContinuation = (ret.readUnsignedByte() == 1);
370 
371  ret.readUnsignedByte();
372  int m = ret.readInt();
373  while (m-- > 0) {
374  info.continuationLanes.push_back(ret.readString());
375  }
376  result.push_back(info);
377  }
378  return result;
379 }
380 
381 
382 std::vector<libsumo::TraCINextTLSData>
383 Vehicle::getNextTLS(const std::string& vehID) {
384  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
385  std::vector<libsumo::TraCINextTLSData> result;
387  ret.readInt(); // components
388  // number of items
389  ret.readUnsignedByte();
390  const int n = ret.readInt();
391  for (int i = 0; i < n; ++i) {
393  ret.readUnsignedByte();
394  d.id = ret.readString();
395 
396  ret.readUnsignedByte();
397  d.tlIndex = ret.readInt();
398 
399  ret.readUnsignedByte();
400  d.dist = ret.readDouble();
401 
402  ret.readUnsignedByte();
403  d.state = (char)ret.readByte();
404 
405  result.push_back(d);
406  }
407  return result;
408 }
409 
410 std::vector<libsumo::TraCINextStopData>
411 Vehicle::getNextStops(const std::string& vehID) {
412  return getStops(vehID, 0);
413 }
414 
415 std::vector<libsumo::TraCIConnection>
416 Vehicle::getNextLinks(const std::string& vehID) {
417  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
418  std::vector<libsumo::TraCIConnection> result;
420  ret.readInt(); // components
421  // number of items
422  ret.readUnsignedByte();
423 
424  const int linkNo = ret.readInt();
425  for (int i = 0; i < linkNo; ++i) {
429  con.hasPrio = StoHelp::readBool(ret);
430  con.isOpen = StoHelp::readBool(ret);
431  con.hasFoe = StoHelp::readBool(ret);
432  con.state = StoHelp::readTypedString(ret);
434  con.length = StoHelp::readTypedDouble(ret);
435  result.emplace_back(con);
436  }
437  return result;
438 }
439 
440 std::vector<libsumo::TraCINextStopData>
441 Vehicle::getStops(const std::string& vehID, int limit) {
442  std::vector<libsumo::TraCINextStopData> result;
443  tcpip::Storage content;
444  StoHelp::writeTypedInt(content, limit);
445  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
446  tcpip::Storage& ret = Dom::get(libsumo::VAR_NEXT_STOPS2, vehID, &content);
447  ret.readInt(); // components
448  // number of items
449  const int n = StoHelp::readCompound(ret);
450  for (int i = 0; i < n; ++i) {
468  result.emplace_back(s);
469  }
470  return result;
471 }
472 
473 std::string
474 Vehicle::getStopParameter(const std::string& vehID, int nextStopIndex, const std::string& param, bool customParam) {
475  tcpip::Storage content;
476  StoHelp::writeCompound(content, 3);
477  StoHelp::writeTypedInt(content, nextStopIndex);
478  StoHelp::writeTypedString(content, param);
479  StoHelp::writeTypedByte(content, customParam);
480  return Dom::getString(libsumo::VAR_STOP_PARAMETER, vehID, &content);
481 }
482 
483 int
484 Vehicle::getStopState(const std::string& vehID) {
485  return Dom::getInt(libsumo::VAR_STOPSTATE, vehID);
486 }
487 
488 
489 double
490 Vehicle::getDistance(const std::string& vehID) {
491  return Dom::getDouble(libsumo::VAR_DISTANCE, vehID);
492 }
493 
494 
495 double
496 Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int laneIndex) {
497  tcpip::Storage content;
498  StoHelp::writeCompound(content, 2);
500  content.writeString(edgeID);
501  content.writeDouble(pos);
502  content.writeUnsignedByte(laneIndex);
504  return Dom::getDouble(libsumo::DISTANCE_REQUEST, vehID, &content);
505 }
506 
507 
508 double
509 Vehicle::getDrivingDistance2D(const std::string& vehID, double x, double y) {
510  tcpip::Storage content;
511  StoHelp::writeCompound(content, 2);
513  content.writeDouble(x);
514  content.writeDouble(y);
516  return Dom::getDouble(libsumo::DISTANCE_REQUEST, vehID, &content);
517 }
518 
519 
520 double
521 Vehicle::getAllowedSpeed(const std::string& vehID) {
523 }
524 
525 
526 double
527 Vehicle::getSpeedFactor(const std::string& vehID) {
529 }
530 
531 
532 int
533 Vehicle::getSpeedMode(const std::string& vehID) {
534  return Dom::getInt(libsumo::VAR_SPEEDSETMODE, vehID);
535 }
536 
537 
538 int
539 Vehicle::getLaneChangeMode(const std::string& vehID) {
541 }
542 
543 
544 int
545 Vehicle::getRoutingMode(const std::string& vehID) {
546  return Dom::getInt(libsumo::VAR_ROUTING_MODE, vehID);
547 }
548 
549 
550 std::string
551 Vehicle::getLine(const std::string& vehID) {
552  return Dom::getString(libsumo::VAR_LINE, vehID);
553 }
554 
555 
556 
557 std::vector<std::string>
558 Vehicle::getVia(const std::string& vehID) {
559  return Dom::getStringVector(libsumo::VAR_VIA, vehID);
560 }
561 
562 
563 std::pair<int, int>
564 Vehicle::getLaneChangeState(const std::string& vehID, int direction) {
565  tcpip::Storage content;
566  StoHelp::writeTypedInt(content, direction);
567  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
568  tcpip::Storage& ret = Dom::get(libsumo::CMD_CHANGELANE, vehID, &content);
569  ret.readInt(); // components
570  ret.readUnsignedByte();
571  const int stateWithoutTraCI = ret.readInt();
572  ret.readUnsignedByte();
573  const int state = ret.readInt();
574  return std::make_pair(stateWithoutTraCI, state);
575 }
576 
577 
578 std::vector<std::pair<std::string, double> >
579 Vehicle::getNeighbors(const std::string& vehID, const int mode) {
580  std::vector<std::pair<std::string, double> > neighs;
581  tcpip::Storage content;
583  content.writeUnsignedByte(mode);
584  std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
585  tcpip::Storage& ret = Dom::get(libsumo::VAR_NEIGHBORS, vehID, &content);
586  const int items = ret.readInt(); // components
587  for (int i = 0; i < items; i++) {
588  const std::string neighID = ret.readString();
589  neighs.emplace_back(neighID, ret.readDouble());
590  }
591  return neighs;
592 }
593 
594 
595 double
596 Vehicle::getFollowSpeed(const std::string& vehID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
597  tcpip::Storage content;
598  StoHelp::writeCompound(content, 5);
599  StoHelp::writeTypedDouble(content, speed);
600  StoHelp::writeTypedDouble(content, gap);
601  StoHelp::writeTypedDouble(content, leaderSpeed);
602  StoHelp::writeTypedDouble(content, leaderMaxDecel);
603  StoHelp::writeTypedString(content, leaderID);
604  return Dom::getDouble(libsumo::VAR_FOLLOW_SPEED, vehID, &content);
605 }
606 
607 
608 double
609 Vehicle::getSecureGap(const std::string& vehID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
610  tcpip::Storage content;
611  StoHelp::writeCompound(content, 4);
612  StoHelp::writeTypedDouble(content, speed);
613  StoHelp::writeTypedDouble(content, leaderSpeed);
614  StoHelp::writeTypedDouble(content, leaderMaxDecel);
615  StoHelp::writeTypedString(content, leaderID);
616  return Dom::getDouble(libsumo::VAR_SECURE_GAP, vehID, &content);
617 }
618 
619 
620 double
621 Vehicle::getStopSpeed(const std::string& vehID, const double speed, double gap) {
622  tcpip::Storage content;
623  StoHelp::writeCompound(content, 2);
624  StoHelp::writeTypedDouble(content, speed);
625  StoHelp::writeTypedDouble(content, gap);
626  return Dom::getDouble(libsumo::VAR_STOP_SPEED, vehID, &content);
627 }
628 
629 double
630 Vehicle::getStopDelay(const std::string& vehID) {
632 }
633 
634 double
635 Vehicle::getStopArrivalDelay(const std::string& vehID) {
637 }
638 
639 double
640 Vehicle::getTimeLoss(const std::string& vehID) {
641  return Dom::getDouble(libsumo::VAR_TIMELOSS, vehID);
642 }
643 
644 std::vector<std::string>
645 Vehicle::getTaxiFleet(int taxiState) {
646  tcpip::Storage content;
647  StoHelp::writeTypedInt(content, taxiState);
648  return Dom::getStringVector(libsumo::VAR_TAXI_FLEET, "", &content);
649 }
650 
651 std::vector<std::string>
652 Vehicle::getLoadedIDList() {
654 }
655 
656 std::vector<std::string>
657 Vehicle::getTeleportingIDList() {
659 }
660 
661 std::string
662 Vehicle::getEmissionClass(const std::string& vehID) {
664 }
665 
666 std::string
667 Vehicle::getShapeClass(const std::string& vehID) {
669 }
670 
671 
672 double
673 Vehicle::getLength(const std::string& vehID) {
674  return Dom::getDouble(libsumo::VAR_LENGTH, vehID);
675 }
676 
677 
678 double
679 Vehicle::getAccel(const std::string& vehID) {
680  return Dom::getDouble(libsumo::VAR_ACCEL, vehID);
681 }
682 
683 
684 double
685 Vehicle::getDecel(const std::string& vehID) {
686  return Dom::getDouble(libsumo::VAR_DECEL, vehID);
687 }
688 
689 
690 double Vehicle::getEmergencyDecel(const std::string& vehID) {
692 }
693 
694 
695 double Vehicle::getApparentDecel(const std::string& vehID) {
697 }
698 
699 
700 double Vehicle::getActionStepLength(const std::string& vehID) {
702 }
703 
704 
705 double Vehicle::getLastActionTime(const std::string& vehID) {
707 }
708 
709 
710 double
711 Vehicle::getTau(const std::string& vehID) {
712  return Dom::getDouble(libsumo::VAR_TAU, vehID);
713 }
714 
715 
716 double
717 Vehicle::getImperfection(const std::string& vehID) {
719 }
720 
721 
722 double
723 Vehicle::getSpeedDeviation(const std::string& vehID) {
725 }
726 
727 
728 std::string
729 Vehicle::getVehicleClass(const std::string& vehID) {
731 }
732 
733 
734 double
735 Vehicle::getMinGap(const std::string& vehID) {
736  return Dom::getDouble(libsumo::VAR_MINGAP, vehID);
737 }
738 
739 
740 double
741 Vehicle::getMinGapLat(const std::string& vehID) {
743 }
744 
745 
746 double
747 Vehicle::getMaxSpeed(const std::string& vehID) {
748  return Dom::getDouble(libsumo::VAR_MAXSPEED, vehID);
749 }
750 
751 
752 double
753 Vehicle::getMaxSpeedLat(const std::string& vehID) {
755 }
756 
757 
758 std::string
759 Vehicle::getLateralAlignment(const std::string& vehID) {
761 }
762 
763 
764 double
765 Vehicle::getWidth(const std::string& vehID) {
766  return Dom::getDouble(libsumo::VAR_WIDTH, vehID);
767 }
768 
769 
770 double
771 Vehicle::getHeight(const std::string& vehID) {
772  return Dom::getDouble(libsumo::VAR_HEIGHT, vehID);
773 }
774 
775 
776 double
777 Vehicle::getMass(const std::string& vehID) {
778  return Dom::getDouble(libsumo::VAR_MASS, vehID);
779 }
780 
781 
782 void
783 Vehicle::setStop(const std::string& vehID,
784  const std::string& edgeID,
785  double pos,
786  int laneIndex,
787  double duration,
788  int flags,
789  double startPos,
790  double until) {
791  tcpip::Storage content;
792  StoHelp::writeCompound(content, 7);
793  StoHelp::writeTypedString(content, edgeID);
794  StoHelp::writeTypedDouble(content, pos);
795  StoHelp::writeTypedByte(content, laneIndex);
796  StoHelp::writeTypedDouble(content, duration);
797  StoHelp::writeTypedByte(content, flags);
798  StoHelp::writeTypedDouble(content, startPos);
799  StoHelp::writeTypedDouble(content, until);
800  Dom::set(libsumo::CMD_STOP, vehID, &content);
801 }
802 
803 
804 void
805 Vehicle::replaceStop(const std::string& vehID,
806  int nextStopIndex,
807  const std::string& edgeID,
808  double pos,
809  int laneIndex,
810  double duration,
811  int flags,
812  double startPos,
813  double until,
814  int teleport) {
815  tcpip::Storage content;
816  StoHelp::writeCompound(content, 9);
817  StoHelp::writeTypedString(content, edgeID);
818  StoHelp::writeTypedDouble(content, pos);
819  StoHelp::writeTypedByte(content, laneIndex);
820  StoHelp::writeTypedDouble(content, duration);
821  StoHelp::writeTypedInt(content, flags);
822  StoHelp::writeTypedDouble(content, startPos);
823  StoHelp::writeTypedDouble(content, until);
824  StoHelp::writeTypedInt(content, nextStopIndex);
825  StoHelp::writeTypedByte(content, teleport);
826  Dom::set(libsumo::CMD_REPLACE_STOP, vehID, &content);
827 }
828 
829 
830 void
831 Vehicle::insertStop(const std::string& vehID,
832  int nextStopIndex,
833  const std::string& edgeID,
834  double pos,
835  int laneIndex,
836  double duration,
837  int flags,
838  double startPos,
839  double until,
840  int teleport) {
841  tcpip::Storage content;
842  StoHelp::writeCompound(content, 9);
843  StoHelp::writeTypedString(content, edgeID);
844  StoHelp::writeTypedDouble(content, pos);
845  StoHelp::writeTypedByte(content, laneIndex);
846  StoHelp::writeTypedDouble(content, duration);
847  StoHelp::writeTypedInt(content, flags);
848  StoHelp::writeTypedDouble(content, startPos);
849  StoHelp::writeTypedDouble(content, until);
850  StoHelp::writeTypedInt(content, nextStopIndex);
851  StoHelp::writeTypedByte(content, teleport);
852  Dom::set(libsumo::CMD_INSERT_STOP, vehID, &content);
853 }
854 
855 
856 void
857 Vehicle::setStopParameter(const std::string& vehID, int nextStopIndex,
858  const std::string& param, const std::string& value,
859  bool customParam) {
860  tcpip::Storage content;
861  StoHelp::writeCompound(content, 4);
862  StoHelp::writeTypedInt(content, nextStopIndex);
863  StoHelp::writeTypedString(content, param);
864  StoHelp::writeTypedString(content, value);
865  StoHelp::writeTypedByte(content, customParam);
866  Dom::set(libsumo::VAR_STOP_PARAMETER, vehID, &content);
867 }
868 
869 
870 void
871 Vehicle::rerouteParkingArea(const std::string& vehID, const std::string& parkingAreaID) {
872  tcpip::Storage content;
873  StoHelp::writeCompound(content, 1);
874  StoHelp::writeTypedString(content, parkingAreaID);
875  Dom::set(libsumo::CMD_REROUTE_TO_PARKING, vehID, &content);
876 }
877 
878 
879 void
880 Vehicle::resume(const std::string& vehID) {
881  tcpip::Storage content;
882  StoHelp::writeCompound(content, 0);
883  Dom::set(libsumo::CMD_RESUME, vehID, &content);
884 }
885 
886 
887 void
888 Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
890 }
891 
892 
893 void
894 Vehicle::changeLane(const std::string& vehID, int laneIndex, double duration) {
895  tcpip::Storage content;
896  StoHelp::writeCompound(content, 2);
897  StoHelp::writeTypedByte(content, laneIndex);
898  StoHelp::writeTypedDouble(content, duration);
899  Dom::set(libsumo::CMD_CHANGELANE, vehID, &content);
900 }
901 
902 void
903 Vehicle::changeLaneRelative(const std::string& vehID, int indexOffset, double duration) {
904  tcpip::Storage content;
905  StoHelp::writeCompound(content, 3);
906  StoHelp::writeTypedByte(content, indexOffset);
907  StoHelp::writeTypedDouble(content, duration);
908  StoHelp::writeTypedByte(content, 1);
909  Dom::set(libsumo::CMD_CHANGELANE, vehID, &content);
910 }
911 
912 
913 void
914 Vehicle::changeSublane(const std::string& vehID, double latDist) {
916 }
917 
918 
919 void
920 Vehicle::add(const std::string& vehID,
921  const std::string& routeID,
922  const std::string& typeID,
923  const std::string& depart,
924  const std::string& departLane,
925  const std::string& departPos,
926  const std::string& departSpeed,
927  const std::string& arrivalLane,
928  const std::string& arrivalPos,
929  const std::string& arrivalSpeed,
930  const std::string& fromTaz,
931  const std::string& toTaz,
932  const std::string& line,
933  int personCapacity,
934  int personNumber) {
935  tcpip::Storage content;
936  StoHelp::writeCompound(content, 14);
937  StoHelp::writeTypedString(content, routeID);
938  StoHelp::writeTypedString(content, typeID);
939  StoHelp::writeTypedString(content, depart);
940  StoHelp::writeTypedString(content, departLane);
941  StoHelp::writeTypedString(content, departPos);
942  StoHelp::writeTypedString(content, departSpeed);
943 
944  StoHelp::writeTypedString(content, arrivalLane);
945  StoHelp::writeTypedString(content, arrivalPos);
946  StoHelp::writeTypedString(content, arrivalSpeed);
947 
948  StoHelp::writeTypedString(content, fromTaz);
949  StoHelp::writeTypedString(content, toTaz);
950  StoHelp::writeTypedString(content, line);
951 
952  StoHelp::writeTypedInt(content, personCapacity);
953  StoHelp::writeTypedInt(content, personNumber);
954 
955  Dom::set(libsumo::ADD_FULL, vehID, &content);
956 }
957 
958 
959 void
960 Vehicle::moveToXY(const std::string& vehID, const std::string& edgeID, const int laneIndex,
961  const double x, const double y, double angle, const int keepRoute, double matchThreshold) {
962  tcpip::Storage content;
963  StoHelp::writeCompound(content, 7);
964  StoHelp::writeTypedString(content, edgeID);
965  StoHelp::writeTypedInt(content, laneIndex);
966  StoHelp::writeTypedDouble(content, x);
967  StoHelp::writeTypedDouble(content, y);
968  StoHelp::writeTypedDouble(content, angle);
969  StoHelp::writeTypedByte(content, keepRoute);
970  StoHelp::writeTypedDouble(content, matchThreshold);
971  Dom::set(libsumo::MOVE_TO_XY, vehID, &content);
972 }
973 
974 void
975 Vehicle::slowDown(const std::string& vehID, double speed, double duration) {
976  tcpip::Storage content;
977  StoHelp::writeCompound(content, 2);
978  StoHelp::writeTypedDouble(content, speed);
979  StoHelp::writeTypedDouble(content, duration);
980  Dom::set(libsumo::CMD_SLOWDOWN, vehID, &content);
981 }
982 
983 void
984 Vehicle::openGap(const std::string& vehID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, const std::string& referenceVehID) {
985  tcpip::Storage content;
986  StoHelp::writeCompound(content, referenceVehID != "" ? 6 : 5);
987  StoHelp::writeTypedDouble(content, newTimeHeadway);
988  StoHelp::writeTypedDouble(content, newSpaceHeadway);
989  StoHelp::writeTypedDouble(content, duration);
990  StoHelp::writeTypedDouble(content, changeRate);
991  StoHelp::writeTypedDouble(content, maxDecel);
992  if (referenceVehID != "") {
993  StoHelp::writeTypedString(content, referenceVehID);
994  }
995  Dom::set(libsumo::CMD_OPENGAP, vehID, &content);
996 }
997 
998 void
999 Vehicle::deactivateGapControl(const std::string& vehID) {
1000  openGap(vehID, -1, -1, -1, -1);
1001 }
1002 
1003 void
1004 Vehicle::requestToC(const std::string& vehID, double leadTime) {
1005  std::ostringstream oss;
1006  oss.setf(std::ios::fixed, std::ios::floatfield);
1007  oss << std::setprecision(2);
1008  oss << leadTime;
1009  setParameter(vehID, "device.toc.requestToC", oss.str());
1010 }
1011 
1012 void
1013 Vehicle::setSpeed(const std::string& vehID, double speed) {
1014  Dom::setDouble(libsumo::VAR_SPEED, vehID, speed);
1015 }
1016 
1017 void
1018 Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
1019  tcpip::Storage content;
1020  StoHelp::writeCompound(content, 2);
1021  StoHelp::writeTypedDouble(content, acceleration);
1022  StoHelp::writeTypedDouble(content, duration);
1023  Dom::set(libsumo::VAR_ACCELERATION, vehID, &content);
1024 }
1025 
1026 void
1027 Vehicle::setPreviousSpeed(const std::string& vehID, double prevSpeed, double prevAcceleration) {
1028  tcpip::Storage content;
1029  StoHelp::writeCompound(content, 2);
1030  StoHelp::writeTypedDouble(content, prevSpeed);
1031  StoHelp::writeTypedDouble(content, prevAcceleration);
1032  Dom::set(libsumo::VAR_PREV_SPEED, vehID, &content);
1033 }
1034 
1035 void
1036 Vehicle::setSpeedMode(const std::string& vehID, int speedMode) {
1037  Dom::setInt(libsumo::VAR_SPEEDSETMODE, vehID, speedMode);
1038 }
1039 
1040 void
1041 Vehicle::setLaneChangeMode(const std::string& vehID, int laneChangeMode) {
1042  Dom::setInt(libsumo::VAR_LANECHANGE_MODE, vehID, laneChangeMode);
1043 }
1044 
1045 void
1046 Vehicle::setRoutingMode(const std::string& vehID, int routingMode) {
1047  Dom::setInt(libsumo::VAR_ROUTING_MODE, vehID, routingMode);
1048 }
1049 
1050 void
1051 Vehicle::setType(const std::string& vehID, const std::string& typeID) {
1052  Dom::setString(libsumo::VAR_TYPE, vehID, typeID);
1053 }
1054 
1055 void
1056 Vehicle::setRouteID(const std::string& vehID, const std::string& routeID) {
1057  Dom::setString(libsumo::VAR_ROUTE_ID, vehID, routeID);
1058 }
1059 
1060 void
1061 Vehicle::setRoute(const std::string& vehID, const std::string& edgeID) {
1062  setRoute(vehID, std::vector<std::string>({edgeID}));
1063 }
1064 
1065 void
1066 Vehicle::setRoute(const std::string& vehID, const std::vector<std::string>& edgeIDs) {
1067  Dom::setStringVector(libsumo::VAR_ROUTE, vehID, edgeIDs);
1068 }
1069 
1070 void
1071 Vehicle::setLateralLanePosition(const std::string& vehID, double posLat) {
1073 }
1074 
1075 void
1076 Vehicle::updateBestLanes(const std::string& vehID) {
1077  tcpip::Storage content;
1078  Dom::set(libsumo::VAR_UPDATE_BESTLANES, vehID, &content);
1079 }
1080 
1081 
1082 void
1083 Vehicle::setAdaptedTraveltime(const std::string& vehID, const std::string& edgeID,
1084  double time, double begSeconds, double endSeconds) {
1085  tcpip::Storage content;
1086  if (time == libsumo::INVALID_DOUBLE_VALUE) {
1087  // reset
1088  StoHelp::writeCompound(content, 1);
1089  StoHelp::writeTypedString(content, edgeID);
1090  } else if (begSeconds == libsumo::INVALID_DOUBLE_VALUE) {
1091  // set value for the whole simulation
1092  StoHelp::writeCompound(content, 2);
1093  StoHelp::writeTypedString(content, edgeID);
1094  StoHelp::writeTypedDouble(content, time);
1095  } else {
1096  StoHelp::writeCompound(content, 4);
1097  StoHelp::writeTypedDouble(content, begSeconds);
1098  StoHelp::writeTypedDouble(content, endSeconds);
1099  StoHelp::writeTypedString(content, edgeID);
1100  StoHelp::writeTypedDouble(content, time);
1101  }
1102  Dom::set(libsumo::VAR_EDGE_TRAVELTIME, vehID, &content);
1103 }
1104 
1105 
1106 void
1107 Vehicle::setEffort(const std::string& vehID, const std::string& edgeID,
1108  double effort, double begSeconds, double endSeconds) {
1109  tcpip::Storage content;
1110  if (effort == libsumo::INVALID_DOUBLE_VALUE) {
1111  // reset
1112  StoHelp::writeCompound(content, 1);
1113  StoHelp::writeTypedString(content, edgeID);
1114  } else if (begSeconds == libsumo::INVALID_DOUBLE_VALUE) {
1115  // set value for the whole simulation
1116  StoHelp::writeCompound(content, 2);
1117  StoHelp::writeTypedString(content, edgeID);
1118  StoHelp::writeTypedDouble(content, effort);
1119  } else {
1120  StoHelp::writeCompound(content, 4);
1121  StoHelp::writeTypedDouble(content, begSeconds);
1122  StoHelp::writeTypedDouble(content, endSeconds);
1123  StoHelp::writeTypedString(content, edgeID);
1124  StoHelp::writeTypedDouble(content, effort);
1125  }
1126  Dom::set(libsumo::VAR_EDGE_EFFORT, vehID, &content);
1127 }
1128 
1129 
1130 void
1131 Vehicle::rerouteTraveltime(const std::string& vehID, const bool /* currentTravelTimes */) {
1132  tcpip::Storage content;
1133  StoHelp::writeCompound(content, 0);
1134  Dom::set(libsumo::CMD_REROUTE_TRAVELTIME, vehID, &content);
1135 }
1136 
1137 
1138 void
1139 Vehicle::rerouteEffort(const std::string& vehID) {
1140  tcpip::Storage content;
1141  StoHelp::writeCompound(content, 0);
1142  Dom::set(libsumo::CMD_REROUTE_EFFORT, vehID, &content);
1143 }
1144 
1145 
1146 void
1147 Vehicle::setSignals(const std::string& vehID, int signals) {
1148  Dom::setInt(libsumo::VAR_SIGNALS, vehID, signals);
1149 }
1150 
1151 
1152 void
1153 Vehicle::moveTo(const std::string& vehID, const std::string& laneID, double pos, int reason) {
1154  tcpip::Storage content;
1155  StoHelp::writeCompound(content, 3);
1156  StoHelp::writeTypedString(content, laneID);
1157  StoHelp::writeTypedDouble(content, pos);
1158  StoHelp::writeTypedInt(content, reason);
1159  Dom::set(libsumo::VAR_MOVE_TO, vehID, &content);
1160 }
1161 
1162 
1163 void
1164 Vehicle::setActionStepLength(const std::string& vehID, double actionStepLength, bool resetActionOffset) {
1165  //if (actionStepLength < 0) {
1166  // raise TraCIException("Invalid value for actionStepLength. Given value must be non-negative.")
1167  //{
1168  // Use negative value to indicate resetActionOffset == False
1169  if (!resetActionOffset) {
1170  actionStepLength *= -1;
1171  }
1172  Dom::setDouble(libsumo::VAR_ACTIONSTEPLENGTH, vehID, actionStepLength);
1173 }
1174 
1175 
1176 void
1177 Vehicle::remove(const std::string& vehID, char reason) {
1178  tcpip::Storage content;
1180  content.writeUnsignedByte(reason);
1181  Dom::set(libsumo::REMOVE, vehID, &content);
1182 }
1183 
1184 
1185 void
1186 Vehicle::setColor(const std::string& vehID, const libsumo::TraCIColor& color) {
1187  Dom::setCol(libsumo::VAR_COLOR, vehID, color);
1188 }
1189 
1190 
1191 void
1192 Vehicle::setSpeedFactor(const std::string& vehID, double factor) {
1193  Dom::setDouble(libsumo::VAR_SPEED_FACTOR, vehID, factor);
1194 }
1195 
1196 
1197 void
1198 Vehicle::setLine(const std::string& vehID, const std::string& line) {
1199  Dom::setString(libsumo::VAR_LINE, vehID, line);
1200 }
1201 
1202 
1203 void
1204 Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
1205  Dom::setStringVector(libsumo::VAR_VIA, vehID, edgeList);
1206 }
1207 
1208 
1209 void
1210 Vehicle::setLength(const std::string& vehID, double length) {
1211  Dom::setDouble(libsumo::VAR_LENGTH, vehID, length);
1212 }
1213 
1214 
1215 void
1216 Vehicle::setMaxSpeed(const std::string& vehID, double speed) {
1217  Dom::setDouble(libsumo::VAR_MAXSPEED, vehID, speed);
1218 }
1219 
1220 
1221 void
1222 Vehicle::setVehicleClass(const std::string& vehID, const std::string& clazz) {
1224 }
1225 
1226 
1227 void
1228 Vehicle::setShapeClass(const std::string& vehID, const std::string& clazz) {
1229  Dom::setString(libsumo::VAR_SHAPECLASS, vehID, clazz);
1230 }
1231 
1232 
1233 void
1234 Vehicle::setEmissionClass(const std::string& vehID, const std::string& clazz) {
1236 }
1237 
1238 
1239 void
1240 Vehicle::setWidth(const std::string& vehID, double width) {
1241  Dom::setDouble(libsumo::VAR_WIDTH, vehID, width);
1242 }
1243 
1244 
1245 void
1246 Vehicle::setHeight(const std::string& vehID, double height) {
1247  Dom::setDouble(libsumo::VAR_HEIGHT, vehID, height);
1248 }
1249 
1250 
1251 void
1252 Vehicle::setMass(const std::string& vehID, double mass) {
1253  Dom::setDouble(libsumo::VAR_MASS, vehID, mass);
1254 }
1255 
1256 
1257 void
1258 Vehicle::setMinGap(const std::string& vehID, double minGap) {
1259  Dom::setDouble(libsumo::VAR_MINGAP, vehID, minGap);
1260 }
1261 
1262 
1263 void
1264 Vehicle::setAccel(const std::string& vehID, double accel) {
1265  Dom::setDouble(libsumo::VAR_ACCEL, vehID, accel);
1266 }
1267 
1268 
1269 void
1270 Vehicle::setDecel(const std::string& vehID, double decel) {
1271  Dom::setDouble(libsumo::VAR_DECEL, vehID, decel);
1272 }
1273 
1274 
1275 void
1276 Vehicle::setEmergencyDecel(const std::string& vehID, double decel) {
1278 }
1279 
1280 
1281 void
1282 Vehicle::setApparentDecel(const std::string& vehID, double decel) {
1284 }
1285 
1286 
1287 void
1288 Vehicle::setImperfection(const std::string& vehID, double imperfection) {
1289  Dom::setDouble(libsumo::VAR_IMPERFECTION, vehID, imperfection);
1290 }
1291 
1292 
1293 void
1294 Vehicle::setTau(const std::string& vehID, double tau) {
1295  Dom::setDouble(libsumo::VAR_TAU, vehID, tau);
1296 }
1297 
1298 
1299 void
1300 Vehicle::setMinGapLat(const std::string& vehID, double minGapLat) {
1301  Dom::setDouble(libsumo::VAR_MINGAP_LAT, vehID, minGapLat);
1302 }
1303 
1304 
1305 void
1306 Vehicle::setMaxSpeedLat(const std::string& vehID, double speed) {
1308 }
1309 
1310 
1311 void
1312 Vehicle::setLateralAlignment(const std::string& vehID, const std::string& latAlignment) {
1313  Dom::setString(libsumo::VAR_LATALIGNMENT, vehID, latAlignment);
1314 }
1315 
1316 
1317 void
1318 Vehicle::setImpatience(const std::string& vehID, double impatience) {
1319  Dom::setDouble(libsumo::VAR_IMPATIENCE, vehID, impatience);
1320 }
1321 
1322 void
1323 Vehicle::setBoardingDuration(const std::string& vehID, double boardingDuration) {
1324  Dom::setDouble(libsumo::VAR_BOARDING_DURATION, vehID, boardingDuration);
1325 }
1326 
1327 
1328 void
1329 Vehicle::highlight(const std::string& vehID, const libsumo::TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
1330  tcpip::Storage content;
1331  StoHelp::writeCompound(content, alphaMax > 0 ? 5 : 2);
1333  content.writeUnsignedByte(col.r);
1334  content.writeUnsignedByte(col.g);
1335  content.writeUnsignedByte(col.b);
1336  content.writeUnsignedByte(col.a);
1337  StoHelp::writeTypedDouble(content, size);
1338  if (alphaMax > 0) {
1340  content.writeUnsignedByte(alphaMax);
1341  StoHelp::writeTypedDouble(content, duration);
1343  content.writeUnsignedByte(type);
1344  }
1345  Dom::set(libsumo::VAR_HIGHLIGHT, vehID, &content);
1346 }
1347 
1348 void
1349 Vehicle::dispatchTaxi(const std::string& vehID, const std::vector<std::string>& reservations) {
1350  Dom::setStringVector(libsumo::CMD_TAXI_DISPATCH, vehID, reservations);
1351 }
1352 
1353 
1354 void
1355 Vehicle::subscribeLeader(const std::string& vehID, double dist, double begin, double end) {
1356  subscribe(vehID, std::vector<int>({ libsumo::VAR_LEADER }), begin, end,
1357  libsumo::TraCIResults({ {libsumo::VAR_LEADER, std::make_shared<libsumo::TraCIDouble>(dist)} }));
1358 }
1359 
1360 
1361 void
1362 Vehicle::addSubscriptionFilterLanes(const std::vector<int>& lanes, bool noOpposite, double downstreamDist, double upstreamDist) {
1363  tcpip::Storage content;
1364  content.writeUnsignedByte((int)lanes.size());
1365  for (int lane : lanes) {
1366  content.writeUnsignedByte(lane < 0 ? lane + 256 : lane);
1367  }
1369  if (noOpposite) {
1370  addSubscriptionFilterNoOpposite();
1371  }
1372  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1373  addSubscriptionFilterDownstreamDistance(downstreamDist);
1374  }
1375  if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1376  addSubscriptionFilterUpstreamDistance(upstreamDist);
1377  }
1378 }
1379 
1380 
1381 void
1382 Vehicle::addSubscriptionFilterNoOpposite() {
1384 }
1385 
1386 
1387 void
1388 Vehicle::addSubscriptionFilterDownstreamDistance(double dist) {
1389  tcpip::Storage content;
1390  StoHelp::writeTypedDouble(content, dist);
1392 }
1393 
1394 
1395 void
1396 Vehicle::addSubscriptionFilterUpstreamDistance(double dist) {
1397  tcpip::Storage content;
1398  StoHelp::writeTypedDouble(content, dist);
1400 }
1401 
1402 
1403 void
1404 Vehicle::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) {
1405  addSubscriptionFilterLeadFollow(std::vector<int>(1));
1406  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1407  addSubscriptionFilterDownstreamDistance(downstreamDist);
1408  }
1409  if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1410  addSubscriptionFilterUpstreamDistance(upstreamDist);
1411  }
1412 }
1413 
1414 
1415 void
1416 Vehicle::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) {
1417  if (direction == libsumo::INVALID_INT_VALUE) {
1418  addSubscriptionFilterLeadFollow({ -1, 0, 1 });
1419  } else if (direction != -1 && direction != 1) {
1420  // warnings.warn("Ignoring lane change subscription filter with non-neighboring lane offset direction=%s." % direction)
1421  return;
1422  } else {
1423  addSubscriptionFilterLeadFollow({ 0, direction });
1424  }
1425  if (noOpposite) {
1426  addSubscriptionFilterNoOpposite();
1427  }
1428  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1429  addSubscriptionFilterDownstreamDistance(downstreamDist);
1430  }
1431  if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1432  addSubscriptionFilterUpstreamDistance(upstreamDist);
1433  }
1434 }
1435 
1436 
1437 void
1438 Vehicle::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) {
1440  addSubscriptionFilterLanes(lanes);
1441 }
1442 
1443 
1444 void
1445 Vehicle::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) {
1446  tcpip::Storage content;
1447  StoHelp::writeTypedDouble(content, foeDistToJunction);
1449  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1450  addSubscriptionFilterDownstreamDistance(downstreamDist);
1451  }
1452 }
1453 
1454 
1455 void
1456 Vehicle::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) {
1457  tcpip::Storage content;
1458  StoHelp::writeTypedStringList(content, vClasses);
1460 }
1461 
1462 
1463 void
1464 Vehicle::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) {
1465  tcpip::Storage content;
1466  StoHelp::writeTypedStringList(content, vTypes);
1468 }
1469 
1470 
1471 void
1472 Vehicle::addSubscriptionFilterFieldOfVision(double openingAngle) {
1473  tcpip::Storage content;
1474  StoHelp::writeTypedDouble(content, openingAngle);
1476 }
1477 
1478 
1479 void
1480 Vehicle::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) {
1481  tcpip::Storage content;
1482  StoHelp::writeTypedDouble(content, lateralDist);
1484  if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1485  addSubscriptionFilterDownstreamDistance(downstreamDist);
1486  }
1487  if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
1488  addSubscriptionFilterUpstreamDistance(upstreamDist);
1489  }
1490 }
1491 
1492 
1493 }
1494 
1495 
1496 /****************************************************************************/
#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_SEGMENT_ID
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_MASS
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 VAR_SEGMENT_INDEX
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