File |
Line |
org\opentrafficsim\road\gtu\lane\perception\categories\neighbors\AccPerception.java |
149 |
org\opentrafficsim\road\gtu\lane\perception\categories\neighbors\CaccPerception.java |
149 |
while (next != null && counter > 1 && !(next.getObject().getTacticalPlanner() instanceof CACC));
return next;
}
}
/**
* Default CACC sensors. This returns all information except desired speed for the first leader and CACC leaders. Remaining
* leaders are provided null information.
* <p>
* Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* <br>
* BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
* <p>
* @version $Revision$, $LastChangedDate$, by $Author$, initial version Mar 13, 2019 <br>
* @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
* @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
* @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
*/
private static class OnboardSensors implements HeadwayGtuType
{
/**
* Constructor.
*/
OnboardSensors()
{
//
}
/** {@inheritDoc} */
@Override
public HeadwayGTU createDownstreamGtu(final LaneBasedGTU perceivingGtu, final LaneBasedGTU perceivedGtu,
final Length distance) throws GTUException, ParameterException
{
Time t = perceivingGtu.getSimulator().getSimulatorTime().minus(perceivingGtu.getParameters().getParameter(DELAY));
String id = perceivedGtu.getId();
GTUType gtuType = perceivedGtu.getGTUType();
Length length = perceivedGtu.getLength();
Length width = perceivedGtu.getWidth();
Speed v = perceivedGtu.getSpeed(t);
Acceleration a = perceivedGtu.getAcceleration(t);
Speed desiredSpeed = null;
List<GTUStatus> status = new ArrayList<>();
if (perceivedGtu.isBrakingLightsOn(t))
{
status.add(GTUStatus.BRAKING_LIGHTS);
}
switch (perceivedGtu.getTurnIndicatorStatus(t))
{
case HAZARD:
status.add(GTUStatus.EMERGENCY_LIGHTS);
break;
case LEFT:
status.add(GTUStatus.LEFT_TURNINDICATOR);
break;
case RIGHT:
status.add(GTUStatus.RIGHT_TURNINDICATOR);
break;
default:
break;
}
return new HeadwayGTUSimple(id, gtuType, distance, length, width, v, a, desiredSpeed,
status.toArray(new GTUStatus[status.size()]));
}
/** {@inheritDoc} */
@Override
public HeadwayGTU createUpstreamGtu(final LaneBasedGTU perceivingGtu, final LaneBasedGTU perceivedGtu,
final Length distance) throws GTUException, ParameterException
{
throw new UnsupportedOperationException("Default CACC sensors can only determine leaders.");
}
/** {@inheritDoc} */
@Override
public HeadwayGTU createParallelGtu(final LaneBasedGTU perceivingGtu, final LaneBasedGTU perceivedGtu,
final Length overlapFront, final Length overlap, final Length overlapRear) throws GTUException
{
throw new UnsupportedOperationException("Default CACC sensors can only determine leaders.");
}
}
} |
File |
Line |
org\opentrafficsim\road\gtu\lane\tactical\following\IDMOld.java |
160 |
org\opentrafficsim\road\gtu\lane\tactical\following\IDMPlusOld.java |
177 |
}
/** {@inheritDoc} */
@Override
public final String getLongName()
{
return String.format("%s (a=%.1fm/s\u00b2, b=%.1fm/s\u00b2, s0=%.1fm, tSafe=%.1fs, delta=%.2f)", getName(),
this.a.getSI(), this.b.getSI(), this.s0.getSI(), this.tSafe.getSI(), this.delta);
}
/** {@inheritDoc} */
@Override
public final void setA(final Acceleration a)
{
this.a = a;
}
/** {@inheritDoc} */
@Override
public final void setT(final Duration t)
{
this.tSafe = t;
}
/** {@inheritDoc} */
@Override
public final void setFspeed(final double fSpeed)
{
this.delta = fSpeed;
}
// The following is inherited from CarFollowingModel
/** {@inheritDoc} */
@Override
public final Speed desiredSpeed(final Parameters parameters, final SpeedLimitInfo speedInfo) throws ParameterException
{
throw new UnsupportedOperationException("Old car-following model does not support desired speed.");
}
/** {@inheritDoc} */
@Override
public final Length desiredHeadway(final Parameters parameters, final Speed speed) throws ParameterException
{
throw new UnsupportedOperationException("Old car-following model does not support desired headway.");
}
/** {@inheritDoc} */
@Override
public final Acceleration followingAcceleration(final Parameters parameters, final Speed speed,
final SpeedLimitInfo speedInfo, final PerceptionIterable<? extends Headway> leaders) throws ParameterException
{
Length headway;
Speed leaderSpeed;
if (leaders.isEmpty())
{
headway = new Length(Double.MAX_VALUE, LengthUnit.SI);
leaderSpeed = speed;
}
else
{
Headway leader = leaders.first();
headway = leader.getDistance();
leaderSpeed = leader.getSpeed();
}
return this.computeAcceleration(speed, speedInfo.getSpeedInfo(SpeedLimitTypes.MAX_VEHICLE_SPEED), leaderSpeed, headway,
speedInfo.getSpeedInfo(SpeedLimitTypes.FIXED_SIGN));
}
/** {@inheritDoc} */
@Override
public final String toString()
{
return "IDMOld [s0=" + this.s0 + ", a=" + this.a + ", b=" + this.b + ", tSafe=" + this.tSafe + ", stepSize=" |
File |
Line |
org\opentrafficsim\road\gtu\lane\tactical\following\IDMOld.java |
80 |
org\opentrafficsim\road\gtu\lane\tactical\following\IDMPlusOld.java |
86 |
public IDMOld(final Acceleration a, final Acceleration b, final Length s0, final Duration tSafe, final double delta)
{
this.a = a;
this.b = b;
this.s0 = s0;
this.tSafe = tSafe;
this.delta = delta;
}
/**
* Desired speed (taking into account the urge to drive a little faster or slower than the posted speed limit).
* @param speedLimit Speed; the speed limit
* @param followerMaximumSpeed Speed; the maximum speed that the follower can drive
* @return DoubleScalarRel<SpeedUnit>; the desired speed
*/
private Speed vDes(final Speed speedLimit, final Speed followerMaximumSpeed)
{
return new Speed(Math.min(this.delta * speedLimit.getSI(), followerMaximumSpeed.getSI()), SpeedUnit.SI);
}
/** {@inheritDoc} */
@Override
public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
final Speed leaderSpeed, final Length headway, final Speed speedLimit)
{
return computeAcceleration(followerSpeed, followerMaximumSpeed, leaderSpeed, headway, speedLimit, DEFAULT_STEP_SIZE);
}
/** {@inheritDoc} */
@Override
public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
final Speed leaderSpeed, final Length headway, final Speed speedLimit, final Duration stepSize)
{ |
File |
Line |
org\opentrafficsim\road\network\lane\conflict\ConflictBuilder.java |
422 |
org\opentrafficsim\road\network\lane\conflict\ConflictBuilder.java |
535 |
Length longitudinalPosition2 = lane2.getLength().multiplyBy(f2start);
Length length1 = lane1.getLength().multiplyBy(Math.abs(f1end - f1start));
Length length2 = lane2.getLength().multiplyBy(Math.abs(f2end - f2start));
// Get geometries
OTSLine3D geometry1 = getGeometry(lane1, f1start, f1end, widthGenerator);
OTSLine3D geometry2 = getGeometry(lane2, f2start, f2end, widthGenerator);
// Determine conflict rule
ConflictRule conflictRule;
if (lane1.getParentLink().getPriority().isBusStop() || lane2.getParentLink().getPriority().isBusStop())
{
Throw.when(lane1.getParentLink().getPriority().isBusStop() && lane2.getParentLink().getPriority().isBusStop(),
IllegalArgumentException.class, "Merge conflict between two links with bus stop priority not supported.");
conflictRule = new BusStopConflictRule(simulator);
}
else
{
conflictRule = new DefaultConflictRule();
}
// Make conflict
Conflict.generateConflictPair(ConflictType.MERGE, conflictRule, permitted, lane1, longitudinalPosition1, length1, dir1, |
File |
Line |
org\opentrafficsim\road\gtu\lane\perception\categories\neighbors\AccPerception.java |
62 |
org\opentrafficsim\road\gtu\lane\perception\categories\neighbors\CaccPerception.java |
62 |
public AccPerception(final LanePerception perception, final HeadwayGtuType sensors)
{
super(perception);
this.sensors = sensors;
}
/** {@inheritDoc} */
@Override
public void updateAll() throws GTUException, NetworkException, ParameterException
{
// lazy evaluation
}
/** {@inheritDoc} */
@Override
public PerceptionCollectable<HeadwayGTU, LaneBasedGTU> getLeaders()
{
return computeIfAbsent("leaders", () -> computeLeaders());
}
/**
* Computes leaders.
* @return perception iterable for leaders
*/
private PerceptionCollectable<HeadwayGTU, LaneBasedGTU> computeLeaders()
{
try
{
LaneStructureRecord record = getPerception().getLaneStructure().getRootRecord();
Length pos = record.getStartDistance().neg();
pos = record.getDirection().isPlus() ? pos.plus(getGtu().getFront().getDx())
: pos.minus(getGtu().getFront().getDx());
boolean ignoreIfUpstream = true;
return new DownstreamNeighboursIterableACC(getGtu(), record, Length.max(Length.ZERO, pos), |
File |
Line |
org\opentrafficsim\road\gtu\lane\tactical\util\lmrs\Cooperation.java |
49 |
org\opentrafficsim\road\gtu\lane\tactical\util\lmrs\Cooperation.java |
129 |
Acceleration a = new Acceleration(Double.MAX_VALUE, AccelerationUnit.SI);
double dCoop = params.getParameter(DCOOP);
Speed ownSpeed = perception.getPerceptionCategory(EgoPerception.class).getSpeed();
RelativeLane relativeLane = new RelativeLane(lat, 1);
for (HeadwayGTU leader : Synchronization.removeAllUpstreamOfConflicts(Synchronization.removeAllUpstreamOfConflicts(
perception.getPerceptionCategory(NeighborsPerception.class).getLeaders(relativeLane), perception,
relativeLane), perception, RelativeLane.CURRENT))
{
Parameters params2 = leader.getParameters();
double desire = lat.equals(LateralDirectionality.LEFT) ? params2.getParameter(DRIGHT)
: lat.equals(LateralDirectionality.RIGHT) ? params2.getParameter(DLEFT) : 0;
if (desire >= dCoop && (leader.getSpeed().gt0() || leader.getDistance().gt0())) |
File |
Line |
org\opentrafficsim\road\network\factory\LaneFactory.java |
415 |
org\opentrafficsim\road\network\factory\LaneFactory.java |
484 |
final CrossSectionLink link = makeLink(network, name, from, to, intermediatePoints, simulator);
Lane[] result = new Lane[laneCount];
Length width = new Length(4.0, LengthUnit.METER);
for (int laneIndex = 0; laneIndex < laneCount; laneIndex++)
{
// Be ware! LEFT is lateral positive, RIGHT is lateral negative.
Length latPosAtStart = new Length((-0.5 - laneIndex - laneOffsetAtStart) * width.getSI(), LengthUnit.SI);
Length latPosAtEnd = new Length((-0.5 - laneIndex - laneOffsetAtEnd) * width.getSI(), LengthUnit.SI);
result[laneIndex] =
makeLane(link, "lane." + laneIndex, laneType, latPosAtStart, latPosAtEnd, width, speedLimit, simulator);
}
return result;
} |
File |
Line |
org\opentrafficsim\road\gtu\lane\tactical\following\FixedAccelerationModel.java |
119 |
org\opentrafficsim\road\gtu\lane\tactical\following\SequentialFixedAccelerationModel.java |
187 |
}
/** {@inheritDoc} */
@Override
public final void setA(final Acceleration a)
{
//
}
/** {@inheritDoc} */
@Override
public final void setT(final Duration t)
{
//
}
/** {@inheritDoc} */
@Override
public final void setFspeed(final double fSpeed)
{
//
}
// The following is inherited from CarFollowingModel
/** {@inheritDoc} */
@Override
public final Speed desiredSpeed(final Parameters parameters, final SpeedLimitInfo speedInfo) throws ParameterException
{
return null;
}
/** {@inheritDoc} */
@Override
public final Length desiredHeadway(final Parameters parameters, final Speed speed) throws ParameterException
{
return null;
}
/** {@inheritDoc} */
@Override
public final Acceleration followingAcceleration(final Parameters parameters, final Speed speed,
final SpeedLimitInfo speedInfo, final PerceptionIterable<? extends Headway> leaders) throws ParameterException
{
return null;
} |
File |
Line |
org\opentrafficsim\road\gtu\lane\tactical\LaneBasedGTUFollowingDirectedChangeTacticalPlanner.java |
294 |
org\opentrafficsim\road\gtu\lane\tactical\LaneBasedGTUFollowingDirectedChangeTacticalPlanner.java |
341 |
if (simplePerception.getParallelHeadwaysLeft().isEmpty())
{
Collection<Headway> sameLaneTraffic = new HashSet<>();
// TODO should it be getObjectType().isGtu() or !getObjectType().isDistanceOnly() ?
// XXX Object & GTU
if (simplePerception.getForwardHeadwayGTU() != null
&& simplePerception.getForwardHeadwayGTU().getObjectType().isGtu())
{
sameLaneTraffic.add(simplePerception.getForwardHeadwayGTU());
}
if (simplePerception.getBackwardHeadway() != null
&& simplePerception.getBackwardHeadway().getObjectType().isGtu())
{
sameLaneTraffic.add(simplePerception.getBackwardHeadway());
}
DirectedLaneChangeModel dlcm = new DirectedAltruistic(getPerception());
DirectedLaneMovementStep dlms = dlcm.computeLaneChangeAndAcceleration(laneBasedGTU,
LateralDirectionality.LEFT, sameLaneTraffic, simplePerception.getNeighboringHeadwaysLeft(), |
File |
Line |
org\opentrafficsim\road\gtu\lane\tactical\util\lmrs\Cooperation.java |
36 |
org\opentrafficsim\road\gtu\lane\tactical\util\lmrs\Cooperation.java |
72 |
org\opentrafficsim\road\gtu\lane\tactical\util\lmrs\Cooperation.java |
116 |
Cooperation PASSIVE = new Cooperation()
{
@Override
public Acceleration cooperate(final LanePerception perception, final Parameters params, final SpeedLimitInfo sli,
final CarFollowingModel cfm, final LateralDirectionality lat, final Desire ownDesire)
throws ParameterException, OperationalPlanException
{
if ((lat.isLeft() && !perception.getLaneStructure().getExtendedCrossSection().contains(RelativeLane.LEFT))
|| (lat.isRight() && !perception.getLaneStructure().getExtendedCrossSection().contains(RelativeLane.RIGHT)))
{
return new Acceleration(Double.MAX_VALUE, AccelerationUnit.SI);
}
Acceleration b = params.getParameter(ParameterTypes.B); |
File |
Line |
org\opentrafficsim\road\gtu\generator\AbstractGTUGeneratorOld.java |
345 |
org\opentrafficsim\road\gtu\generator\AbstractGTUGeneratorOld.java |
405 |
double distanceM = cumDistanceSI + otherGTU.position(theLane, otherGTU.getRear(), when).getSI() - lanePositionSI;
if (distanceM > 0 && distanceM <= maxDistanceSI)
{
return new HeadwayGTUSimple(otherGTU.getId(), otherGTU.getGTUType(), new Length(distanceM, LengthUnit.SI),
otherGTU.getLength(), otherGTU.getWidth(), otherGTU.getSpeed(), otherGTU.getAcceleration(), null);
}
return new HeadwayDistance(Double.MAX_VALUE);
}
// Continue search on successor lanes.
if (cumDistanceSI + theLane.getLength().getSI() - lanePositionSI < maxDistanceSI)
{
// is there a successor link?
if (theLane.nextLanes(this.gtuType).size() > 0) |
File |
Line |
org\opentrafficsim\road\gtu\lane\perception\categories\neighbors\AccPerception.java |
132 |
org\opentrafficsim\road\gtu\lane\perception\categories\neighbors\CaccPerception.java |
132 |
DownstreamNeighboursIterableACC(final LaneBasedGTU perceivingGtu, final LaneRecord<?> root,
final Length initialPosition, final Length maxDistance, final RelativePosition relativePosition,
final HeadwayGtuType headwayGtuType, final RelativeLane lane, final boolean ignoreIfUpstream)
{
super(perceivingGtu, root, initialPosition, maxDistance, relativePosition, headwayGtuType, lane, ignoreIfUpstream);
}
/** {@inheritDoc} */
@Override
protected Entry getNext(final LaneRecord<?> record, final Length position, final Integer counter) throws GTUException
{
Entry next;
do
{
next = super.getNext(record, position, counter);
}
// skip leaders that are not the direct leader and that are not CACC
while (next != null && counter > 1 && !(next.getObject().getTacticalPlanner() instanceof CACC)); |