CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
576 stars 85 forks source link

Automatically lower speed limits on roundabouts [Suggestion] #793

Closed scottmcm closed 4 years ago

scottmcm commented 4 years ago

Many people use highways for roundabouts, as there's no other 3-lane one-way road in vanilla, or use 80km/h highway ramps for small residential roundabouts as the only 1-lane road in vanilla.

But the roundabout going faster than the connecting roads is both unrealistic and less efficient -- having the speed limit lower makes it easier for traffic to merge onto the roundabout (less time accelerating means they can fit into a smaller gap, and the same distance of gap becomes a longer-in-time gap) and allows for more traffic to be on the circulating roadway at a time.

So it would be nice to have an option for the roundabout auto-setup to also set an appropriate speed limit based on the size of the roundabout.

How fast should it be? Well, the FHWA's roundabout technical summary suggests speeds of 25-50km/h, for different sized roundabouts, and we know that a=v²/r, so it seems plausible for the speed to be linear in the square root of the radius.

Playing with the numbers a bit, setting the speed limit to 4√r (with r in meters and speed limit in km/h) seems plausible

radius (u=8m) speed limit (km/h)
3 20
5 25
7 30
10 36
14 42
20 50

So here's a concrete suggestion for how this could work, as a probably-close-enough approximation:

Other estimates for the radius could be 1/2π of the length of the roundabout, or anything else that's easy for you get and about-right for anything that's about-circular. (If the speed limits are a bit off for a "wonky-about" I wouldn't really care.)

originalfoo commented 4 years ago

@kianzarrin is this something that could be added to the bulk update tool for roundabouts?

kianzarrin commented 4 years ago

My pedestrian bridge build mod can detect the center of the roundabout but I don't think we need it here. I think measure of curvature suffices:

segment speed = constant * Vector2.Dot(startDir,EndDir) // maybe cos would work better.
kianzarrin commented 4 years ago

in any case we should ban parking

kianzarrin commented 4 years ago

I think there is a superstition that changing roundabout speed improves traffic!

I have done some testing of my own and I noticed decrees in traffic flow. It is indeed easier to enter roundabout if approaching car is moving slowly but on the downside approaching cars take their sweet time to leave the roundabout so cars entering the roundabout will have to wait longer for the roundabout to be cleared. You give some, you loose some but on the whole its worst.

Biffa says reducing speed limit on roundabout boosts traffic. While he does plays with roundabout speed limits, he has never checked back (that I know of) to verify if there has been any benefit.

I still think its a good feature because you want to go slowly on roundabouts to reduce accidents ... although this game does not simulate accidents. not to mention the centrifuge force.

I am worried that if we implement this feature, people will think its boosts traffic in CS so I think we should explain in a wiki page that it does not.

originalfoo commented 4 years ago

I've seen lots of users building roundabouts out of highway roads, and then proclaiming that their roundabout solved traffic issues.

What is described in OP is essentially "make roundabout traffic speed more realisstic". Personally I spend ages tweaking lane speeds in roundabouts which is a bit of a PITA especially as I can't get much benefit from Shift + click in that context.

Maybe we can add a Realistic speed limits checkbox to the existing roundabout policies: It would essentially do some math to set the lane speeds for segments in the rounadabout and, ideally, also the segments entering the roundabout.

That way users can choose to have more realistic speeds in their roundabouts, or not. Hopefully calling it realistic speed will avoid assumptions that it somehow improves traffic throughput.

Some potentially related issues: #757 , #668

kianzarrin commented 4 years ago

we can calculate the raduis of the segment like this:

dot = - startDir . EndDir
angle = acos(dot)
L = |startPos - endPos|
R = L / ( 2*sin(angle/2) ) // see drawing 
  = L/(2-2*dot) // see https://github.com/CitiesSkylinesMods/TMPE/issues/793#issuecomment-617521557
V= 4 * sqrt(r)

Now the question is what formula to use to drive speed limit based on the values above. EDIT: wait its already in the description

raduis

scottmcm commented 4 years ago

If you want to save some trig, I think you can do R = L / sqrt(2 - 2*dot).

kianzarrin commented 4 years ago

R = L / sqrt(2 - 2*dot).

Wow I like that so cool! forgot what was sin(x/2) ... should have searched it!

kianzarrin commented 4 years ago

@scottmcm what is sign in 4√r

4*sqrt(20)=18 which is different than your table 50

kianzarrin commented 4 years ago

My calculations shows that it should be 11.3*sqrt(r)

kianzarrin commented 4 years ago
Playing with the numbers a bit, setting the speed limit to 4√r (with r in meters and speed limit in km/h) seems plausible radius (u) speed limit (km/h)
3 20
5 25

How did you manage to create roads so small?! @scottmcm The smallest I could create is radius=8m Screenshot (897)

EDIT: tagging #73 and https://imgur.com/a/Hf6FBim the image above looks like the 8m roundabout i made but painted over.

scottmcm commented 4 years ago

@kianzarrin Oh, by (u) in the table I meant the 8m grid-/road-snapping units. So 3u -> 24m -> 19.6km/h. (The 11.3 you calculated from the table is 4*sqrt(8).) And √ is square root.

I'm glad you like the trig trick! I tried to figure it out by hand but decided that was too complicated and decided to just ask wolfram alpha in hopes that something existed 😅

Also, I was looking at your original formula again and came up with another way of getting the same thing (thinking in terms of 2R=L/sin(θ)), with apologies for the mspaint art: image Using Thale's Theorem (and some poorly justified math that the blue corner has to go from 0° when the directions are parallel to 90° when they're in opposition).

