Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JuPedSim] Speed adjustment #14269

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/microsim/transportables/MSPModel_JuPedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,21 @@ 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.
Position newPosition(position.x, position.y);
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<double>::max();
const double bestDistance = std::numeric_limits<double>::max();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bcoueraud87 this should not be const

MSLane* candidateLane = nullptr;
double candidateLaneLongitudinalPosition = 0.0;
int routeOffset = 0;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Warning: Polygon for junction 'J1' has been dilated as it is just a segment.
2,579 changes: 2,579 additions & 0 deletions tests/sumo/pedestrian_model/jupedsim/speed_change/fcd.sumo

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- generated on 2022-09-07 15:44:19 by Eclipse SUMO netedit Version v1_14_1+0668-9e54f98b5d2
-->

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
<!-- Routes -->
<route id="r_0" edges="E0 E1"/>
<!-- Vehicles, persons and containers (sorted by depart) -->
<person id="p_0" depart="0.00" color="red">
<walk route="r_0" arrivalPos="-0.10"/>
</person>
</routes>
51 changes: 51 additions & 0 deletions tests/sumo/pedestrian_model/jupedsim/speed_change/net.net.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- generated on 2024-01-26 15:08:31 by Eclipse SUMO netedit Version v1_19_0+0701-cce4e253116
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/neteditConfiguration.xsd">

<input>
<sumo-net-file value="C:\Users\coue_be\Dev\sumo\tests\sumo\pedestrian_model\jupedsim\speed_change\net.net.xml"/>
</input>

<output>
<output-file value="C:\Users\coue_be\Dev\sumo\tests\sumo\pedestrian_model\jupedsim\speed_change\net.net.xml"/>
</output>

<processing>
<geometry.min-radius.fix.railways value="false"/>
<geometry.max-grade.fix value="false"/>
<offset.disable-normalization value="true"/>
<lefthand value="0"/>
</processing>

<junctions>
<no-internal-links value="true"/>
<no-turnarounds value="true"/>
<junctions.corner-detail value="5"/>
<junctions.limit-turn-speed value="5.50"/>
<rectangular-lane-cut value="0"/>
</junctions>

<pedestrian>
<walkingareas value="0"/>
</pedestrian>

</configuration>
-->

<net version="1.16" junctionCornerDetail="5" limitTurnSpeed="5.50" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/net_file.xsd">

<location netOffset="0.00,0.00" convBoundary="0.00,0.00,200.00,0.00" origBoundary="-10000000000.00,-10000000000.00,10000000000.00,10000000000.00" projParameter="!"/>

<edge id="E0" from="J0" to="J1" priority="-1">
<lane id="E0_0" index="0" allow="pedestrian" speed="13.89" length="100.00" shape="0.00,-1.60 100.00,-1.60"/>
</edge>
<edge id="E1" from="J1" to="J2" priority="-1">
<lane id="E1_0" index="0" allow="pedestrian" speed="0.50" length="100.00" shape="100.00,-1.60 200.00,-1.60"/>
</edge>

<junction id="J0" type="dead_end" x="0.00" y="0.00" incLanes="" intLanes="" shape="0.00,0.00 0.00,-3.20"/>
<junction id="J1" type="dead_end" x="100.00" y="0.00" incLanes="E0_0" intLanes="" shape="100.00,0.00 100.00,-3.20 100.00,0.00"/>
<junction id="J2" type="dead_end" x="200.00" y="0.00" incLanes="E1_0" intLanes="" shape="200.00,-3.20 200.00,0.00"/>

</net>
Original file line number Diff line number Diff line change
@@ -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
Empty file.
48 changes: 48 additions & 0 deletions tests/sumo/pedestrian_model/jupedsim/speed_change/tripinfos.sumo
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- generated on 2024-01-26 15:08:54 by Eclipse SUMO sumo Version v1_19_0+0701-cce4e253116
This data file and the accompanying materials
are made available under the terms of the Eclipse Public License v2.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v20.html
This file may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License 2.0 are satisfied: GNU General Public License, version 2
or later which is available at
https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">

<input>
<net-file value="net.net.xml"/>
<route-files value="input_routes.rou.xml"/>
</input>

<output>
<write-license value="true"/>
<fcd-output value="fcd.xml"/>
<tripinfo-output value="tripinfos.xml"/>
</output>

<time>
<end value="2000"/>
</time>

<processing>
<default.speeddev value="0"/>
<pedestrian.model value="jupedsim"/>
</processing>

<report>
<xml-validation value="never"/>
<no-step-log value="true"/>
</report>

</configuration>
-->

<tripinfos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/tripinfo_file.xsd">
<personinfo id="p_0" depart="0.00" type="DEFAULT_PEDTYPE" speedFactor="1.00">
<walk depart="0.00" departPos="0.00" arrival="267.00" arrivalPos="99.90" duration="267.00" routeLength="199.90" timeLoss="123.07" maxSpeed="1.39"/>
</personinfo>
</tripinfos>
3 changes: 3 additions & 0 deletions tests/sumo/pedestrian_model/jupedsim/testsuite.sumo
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading