82 #pragma warning(disable: 4355) 86 MSVehicle(pars, route, type, speedFactor),
108 ret->
mkItem(
"shadow lane [id]",
false, shadowLane == 0 ?
"" : shadowLane->
getID());
112 ret->
mkItem(
"target lane [id]",
false, targetLane == 0 ?
"" : targetLane->
getID());
114 ret->
mkItem(
"position [m]",
true,
116 ret->
mkItem(
"lateral offset [m]",
true,
118 ret->
mkItem(
"speed [m/s]",
true,
120 ret->
mkItem(
"lateral speed [m/s]",
true,
122 ret->
mkItem(
"acceleration [m/s^2]",
true,
124 ret->
mkItem(
"angle [degree]",
true,
126 ret->
mkItem(
"slope [degree]",
true,
129 ret->
mkItem(
"time gap on lane [s]",
true,
131 ret->
mkItem(
"waiting time [s]",
true,
135 ret->
mkItem(
"time loss [s]",
true,
137 ret->
mkItem(
"impatience",
true,
139 ret->
mkItem(
"last lane change [s]",
true,
143 if (
getParameter().repetitionNumber < std::numeric_limits<int>::max()) {
154 ret->
mkItem(
"CO2 [mg/s]",
true,
156 ret->
mkItem(
"CO [mg/s]",
true,
158 ret->
mkItem(
"HC [mg/s]",
true,
160 ret->
mkItem(
"NOx [mg/s]",
true,
162 ret->
mkItem(
"PMx [mg/s]",
true,
164 ret->
mkItem(
"fuel [ml/s]",
true,
166 ret->
mkItem(
"electricity [Wh/s]",
true,
168 ret->
mkItem(
"noise (Harmonoise) [dB]",
true,
170 std::ostringstream str;
171 for (std::vector<MSDevice*>::const_iterator i =
myDevices.begin(); i !=
myDevices.end(); ++i) {
175 str << (*i)->getID().substr(0, (*i)->getID().find(
getID()));
177 ret->
mkItem(
"devices",
false, str.str());
178 ret->
mkItem(
"persons",
true,
180 ret->
mkItem(
"containers",
true,
201 ret->
mkItem(
"Type Information:",
false,
"");
240 for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
249 int containerIndex = 0;
250 for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
252 assert(container != 0);
257 #ifdef DRAW_BOUNDING_BOX 262 boundingBox.push_back(boundingBox.front());
266 glColor3d(0.5, .8, 0);
277 glTranslated(0, 0,
getType() + .2);
279 if ((*i).myLink == 0) {
282 MSLink* link = (*i).myLink;
286 if ((*i).mySetRequest) {
291 const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
301 glTranslated(0, 0,
getType() - .2);
329 #define BLINKER_POS_FRONT .5 330 #define BLINKER_POS_BACK .5 334 glColor3d(1.f, .8f, 0);
370 glColor3f(1.f, .2f, 0);
373 glTranslated(0, length, -0.1);
390 glTranslated(0, 2.5, .5);
400 switch (activeScheme) {
464 std::vector<std::vector<MSVehicle::LaneQ> > bestLanes =
myBestLanes;
466 for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
467 std::vector<MSVehicle::LaneQ>& lanes = *j;
470 for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
471 gmax =
MAX2((*i).length, gmax);
472 rmax =
MAX2((*i).occupation, rmax);
474 for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
476 double g = (*i).
length / gmax;
477 double r = (*i).occupation / rmax;
479 double width = 0.5 / (1 + abs((*i).bestLaneOffset));
502 int bestLaneIndex = (&r ==
myRoute ? 0 : (int)bestLaneConts.
size());
503 for (; i != r.
end(); ++i) {
505 if (bestLaneIndex < (
int)bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
506 lane =
static_cast<GUILane*
>(bestLaneConts[bestLaneIndex]);
509 const std::vector<MSLane*>* allowed = (*i)->allowedLanes(
getVClass());
510 if (allowed != 0 && allowed->size() != 0) {
511 lane =
static_cast<GUILane*
>((*allowed)[0]);
513 lane =
static_cast<GUILane*
>((*i)->getLanes()[0]);
520 Position pos = stop.lane->geometryPositionAtOffset(stop.getEndPos(*
this));
522 std::string label =
"stop " +
toString(stopIndex);
523 if (stop.pars.until >= 0) {
526 if (stop.duration >= 0) {
527 label +=
" duration:" +
time2string(stop.duration);
551 defaultLength *= exaggeration;
552 if (exaggeration == 0) {
555 carriageGap *= exaggeration;
561 const double xCornerCut = 0.3 * exaggeration;
562 const double yCornerCut = 0.4 * exaggeration;
564 const int numCarriages = (int)(length / (defaultLength + carriageGap) + 0.5);
565 assert(numCarriages > 0);
566 const double carriageLengthWithGap = length / numCarriages;
567 const double carriageLength = carriageLengthWithGap - carriageGap;
570 int furtherIndex = 0;
573 int backFurtherIndex = furtherIndex;
576 double carriageBackOffset =
myState.
pos() - carriageLength;
579 if (requiredSeats > 0) {
585 for (
int i = 0; i < numCarriages; ++i) {
586 while (carriageOffset < 0) {
596 while (carriageBackOffset < 0) {
598 if (prev != backLane) {
602 carriageBackOffset = 0;
612 const double drawnCarriageLength = front.
distanceTo2D(back);
613 angle = atan2((front.
x() - back.
x()), (back.
y() - front.
y())) * (double) 180.0 / (
double)
M_PI;
614 if (i >= firstPassengerCarriage) {
618 glTranslated(front.
x(), front.
y(),
getType());
619 glRotated(angle, 0, 0, 1);
621 glBegin(GL_TRIANGLE_FAN);
622 glVertex2d(-halfWidth + xCornerCut, 0);
623 glVertex2d(-halfWidth, yCornerCut);
624 glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
625 glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
626 glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
627 glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
628 glVertex2d(halfWidth, yCornerCut);
629 glVertex2d(halfWidth - xCornerCut, 0);
633 carriageOffset -= carriageLengthWithGap;
634 carriageBackOffset -= carriageLengthWithGap;
639 glTranslated(front.
x(), front.
y(),
getType());
640 glRotated(angle, 0, 0, 1);
648 glTranslated(front.
x(), front.
y(),
getType());
649 glRotated(angle, 0, 0, 1);
651 glScaled(upscale, upscale, 1);
667 if (requiredSeats <= 0) {
676 for (
double p = 2; p <= length - 1; p += 1) {
692 std::string result =
"";
698 return "next: " +
myStops.front().getDescription();
702 if (
myStops.front().pars.triggered) {
703 result +=
", triggered";
704 }
else if (
myStops.front().pars.containerTriggered) {
705 result +=
", containerTriggered";
706 }
else if (
myStops.front().collision) {
707 result +=
", collision";
723 std::vector<const SUMOVehicle*> blockingFoes;
724 std::vector<const MSPerson*> blockingPersons;
733 for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
734 std::cout <<
" " << (*it)->getID() <<
"\n";
740 if (parallelLink != 0) {
744 const bool isShadowOpen =
753 for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
754 std::cout <<
" " << (*it)->getID() <<
"\n";
760 for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
764 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
775 for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
815 for (
int i = 0; i < (int)sublaneSides.size(); ++i) {
816 if (sublaneSides[i] > rightSide) {
817 return MAX2(i - 1, 0);
827 for (
int i = (
int)sublaneSides.size() - 1; i >= 0; --i) {
828 if (sublaneSides[i] < leftSide) {
SUMOTime getBoardingDuration() const
Get this vehicle type's boarding duration.
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
bool signalSet(int which) const
Returns whether the given signal is on.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
const std::vector< double > & getShapeRotations() const
Drive process items represent bounds on the safe velocity corresponding to the upcoming links...
double getMinGap() const
Get the free space in front of vehicles of this class.
static double gLateralResolution
void selectBlockingFoes() const
adds the blocking foes to the current selection
static StringBijection< SumoXMLTag > CarFollowModels
car following models
SumoXMLTag
Numbers representing SUMO-XML - element names.
MSEdge & getEdge() const
Returns the lane's edge.
bool drawAction_drawCarriageClass(const GUIVisualizationSettings &s, SUMOVehicleShape guiShape, bool asImage) const
draws the given guiShape if it has distinct carriages/modules and returns true if so ...
double getWidth() const
Returns the lane's width.
Representation of a vehicle in the micro simulation.
double scale
information about a lane's width (temporary, used for a single view)
bool isLeader(const MSVehicle *ego, const MSVehicle *foe) const
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, double length=-1) const
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double getMaxSpeed() const
Returns the maximum speed.
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
int getRightSublaneOnEdge() const
return the righmost sublane on the edge occupied by the vehicle
std::vector< std::vector< LaneQ > > myBestLanes
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
double getTimeLossSeconds() const
Returns the time loss in seconds.
State myState
This Vehicles driving state (pos and speed)
DriveItemVector myLFLinkLanes
SUMOTime getLoadingDuration() const
Get this vehicle type's loading duration.
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
MSLane * getTargetLane() const
Returns the lane the vehicle has committed to enter during a sublane lane change. ...
double getManeuverDist() const
return the lane-change maneuver distance
void drawBestLanes() const
Draws the vehicle's best lanes.
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
double x() const
Returns the x-position.
Stores the information about how to visualize structures.
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
render as a flexible city bus
double getNaviDegree() const
return the current angle in navigational degrees
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
int getShadowDirection() const
return the direction in which the current shadow lane lies
std::string time2string(SUMOTime t)
GUIVisualizationTextSettings vehicleName
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r) const
Draws the route.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
double getCO2Emissions() const
Returns CO2 emission of the current state.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, int align=0, double width=-1)
double getRightSideOnEdge2() const
return right vehicle side on current edge (without argument)
double getLength() const
Returns the lane's length.
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model) ...
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
void drawOutsideNetwork(bool add)
register vehicle for drawing while outside the network
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
const MSRoute * myRoute
This vehicle's route.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
bool isSelected() const
whether this vehicle is selected in the GUI
double getHCEmissions() const
Returns HC emission of the current state.
double getPositionOnLane() const
Get the vehicle's position along the lane.
bool addAdditionalGLVisualisation(const GUIGlObject *const which)
Adds an object to call its additional visualisation method.
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
LateralAlignment getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment.
The base class for microscopic and mesoscopic vehicles.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
bool isActionStep(SUMOTime t) const
Returns whether the next simulation step will be an action point for the vehicle. ...
GUIGlID getGlID() const
Returns the numerical id of the object.
#define UNUSED_PARAMETER(x)
bool removeAdditionalGLVisualisation(const GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
The car-following model and parameter.
MSAbstractLaneChangeModel & getLaneChangeModel()
int getPersonCapacity() const
Get this vehicle type's person capacity.
std::string getStopInfo() const
retrieve information about the current stop state
Right blinker lights are switched on.
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
double getSlope() const
Returns the slope of the road at vehicle's position.
const std::vector< double > & getShapeLengths() const
Representation of a lane in the micro simulation (gui-version)
const std::vector< double > getSubLaneSides() const
Returns the right side offsets of this edge's sublanes.
double getImpatience() const
Returns this vehicles impatience.
int getContainerNumber() const
Returns the number of containers.
const std::string & getID() const
Returns the id.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
double getElectricityConsumption() const
Returns electricity consumption of the current state.
double getLeaveSpeed() const
Left blinker lights are switched on.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
GUISUMOAbstractView * getActiveView() const
get the active view or 0
const SUMOVTypeParameter & getParameter() const
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, std::vector< const SUMOVehicle * > *collectFoes=0, bool ignoreRed=false, const SUMOVehicle *ego=0) const
Returns the information whether the link may be passed.
PositionVector getBoundingBox() const
get bounding rectangle
double getColorValue(int activeScheme) const
gets the color value according to the current scheme index
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
static GUIMainWindow * getInstance()
SUMOTime getDepartDelay() const
Returns the depart delay.
A point in 2D or 3D with translation and scaling methods.
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, MSVehicleType *type, const double speedFactor)
Constructor.
int size() const
Returns the number of edges to pass.
std::list< Stop > myStops
The vehicle's list of stops.
ConstMSEdgeVector::const_iterator MSRouteIterator
double y() const
Returns the y-position.
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
PositionVector getBoundingPoly() const
get bounding polygon
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
bool isStopped() const
Returns whether the vehicle is at a stop.
MSLane * myLane
The lane the vehicle is on.
Blinker lights on both sides are switched on.
void drawAction_drawRailCarriages(const GUIVisualizationSettings &s, double defaultLength, double carriageGap, int firstPassengerCarriage, bool asImage) const
double length() const
Returns the length.
double getPMxEmissions() const
Returns PMx emission of the current state.
void setPositionInVehicle(const Position &pos)
render as a (city) rail without locomotive
double getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
std::vector< LinkLeader > LinkLeaders
A MSVehicle extended by some values for usage within the gui.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
A blue emergency light is on.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
int getNumPassengers() const
return the number of passengers
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
void drawAction_drawVehicleBlinker(double length) const
bool isParking() const
Returns whether the vehicle is parking.
void move2side(double amount)
move position vector to side using certain ammount
int getPersonNumber() const
Returns the number of persons.
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
double getNOxEmissions() const
Returns NOx emission of the current state.
std::string line
The vehicle's line (mainly for public transport)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
void setPositionInVehicle(const Position &pos)
void computeSeats(const Position &front, const Position &back, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
void unlock()
release mutex lock
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getLength() const
Get vehicle's length [m].
Structure representing possible vehicle parameter.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
draw vehicle outside the road network
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
int getLeftSublaneOnEdge() const
MSVehicleType * myType
This vehicle's type.
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
void drawAction_drawLinkItems(const GUIVisualizationSettings &s) const
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
double getLeftSideOnEdge() const
return left vehicle side on current edge
const std::string & getID() const
Returns the name of the vehicle type.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
static SUMOTime gWaitingTimeMemory
length of memory for waiting times (in millisecs)
double pos() const
Position of this state.
const PositionVector & getShape() const
Returns this lane's shape.
#define BLINKER_POS_FRONT
double getFuelConsumption() const
Returns fuel consumption of the current state.
double getCOEmissions() const
Returns CO emission of the current state.
double getRightSideOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0) ...
GUIVisualizationSizeSettings vehicleSize
void drawAction_drawBlinker(double dir, double length)
int getContainerCapacity() const
Get this vehicle type's container capacity.
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
MSLane * getLane() const
Returns the lane the vehicle is on.
static SUMOTime gLaneChangeDuration
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
GUISelectedStorage gSelected
A global holder of selected objects.
Representation of a lane in the micro simulation.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
std::vector< MSDevice * > myDevices
The devices this vehicle has.
A window containing a gl-object's parameter.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void drawAction_drawVehicleBlueLight() const
int getBestLaneOffset() const
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
double getWidth() const
Returns the vehicle's width.
Definition of vehicle stop (position and duration)
const std::string & getID() const
Returns the name of the vehicle.
int size() const
Return the number of passengers / containers.
const PositionVector & getShape() const
double getSpeed() const
Returns the vehicle's current speed.
static RGBColor getColor()
gets the gl-color
A MSVehicle extended by some values for usage within the gui.