EDIT: Oh, actually, if you have the three points of the quadratic bezier when doing this, this answer claims to have a closed formula for curvature, which is inverse radius: https://math.stackexchange.com/a/2971112

originalfoo commented 4 years ago

I assume this could be applied to any bend? So we can make traffic slow down on any curved segment, based on curvature of the segment - regardless of whether it's roundabout or just winding road through the mountains?

Are there any guidelines of traffic speed based on incline/decline of the road? Because if we could mix those two together, optimised enogh for per-frame vehicle AIs, we could get some really awesome and realistic vehicle speeds! (User would set thier desired speed but TMPE would then buff/nerf it depending on various factors).

scottmcm commented 4 years ago

@aubergine10 I can't find the table I'm thinking about, but I did manage to find this: https://www.virginiadot.org/business/resources/LocDes/RDM/Appendix_a1.pdf image

If I turn that into a formula, image

And if I turn that into metric https://frinklang.org/fsp/frink.fsp?fromVal=1.3449+miles+%2F+hour+%2F+%28sqrt%5Bfeet%5D%29&toVal=km%2Fhour+%2F+%28sqrt%5Bm%5D%29#calc, I think that's Maximum Speed in km/h = 3.9204 km/hour/√m * √(Radius in m) + 20 km/h

Which is surprisingly close to what I'd guessed for roundabouts, actually, just plus 20. (But this is a maximum speed, not a suggested speed, so being higher makes sense.)

EDIT Actually, I remade the chart in metric, and it's so close to the grid intersections that it makes me think that they actually did it off a formula that was in metric with a simple constant, and it's just the rounding to the unfortunate imperial system that added the weird decimals: image Oh, in fact the page says "Note: Reference to all Metric Units have been removed." So maybe a previous version of the document even had the nice numbers, but a later revision removed them.

scottmcm commented 4 years ago

@aubergine10 Oh, I forgot to respond to "traffic speed based on incline/decline of the road". The CSL horizontal compression means that the real-life guidelines will be quite unusable. A fairly-gentle slope in the game is 1/8 (one default page up per 12 grid units), but that's a 12.5% grade, which is real life is quite severe. From the same PDF I linked in the previous post: image Applying those would force us to slow even well-designed system interchanges to a crawl.

originalfoo commented 4 years ago

Applying those would force us to slow even well-designed system interchanges to a crawl.

Could we approach it as a ratio or something like that?

So we'd say 12.5% grade (game) is equivalent to 3% grade (RL) and adjust speeds accordingly?

The main thing I'm thinking is it would be nice to have traffic that's going up-hill be a bit slower than traffic going down the same hill.

kianzarrin commented 4 years ago

@scottmcm EDIT: Oh, actually, if you have the three points of the quadratic bezier when doing this, this answer claims to have a closed formula for curvature, which is inverse radius: https://math.stackexchange.com/a/2971112

You have some cool math there. I don't have access to segment bezier so going that root is going to be slow. How did you calculated the angle/2 in your diagram?

And what is grade?

EDIT: @aubergine10 I didn't know going downhill is faster than going up hill. going downhill is dangerous because the brakes don't work as good. In a few of my trips to hilly regions I noticed going up hill and downhill has the same speed limit in Israel (in theory in practice people just zoom downhill!)

scottmcm commented 4 years ago

@kianzarrin Ah, yeah, if you don't have all the bezier points then that's not a fruitful direction.

I haven't yet managed to geometrically prove that blue corner is the same angle/2 as in your formula. I just have the informal demonstration that when the angle between the directions is 0°, that blue corner is 0°, when the angle between the directions is 90° that blue corner is 45°, and when the angle between the directions is 180° that blue corner is 90°. (It's not important, though -- I'm just exploring and you should feel free to ignore my rambling about it, since you already found a good formula.)

