From 260ac9c7e2759bc376b02269b87776d26067d69a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cou=C3=A9raud?= Date: Fri, 26 Jan 2024 15:41:42 +0100 Subject: [PATCH 1/4] [JuPedSim] A pedestrian's speed is possibly adjusted from its lane's speed. --- src/microsim/transportables/MSPModel_JuPedSim.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/microsim/transportables/MSPModel_JuPedSim.cpp b/src/microsim/transportables/MSPModel_JuPedSim.cpp index b32a19643097..0250ed8fe85b 100644 --- a/src/microsim/transportables/MSPModel_JuPedSim.cpp +++ b/src/microsim/transportables/MSPModel_JuPedSim.cpp @@ -323,6 +323,11 @@ MSPModel_JuPedSim::execute(SUMOTime time) { UNUSED_PARAMETER(result); assert(result == false); // The person has not arrived yet. stage->activateEntryReminders(person); + JPS_CollisionFreeSpeedModelState modelState = JPS_Agent_GetCollisionFreeSpeedModelState(agent, nullptr); + const double newMaxSpeed = MIN2(candidateLane->getSpeedLimit(), person->getMaxSpeed()); + if (newMaxSpeed != JPS_CollisionFreeSpeedModelState_GetV0(modelState)) { + JPS_CollisionFreeSpeedModelState_SetV0(modelState, newMaxSpeed); + } } if (newPosition.distanceTo2D(state->getNextWaypoint()) < 2 * myExitTolerance) { From 957d247f94f3c041991b0fb5973e7fdb4428ce09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cou=C3=A9raud?= Date: Fri, 26 Jan 2024 15:43:33 +0100 Subject: [PATCH 2/4] [JuPedSim] Added test for pedestrian speed adjustment. --- .../jupedsim/speed_change/errors.sumo | 1 + .../jupedsim/speed_change/fcd.sumo | 2579 +++++++++++++++++ .../speed_change/input_routes.rou.xml | 13 + .../jupedsim/speed_change/net.net.xml | 51 + .../jupedsim/speed_change/options.sumo | 1 + .../jupedsim/speed_change/output.sumo | 0 .../jupedsim/speed_change/tripinfos.sumo | 48 + .../pedestrian_model/jupedsim/testsuite.sumo | 3 + 8 files changed, 2696 insertions(+) create mode 100644 tests/sumo/pedestrian_model/jupedsim/speed_change/errors.sumo create mode 100644 tests/sumo/pedestrian_model/jupedsim/speed_change/fcd.sumo create mode 100644 tests/sumo/pedestrian_model/jupedsim/speed_change/input_routes.rou.xml create mode 100644 tests/sumo/pedestrian_model/jupedsim/speed_change/net.net.xml create mode 100644 tests/sumo/pedestrian_model/jupedsim/speed_change/options.sumo create mode 100644 tests/sumo/pedestrian_model/jupedsim/speed_change/output.sumo create mode 100644 tests/sumo/pedestrian_model/jupedsim/speed_change/tripinfos.sumo diff --git a/tests/sumo/pedestrian_model/jupedsim/speed_change/errors.sumo b/tests/sumo/pedestrian_model/jupedsim/speed_change/errors.sumo new file mode 100644 index 000000000000..280b053e6399 --- /dev/null +++ b/tests/sumo/pedestrian_model/jupedsim/speed_change/errors.sumo @@ -0,0 +1 @@ +Warning: Polygon for junction 'J1' has been dilated as it is just a segment. diff --git a/tests/sumo/pedestrian_model/jupedsim/speed_change/fcd.sumo b/tests/sumo/pedestrian_model/jupedsim/speed_change/fcd.sumo new file mode 100644 index 000000000000..b486f7f7e9a7 --- /dev/null +++ b/tests/sumo/pedestrian_model/jupedsim/speed_change/fcd.sumo @@ -0,0 +1,2579 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/sumo/pedestrian_model/jupedsim/speed_change/input_routes.rou.xml b/tests/sumo/pedestrian_model/jupedsim/speed_change/input_routes.rou.xml new file mode 100644 index 000000000000..73e36d3b4480 --- /dev/null +++ b/tests/sumo/pedestrian_model/jupedsim/speed_change/input_routes.rou.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/tests/sumo/pedestrian_model/jupedsim/speed_change/net.net.xml b/tests/sumo/pedestrian_model/jupedsim/speed_change/net.net.xml new file mode 100644 index 000000000000..f6244adf4805 --- /dev/null +++ b/tests/sumo/pedestrian_model/jupedsim/speed_change/net.net.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/sumo/pedestrian_model/jupedsim/speed_change/options.sumo b/tests/sumo/pedestrian_model/jupedsim/speed_change/options.sumo new file mode 100644 index 000000000000..f90e1ad8036f --- /dev/null +++ b/tests/sumo/pedestrian_model/jupedsim/speed_change/options.sumo @@ -0,0 +1 @@ +--net-file net.net.xml --route-files input_routes.rou.xml --no-step-log --tripinfo-output tripinfos.xml --fcd-output fcd.xml diff --git a/tests/sumo/pedestrian_model/jupedsim/speed_change/output.sumo b/tests/sumo/pedestrian_model/jupedsim/speed_change/output.sumo new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/sumo/pedestrian_model/jupedsim/speed_change/tripinfos.sumo b/tests/sumo/pedestrian_model/jupedsim/speed_change/tripinfos.sumo new file mode 100644 index 000000000000..251011a12c9c --- /dev/null +++ b/tests/sumo/pedestrian_model/jupedsim/speed_change/tripinfos.sumo @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/tests/sumo/pedestrian_model/jupedsim/testsuite.sumo b/tests/sumo/pedestrian_model/jupedsim/testsuite.sumo index 73d544738a79..80d424ed837d 100644 --- a/tests/sumo/pedestrian_model/jupedsim/testsuite.sumo +++ b/tests/sumo/pedestrian_model/jupedsim/testsuite.sumo @@ -1,5 +1,8 @@ two_edges +# This test checks that when a pedestrian walks on a new edge, the max speed of the new edge is taken into account. +speed_change + # Test the geometry checks regarding non-simple polygons geometry_check From ef5c7bb3ce81d657a4a65349967320feadd4a36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cou=C3=A9raud?= Date: Fri, 26 Jan 2024 15:47:18 +0100 Subject: [PATCH 3/4] [JuPedSim] Minor style changes. --- src/microsim/transportables/MSPModel_JuPedSim.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/microsim/transportables/MSPModel_JuPedSim.cpp b/src/microsim/transportables/MSPModel_JuPedSim.cpp index 0250ed8fe85b..e47e51d9bdcb 100644 --- a/src/microsim/transportables/MSPModel_JuPedSim.cpp +++ b/src/microsim/transportables/MSPModel_JuPedSim.cpp @@ -292,13 +292,13 @@ MSPModel_JuPedSim::execute(SUMOTime time) { } // Updates the agent position. - auto agent = JPS_Simulation_GetAgent(myJPSSimulation, state->getAgentId(), nullptr); + const JPS_Agent agent = JPS_Simulation_GetAgent(myJPSSimulation, state->getAgentId(), nullptr); state->setPreviousPosition(state->getPosition(*stage, DELTA_T)); - const auto position = JPS_Agent_GetPosition(agent); + const JPS_Point position = JPS_Agent_GetPosition(agent); state->setPosition(position.x, position.y); // Updates the agent direction. - const auto orientation = JPS_Agent_GetOrientation(agent); + const JPS_Point orientation = JPS_Agent_GetOrientation(agent); state->setAngle(atan2(orientation.y, orientation.x)); // Find on which edge the pedestrian is, using route's forward-looking edges because of how moveToXY is written. @@ -306,7 +306,7 @@ MSPModel_JuPedSim::execute(SUMOTime time) { ConstMSEdgeVector route = stage->getEdges(); const int routeIndex = (int)(stage->getRouteStep() - stage->getRoute().begin()); ConstMSEdgeVector forwardRoute = ConstMSEdgeVector(route.begin() + routeIndex, route.end()); - double bestDistance = std::numeric_limits::max(); + const double bestDistance = std::numeric_limits::max(); MSLane* candidateLane = nullptr; double candidateLaneLongitudinalPosition = 0.0; int routeOffset = 0; From 807931593a9883f8e9f3af1d9c51a421beb74d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cou=C3=A9raud?= Date: Mon, 29 Jan 2024 11:52:10 +0100 Subject: [PATCH 4/4] Removed a const qualifier that I added. --- src/microsim/transportables/MSPModel_JuPedSim.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/microsim/transportables/MSPModel_JuPedSim.cpp b/src/microsim/transportables/MSPModel_JuPedSim.cpp index e47e51d9bdcb..593ca7f87fe4 100644 --- a/src/microsim/transportables/MSPModel_JuPedSim.cpp +++ b/src/microsim/transportables/MSPModel_JuPedSim.cpp @@ -306,7 +306,7 @@ MSPModel_JuPedSim::execute(SUMOTime time) { ConstMSEdgeVector route = stage->getEdges(); const int routeIndex = (int)(stage->getRouteStep() - stage->getRoute().begin()); ConstMSEdgeVector forwardRoute = ConstMSEdgeVector(route.begin() + routeIndex, route.end()); - const double bestDistance = std::numeric_limits::max(); + double bestDistance = std::numeric_limits::max(); MSLane* candidateLane = nullptr; double candidateLaneLongitudinalPosition = 0.0; int routeOffset = 0;