viewof vehicleASpeed = Inputs.range([20, 200], {
value: 100,
step: 5,
label: "Vehicle A Speed (km/h)"
})
viewof vehicleBSpeed = Inputs.range([20, 200], {
value: 100,
step: 5,
label: "Vehicle B Speed (km/h)"
})
viewof distanceBetween = Inputs.range([50, 2000], {
value: 300,
step: 50,
label: "Distance Between Vehicles (m)"
})
// Calculations
combinedSpeedMps = (vehicleASpeed + vehicleBSpeed) / 3.6 // Convert km/h to m/s
timeToCollision = distanceBetween / combinedSpeedMps
warningTime = Math.max(0, timeToCollision - 0.5) // Minus system processing time
messagesExchanged = Math.floor(timeToCollision / 0.1) // BSM every 100ms
html`
<div style="background: linear-gradient(135deg, #2C3E50 0%, #16A085 100%); padding: 25px; border-radius: 8px; color: white; margin: 20px 0;">
<h3 style="margin-top: 0; color: white; border-bottom: 2px solid #E67E22; padding-bottom: 10px;">V2X Collision Warning Analysis</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px;">
<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 6px; border-left: 4px solid #E67E22;">
<div style="font-size: 14px; opacity: 0.9;">Time to Collision</div>
<div style="font-size: 32px; font-weight: bold; color: ${timeToCollision < 2 ? '#E74C3C' : '#16A085'};">
${timeToCollision.toFixed(2)}s
</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 6px; border-left: 4px solid #3498DB;">
<div style="font-size: 14px; opacity: 0.9;">Driver Warning Time</div>
<div style="font-size: 32px; font-weight: bold; color: ${warningTime < 1 ? '#E74C3C' : '#16A085'};">
${warningTime.toFixed(2)}s
</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 6px; border-left: 4px solid #9B59B6;">
<div style="font-size: 14px; opacity: 0.9;">Combined Speed</div>
<div style="font-size: 28px; font-weight: bold;">
${(combinedSpeedMps * 3.6).toFixed(0)} km/h (${combinedSpeedMps.toFixed(1)} m/s)
</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 6px; border-left: 4px solid #16A085;">
<div style="font-size: 14px; opacity: 0.9;">BSM Messages Exchanged</div>
<div style="font-size: 28px; font-weight: bold;">
~${messagesExchanged} messages
</div>
</div>
</div>
<div style="margin-top: 20px; padding: 15px; background: rgba(255,255,255,0.1); border-radius: 6px; font-size: 14px; line-height: 1.6;">
<strong style="color: #E67E22;">Safety Analysis:</strong><br/>
${timeToCollision < 1.5
? "<strong>CRITICAL:</strong> Insufficient time for human reaction. Automatic emergency braking required."
: timeToCollision < 2.5
? "<strong>WARNING:</strong> Limited time for driver response. V2X warning essential for crash avoidance."
: "✓ <strong>SAFE:</strong> Adequate warning time for driver to react and avoid collision."}
<br/><br/>
At this closing speed, vehicles approach each other at <strong>${combinedSpeedMps.toFixed(1)} m/s</strong>.
V2X enables <strong>${messagesExchanged} safety message exchanges</strong> before potential impact,
providing <strong>${warningTime.toFixed(2)} seconds</strong> of actionable warning time after system processing.
</div>
</div>
`V2X Collision Avoidance Scenario
V2X Collision Avoidance Scenario
animation
transportation
Try Change Vehicle A Speed (km/h), then press Calculate warning time.
Observe After Calculate warning time, compare Time to Collision, Driver Warning Time, and BSM Messages Exchanged.
Explain Explain why Calculate warning time subtracts system processing time from Time to Collision.
Technical boundaries. The calculation adds vehicle speeds and assumes they remain constant. Driver warning time subtracts 0.5 seconds, and BSM messages are counted every 100 ms.
V2X Collision Avoidance Scenario
To understand how V2X saves lives, follow Figure 1 through a potential intersection collision being prevented:
Figure 1 illustrates why V2X requires <10 ms latency: with vehicles approaching at combined speeds of 100+ km/h, every millisecond matters. The Basic Safety Message (BSM) broadcast every 100 ms provides continuous position updates, enabling collision prediction 2-3 seconds before impact—enough time for both automated systems and human drivers to react.
Interactive Insight: Adjust the speeds and distance to see how V2X warning time changes. Notice how even at highway speeds (100+ km/h), vehicles have only 2-3 seconds to avoid collision. This is why V2X requires <10 ms latency—every millisecond matters when closing speeds exceed 50 m/s.