Grade is just a word for slope with a grade of zero being horizontal. When reported as a percentage its value is the tangent of the angle (12.5% = tan(7.125°)).

Sipke82 commented 4 years ago

I was under the illusion that the cars travel slower in bends?..do they really go full speed in tight corners?

originalfoo commented 4 years ago

@Sipke82 that's what we're trying to achieve; getting the cars to alter their speeds based on curvature and grade of road.

So users might have road that is 60MPH, but due to bends (in particular) and grade, some parts of the road might require vehicles to reduce their speed. We could potentially also create some sort of info view showing red where traffic has to go slower than current speed limit and green where potentially traffic could go faster than current speed limit.

The benefits are:

Sipke82 commented 4 years ago

Well when watching this with the FPS camera mod (which displays the actual speed) Vehicles do slow down in the corners.. Personally i think its still a bit fast :-S

image

kianzarrin commented 4 years ago

Does everyone agree that shift clicking roundabout should change the speed of the whole roundabout rather than until junction?

@thebugfixnet I figured out that the Speed-Limit function works within round-abouts in the same way they do on normal roads. On normal roads with Shift-Klick the speed limit is assigned from one junction to the next. I can understand this as in real world also the speed limits at the next crossing may be different. So this behavior i was ecpexting. But on roundabouts in my opinion there should be the logic to set the speed limit for the whole roundabout street with Shift-Klick. This is the way ot is in real i think. Additionally the super function of automated lower speed limits on roundabouts do it for the whole roundabout road. To be consistend to this function it would be good to handle it in the same way for the speed-limit function. image

originalfoo commented 4 years ago

It should, and it should set the speed to whatever the user has selected.

To adjust speed based on curvature/grade, that should be buff/nerf done automatically if possible.

kianzarrin commented 4 years ago

created issue #869 for speed limit tool to cover the roundabout.

scottmcm commented 4 years ago

Thanks, folks! I'm excited to try this when 11.6 comes out!

kianzarrin commented 4 years ago

@Biffa: Next TMPE version will be able to setup REALISTIC roundabout speed limit based on the size of the roundabout (sharp curves means lower speeds). It will be turned off by default but you can change it via the policy tab in mod settings.

Additionally you can shift click to change the speed of the whole roundabout (#869) (Control+shift+click for lane wise): image

I am not so sure if reducing roundabout speed (but I could be wrong will reduce traffic. We are adding these options for the sake of realism.

You mentioned in your videos that reducing roundabout speeds can give cars a chance to get in and reduce traffic. I noticed that after reducing roundabout speed, you did not came back to check if you got any improvement (unless if you cut that part out). I tried this my self and I observed that reducing roundabout speed actually decreases traffic flow and increase traffic jams ( I am a fallible being so I can make mistakes!):

Going slower on the roundabout does reduce car accidents (and hence traffic jams) in the real world but considering that there is no accidents in Cities skylines, higher speed is a risk free advantage.

Anyway just my opinions and I could be wrong so I like to know your thoughts on this as well.

kianzarrin commented 4 years ago

Biffa In your videos you like to enable lane switching at the the entrance of the roundabout:

image

as you can see from the image above, if cars lane switch at the roundabout, they are going to get in the way of the cars that are already on the roundabout as well as the cars joining the roundabout on that road.

But if the cars switch lane before arriving at roundabout then they only get in the way of the cars on that road. Which is not a big deal because in on a busy roundabout the cars have to wait before they can enter the roundabout anyway. image

When I tried turned on the "Vehicles going straight on may change lanes at junctions" on the roundabout, it had no influence ... probably because cars are not going straight but rather are turning right into the roundabout.

If the highway rules are enabled, its a different story though. If highway rules is enabled (not recommended) and highway roads joins a highway roundabout then you MUST turn on lane switching when entering the roundabout or cars will not use the outer lanes of the roundabout anymore. For this reason my TMPE roundabout auto-setup silently activates the lane changing rule at such circumstances.

DaEgi01 commented 4 years ago
  • Con: but it also means that it takes longer for the cars on the roundabout to leave get out of the way so that cars can join the roundabout. This cancels out any advantage you gain from the "Pro" above.
  • Con2: At the end of the day, the faster cars move on the roundabout, the more throughput it has, and the more cars it can let through.

This is not true if you consider that safety distance does not increase linearly with speed, at least IRL. No idea what the formula is ingame.

kianzarrin commented 4 years ago

@DaEgi01 You make a very good point. Safety distance increases as a power of two (I guess) but getting out of the way is directly proportional to speed. (assuming TMPE implementation matches reality).

There are many factors in play like a faster roundabout gets cleared faster allowing cars to come in. When I tried it in game several times, every time when I reduced roundabout speed traffic started to build up. when I increased roundabout speed, traffic got cleared. A few samples only so not that much.