Skip to content

Commit

Permalink
[JuPedSim] Corrected errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoueraud87 authored and behrisch committed Mar 22, 2024
1 parent e18378f commit 069bb58
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/microsim/MSTrainHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ MSTrainHelper::computeDoorPositions() {


void
MSTrainHelper::computeUnboardingPositions(double passengerRadius, std::list<Position>& unboardingPositions) {
MSTrainHelper::computeUnboardingPositions(double passengerRadius, std::vector<Position>& unboardingPositions) {
passengerRadius += PEDESTRIAN_RADIUS_EXTRA_TOLERANCE;
for (Carriage* carriage : myCarriages) {
Position dir = carriage->front - carriage->back;
Expand All @@ -181,10 +181,10 @@ MSTrainHelper::computeUnboardingPositions(double passengerRadius, std::list<Posi
}
}
}
// Shuffle the positions upstream so that we won't have to sample later on, just pop the last element.
RandHelper::shuffle(carriage->unboardingPositions);
std::copy(carriage->unboardingPositions.begin(), carriage->unboardingPositions.end(), std::back_inserter(unboardingPositions));
}
// Shuffle the positions upstream so that we don't have to sample later on, just pop the last element.
RandHelper::shuffle(unboardingPositions);
}


Expand Down
2 changes: 1 addition & 1 deletion src/microsim/MSTrainHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MSTrainHelper {

/// @brief compute unboarding positions on demand and fills the carriage structures
/// @remark need to be called before retrieving carriages if unboarding positions needed
void computeUnboardingPositions(double passengerRadius, std::list<Position>& unboardingPositions);
void computeUnboardingPositions(double passengerRadius, std::vector<Position>& unboardingPositions);

/// @brief return length exaggeration factor (special for long vehicles)
static double getUpscaleLength(double upscale, double length, int vehicleQuality);
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/MSVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ MSVehicle::MSVehicle(SUMOVehicleParameter* pars, ConstMSRoutePtr route,
myJunctionConflictEntryTime(SUMOTime_MAX),
myTimeSinceStartup(TIME2STEPS(3600 * 24)),
myInfluencer(nullptr),
myUnboardingPositions(new std::list<Position>()) {
myUnboardingPositions(new std::vector<Position>()) {
myCFVariables = type->getCarFollowModel().createVehicleVariables();
myNextDriveItem = myLFLinkLanes.begin();
}
Expand Down
4 changes: 2 additions & 2 deletions src/microsim/transportables/MSPModel_JuPedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const int MSPModel_JuPedSim::GEOS_QUADRANT_SEGMENTS = 16;
const double MSPModel_JuPedSim::GEOS_MITRE_LIMIT = 5.0;
const double MSPModel_JuPedSim::GEOS_MIN_AREA = 0.01;
const double MSPModel_JuPedSim::GEOS_BUFFERED_SEGMENT_WIDTH = 0.5 * SUMO_const_laneWidth;
const double MSPModel_JuPedSim::CARRIAGE_RAMP_WIDTH = 2.0;
const double MSPModel_JuPedSim::CARRIAGE_RAMP_LENGTH = 2.0;
const RGBColor MSPModel_JuPedSim::PEDESTRIAN_NETWORK_COLOR = RGBColor(179, 217, 255, 255);
const RGBColor MSPModel_JuPedSim::PEDESTRIAN_NETWORK_CARRIAGES_AND_RAMPS_COLOR = RGBColor(255, 217, 179, 255);
const std::string MSPModel_JuPedSim::PEDESTRIAN_NETWORK_ID = "jupedsim.pedestrian_network";
Expand Down Expand Up @@ -439,7 +439,7 @@ MSPModel_JuPedSim::execute(SUMOTime time) {
carriageShape.push_back(carriage->front - perp * p);
carriagePolygons.push_back(createGeometryFromShape(carriageShape, train->getID(), false));
// Create ramps geometry.
p += CARRIAGE_RAMP_WIDTH;
p += CARRIAGE_RAMP_LENGTH;
const double d = 0.5 * MSTrainHelper::CARRIAGE_DOOR_WIDTH;
for (const Position& door : carriage->doorPositions) {
PositionVector rampShape;
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/transportables/MSPModel_JuPedSim.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class MSPModel_JuPedSim : public MSPModel {
static const double GEOS_MITRE_LIMIT;
static const double GEOS_MIN_AREA;
static const double GEOS_BUFFERED_SEGMENT_WIDTH;
static const double CARRIAGE_RAMP_WIDTH;
static const double CARRIAGE_RAMP_LENGTH;
static const RGBColor PEDESTRIAN_NETWORK_COLOR;
static const RGBColor PEDESTRIAN_NETWORK_CARRIAGES_AND_RAMPS_COLOR;
static const std::string PEDESTRIAN_NETWORK_ID;
Expand Down
16 changes: 7 additions & 9 deletions src/microsim/transportables/MSStageDriving.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,20 +486,18 @@ MSStageDriving::setArrived(MSNet* net, MSTransportable* transportable, SUMOTime
myArrivalPos = MIN2(MAX2(0., myArrivalPos), myVehicle->getEdge()->getLength());
}
else {
std::list<Position>& unboardingPositions = train->getUnboardingPositions();
std::vector<Position>& unboardingPositions = train->getUnboardingPositions();
if (unboardingPositions.empty()) {
const MSVehicleType* defaultPedestrianType = MSNet::getInstance()->getVehicleControl().getVType(DEFAULT_PEDTYPE_ID, nullptr, true);
const double defaultPassengerRadius = MAX2(defaultPedestrianType->getLength(), defaultPedestrianType->getWidth()) / 2.;
trainHelper.computeUnboardingPositions(defaultPassengerRadius, unboardingPositions);
}
else {
// Random shuffling of the positions has already been done in the train helper.
const Position availableUnboardingPosition = unboardingPositions.back();
unboardingPositions.pop_back();
const Position arrivalPos = myLane->getShape().transformToVectorCoordinates(availableUnboardingPosition);
myArrivalPos = arrivalPos.x();
myArrivalPosLat = arrivalPos.y();
}
// Random shuffling of the positions has already been done in the train helper.
const Position availableUnboardingPosition = unboardingPositions.back();
unboardingPositions.pop_back();
const Position arrivalPos = myLane->getShape().transformToVectorCoordinates(availableUnboardingPosition);
myArrivalPos = arrivalPos.x();
myArrivalPosLat = arrivalPos.y();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/common/RandHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class RandHelper {
}

template<class T>
static void shuffle(const std::vector<T>& v) {
static void shuffle(std::vector<T>& v) {
std::shuffle(v.begin(), v.end(), myRandomNumberGenerator);
}

Expand Down

0 comments on commit 069bb58

Please sign in to comment.