Opened 7 years ago

Last modified 3 years ago

#660 new defect/bug

roads joining at obtuse angle do not create navigation maneuver

Reported by: polarbear_n Owned by: mvglasow (2)
Priority: major Milestone: version 0.5.1
Component: core Version: git master
Severity: normal Keywords: patches
Cc: michael@…

Description

I observed in several locations that a road joining another road in an obtuse angle is not recognised as a maneuver and therefore not announced.

While that might be ok as long as the roads have the same grade, even if they change name (since even straight roads might have differently named segments), but the following conditions should clearly trigger a maneuver announcement:

  • the roads have different Ref numbers, such as motorway M9 joining M7,
  • the road have different grades, such as a tertiary road joining a secondary
  • joining a road which is clearly not just a name change, i.e. coming from road A to road B, which is B both left and right of the junction.

The strangest situation I had observed in that context was joining a road (obtuse) in a slight right turn, which was followed by a sharp left 50 m further down. Since the obtuse right was not announced, it was already announcing the sharp left, which apparently was impossibe and misleading.

Attachments (5)

trac660.patch (3.8 KB) - added by mvglasow (2) 3 years ago.
trac660_r5911.patch (5.6 KB) - added by mvglasow (2) 3 years ago.
Third version of patch, applies on top of r5911 (replaces second version)
highway.png (176.3 KB) - added by kazer 3 years ago.
Highway routing comparison
missing_maeuver.png (125.9 KB) - added by kazer 3 years ago.
Missing maneuver
trac660_r5917.patch (13.3 KB) - added by mvglasow (2) 3 years ago.
Refine criteria for ambiguous maneuvers (fix for Emeryville test case), third try

Download all attachments as: .zip

Change History (57)

comment:1 Changed 7 years ago by monas

I think maneuver should also be announced if another road of the same or better grade require to turn at similar or smaller angle in the junction. i.e. abs(angle[route]) + 15degrees > abs(angle[alternative]).

Real world example (OSM)

I was traveling on 108 from SE and needed to continue on 108 to SW. Turn in this junction was not announced. Ok, I knew the route, road signs show that "main road" makes a turn. But, if traveling in unknown place, it's easy to become confused or miss a turn if not glimpsing at the map periodically.

comment:2 Changed 6 years ago by mvglasow (2)

  • Cc michael@… added

Another one is here: http://www.openstreetmap.org/?lat=54.3455&lon=24.6964&zoom=13&layers=M

No turn is announced when following A4 from east to west; however, the route graph shows the correct route (turning slightly left to stay on A4, rather than proceeding straight onto 128). I've seen similar behavior in many places, not just Lithuania ;-)

It seems that Navit does not produce turn instructions when the same road is followed, even if this road turns right or left and another one branches off, going straight (or to the other side). "Same road" apparently gets decided based on highway=*, ref and/or name.

When roads split, it is not immediately apparent to the driver which of the two roads ahead is the continuation of the road he is currently on. Directions like "go straight", "turn left", "keep right" are more intuitive. Also, I would expect most drivers to intuitively go straight unless they are getting different instructions.

Suggestion: At each junction, analyze the geometry of the roads. When the road to be followed deviates from the "straight" direction and there's another road that's going more "straight", generate a turn instruction.

comment:3 Changed 6 years ago by mvglasow (2)

Consider also #921, which discusses the contrary case for motorways: the motorway turns slightly while an off-ramp goes straight; here turn instructions are not needed as it's usually obvious where the continuation of the road is.

comment:4 Changed 4 years ago by usul

  • Milestone changed from version 0.2.1 to version 0.5.1

Can any cardriver please tell, if this is still an issue?

comment:5 Changed 3 years ago by mvglasow (2)

  • Severity set to normal

Yes, it is still an issue, and I just ran into it again.

Does anybody have a pointer to the part of the code where Navit decides whether or not to announce a maneuver? Then I might be able to get my build environment up and running again and experiment with a few rules.

I have a first solution approach for motorways: Assume each point on the route has an "entry" and one or more potential "exits". The route approaches the point over the entry and leaves it through one of the exit.

Then rules for announcing a maneuver are:

  • When there is only one exit, make no announcement. (This one is so obvious that it might be forgotten in code.)
  • When the entry is a motorway and the exit on the route is a ramp, make an announcement.
  • When the entry is a motorway and more than one exit is a motorway, make an announcement.

Trunk roads are a bit more difficult. Some have motorway-like characteristics while others are just major urban or country roads.

Motorway-like trunk roads have the oneway=yes tag, hence we can apply the above rules to highway=trunk;oneway=yes just like highway=motorway.

Not every trunk road with this tag is motorway-like, so we need an extra rule to sort out such cases:

  • When the entry is a one-way trunk road and at least one exit is neither a motorway, trunk road or ramp, use the old logic, i.e. decide whether or not to announce a maneuver based on the same criteria as before.

I expect that this will solve quite a few issues, including those that I encountered over the course of the past week (mostly motorway junctions). The bad news is that the two cases in Lithuania which Monas and I encountered before were on single-carriageway roads. (Monas's example has since been converted to a roundabout, so we'll need to find another test case here.)

We might be able to catch these with the following extra rules:

  • When the exit is a ramp, make an annonucement.
  • When two or more exits have the same rank as the entry (i.e. trunk, primary, secondary) and the route takes a turn, make an announcement. Specifically, do not suppress announcements based on the road number alone.

For the purposes of this rule, we will consider a route to take a turn based on the bearings of entry and route exit. When the exit with the bearing closest to the entry is not on the route, or when the bearings of entry and route exit differ by more than a certain threshold (some 22.5°), we consider this a turn in the route.

The last rule may need some extra tweaking: it will not catch my case (entry is trunk, exit is either slightly left onto the trunk road or straight onto a primary road). One possibility would be to change the "same rank as entry" criterion to "same rank as or one rank lower than entry".

comment:6 Changed 3 years ago by mvglasow (2)

I've found something in /trunk/navit/navit/navigation.c, maneuver_required2(struct navigation *, struct navigation_itm *, struct navigation_itm *, int *, char **), which seems to hold the code we need to touch. I'm currently cloning the repo, and if I get it to build, I'll prepare a patch and submit it here.

comment:7 Changed 3 years ago by mvglasow (2)

Navit builds, I'll try to get a patch ready over the next few days

comment:8 Changed 3 years ago by mvglasow (2)

Looking at it again, I see that my earlier example (near Naujieji Valkininkai, Lithuania) is a particularly mean one. It is a single-carriageway trunk road that turns left, and a primary going off it. However, the links between the primary and the trunk road are mapped as ramps. In OSM they are primary_ramp roads, but Navit uses a single ramp type and thus cannot tell if it is a trunk_ramp or a primary_ramp.

I could modify the logic to generate turn instructions when the entry and exit is a single-carriageway trunk road, which would give us an instruction here. However, it might generate superfluous instructions on certain single-carriageway trunk roads with no level crossings. (These are single-carriageway roads but have ramps like motorways, and if one of the ramps is in a left turn, we'd get a "turn left" to stay on the road.) I'll try to find a few test cases where we don't want a turn instruction and then try implementing the ruleset I described above.

comment:9 Changed 3 years ago by mvglasow (2)

Just noticed that I still have an old map file where Monas's example is still a T junction rather than a roundabout. He was going from Maišiagala to Vievis and the left turn near Airėnai I/II to stay on 108 was not announced. However, r5899 does announce a left turn here. On the other hand, the turn before, in Dūkštos (turn right to stay on 108) is not announced. The only difference I can see is that the turn in Dūkstos has a bearing change of about 60° while the one in Airėnai is close to 90°. In any case this should get caught by the rules I proposed.

comment:10 Changed 3 years ago by mvglasow (2)

I've found two stretches of single-carriageway trunk roads with no level crossings: in Switzerland, the Rongellen–San Bernardino and Lostallo–Bellinzona stretches of the A13. With r5899 routing is OK: exits are announced, going past an exit is not.

I've implemented and tested the above rules. Results:

  • Maišiagala–Vievis: OK – announcements in Dūkštos and Airėnai.
  • Naujieji Valkininkai–Senoji Varėna: NOK – still no announcement after Naujieji Valkininkai.
  • Rongellen–San Bernardino: OK – no announcements when going past an exit
  • San Bernardino–Rongellen: OK – no announcements when going past an exit
  • Lostallo–Arbedo-Castione: OK – no announcements when going past an exit
  • Bellinzona–Lostallo: OK – no announcements when going past an exit

Still need to do some work work on Senoji Varėna without breaking San Bernardino.

comment:11 Changed 3 years ago by mvglasow (2)

Looking at aerial imagery of Naujieji Valkininkai, the road markings at the junction make it pretty clear that the trunk road goes left while the road that continues straight is a smaller road. We might even be able to live with cases like that one – I'll make a patch of what I have now and submit it.

Changed 3 years ago by mvglasow (2)

comment:12 Changed 3 years ago by mvglasow (2)

  • Keywords patch added

Patch above.

comment:13 Changed 3 years ago by mvglasow (2)

  • Keywords patches added; patch removed

comment:14 Changed 3 years ago by mvglasow (2)

If somebody would like to try the patch, a prebuilt Android package is available at: http://mvglasow.github.io/navit/Navit.5899-trac660.apk

A binary for Linux (x86) is available at: http://mvglasow.github.io/navit/linux_x86/navit.5899-trac660

Edit: These versions are outdated and have been removed. See later comment for current versions.

Last edited 3 years ago by mvglasow (2) (previous) (diff)

comment:15 Changed 3 years ago by tryagain

I also have compiled a test version for win32 and wince platforms, you may download it from http://www.navit-project.org/~tryagain/navit_win32_5899_trac660.exe and http://www.navit-project.org/~tryagain/navit_wince_5899_trac660.exe

Last edited 3 years ago by tryagain (previous) (diff)

comment:16 Changed 3 years ago by mvglasow (2)

Currently testing the patched version.

The patch just adds announcements and doesn't suppress any, hence watch out for superfluous announcements.

  • I got one strange maneuver, which I still need to sort out by replaying a GPX trace against both a patched and a vanilla build and comparing differences.
  • There are some cases which will not get caught. Most notably, these are motorway interchanges where one of the two possible ways after the maneuver is a motorway and the other is a ramp (and the maneuver is to follow the motorway). This is indistinguishable from a regular exit, thus going on the ramp will create a maneuver, staying on the motorway will not. (Same goes for oneway trunk roads.)
  • Occasionally I will get told to "turn left" when it should be "keep right" and vice versa. This is a separate issue (#694, #795) and not addressed by this patch.
  • Apart from that I did not notice any superfluous maneuvers.

comment:17 Changed 3 years ago by mvglasow (2)

The strange maneuver was a "turn left" just prior to entering a roundabout which is part of a ramp. Without cross-checking against a vanilla build, I suspect it has to do with the rule to always generate a maneuver for ramps. I'll move the "no maneuver to enter roundabout" rule higher up and see what happens.

comment:18 Changed 3 years ago by mvglasow (2)

Rearranging the rules to evaluate roundabouts first did the trick and eleminated the strange maneuver I'd observed before. Updated test versions:

comment:19 Changed 3 years ago by mvglasow (2)

Another test today brought about two more odd maneuvers:

  • Turning left from a dual-carriageway primary road onto a motorway ramp, I was first instructed to keep left, then to turn left right after that. This needs further investigation.
  • When going past a highway service area, connected via highway=service ways, I got an instruction to go straight – this is probably an error that can be fixed by not generating a maneuver when the only other options are service roads.

comment:20 Changed 3 years ago by kazer

I am definitely interested into an updated version of your patch. Highways are quite dense around where I live ( or where I usually drive ) and splits are very common, and Navit should make better announcements for them. I'll try your patch meanwhile.

comment:21 Changed 3 years ago by kazer

I did some testing, and the navigation instructions are indeed a bit better. It does a better job at announcing a highway split for example.

Patch applied in r5911.

We could still enhance the navigation tho, especially for highways :

  • when there is a ramp between the two highways, navit will say "turn right into the ramp". It would be useful to announce the next highway name / number : " ... towards <insert name here>". For that we probably need to announce item[2] instead of item[1]
  • same applies for highway entries actually : sometimes you have two ramps leading to two different highways. Knowing toward which highway you should be headed would actually be helpful
  • we should probably replace the "turn <right|left> into the ramp" by "take the exit on your <left|right>" ( announcing exit number when available is yet another topic). Can a ramp be something else than an exit or a merge towards another highway?

I'm keeping this ticket open for now in case we can enhance these issues soon.

Anyway, your patch does actually improve navigation a lot, so thanks mvglasow!

comment:22 Changed 3 years ago by mvglasow (2)

I'll post the updated patch soon, I realize I should have made that available along with the compiled versions.

I'll need to do some more research into the cases which I encountered this weekend. Turns out the service area had ramps going off the motorway which then turned into service roads, thus it got treated like a normal exit or interchange. There were two further cases in which I got an announcement to stay on the motorway and not take a normal exit – I'll need to investigate into why that happened. Neither of these cases should be generating an announcement.

(This should also answer the question what else ramps can be used for – a ramp may also lead towards a service area, though mapping on OSM is somewhat inconsistent here.)

As for announcing ramps – I have had this idea as well, but this is really a separate issue. I've opened #1265 for it. The issue here is about whether or not to create a maneuver, #1265 is about the name to be used in announcements. There's also #694/#795, which is about the type of maneuver...

comment:23 Changed 3 years ago by mvglasow (2)

The above patch fixes the roundabout/ramp case. Be sure to get the latest version as I've uploaded a few buggy versions of it, due to the fact that merging r5911 back into my git branch messed up things.

comment:24 Changed 3 years ago by mvglasow (2)

Some news on the "don't take the ramp" maneuvers: apparently the rule that triggers those maneuvers is somewhere in the block that checks for same street and angles. I have to dig my way through it to understand what it is meant to do...

comment:25 Changed 3 years ago by mvglasow (2)

I still don't fully understand the whole steering angle magic, but essentially the code boils down to checking two things:

  • Ambiguity: A maneuver is considered ambiguous if there is more than one candidate road within a certain range of steering angles.
  • Same street: The route is assumed to follow the same street if the name stays the same and there are no other candidate roads with the same name. An exception is made for motorways (which can split temporarily): if the route follows a motorway and all other roads with the same name are also motorways, the same street criterion is still met.

A maneuver is created when the maneuver is ambiguous AND the same street criterion is not met.

Due to the rules for steering angles, an exit off a relatively straight motorway is easily considered ambiguous. However, the same street criterion will usually be met, thus following a motorway going past an exit will usually not create a maneuver.

However, there are cases in which zealous mappers have tagged ramps with the name of the motorway they lead away from. This would violate the "same street" criterion (more than one candidate way with the same name as the old way, one of which is not a motorway) and thus create an unnecessary maneuver.

After analyzing the data, this has caused all of the superfluous maneuvers I encountered last weekend.

IMHO the tagging is broken. But I doubt I'll live long enough to convince each and every mapper out there of my point – so the only other option is to modify Navit to handle such cases. Should be fairly straightforward...

Changed 3 years ago by mvglasow (2)

Third version of patch, applies on top of r5911 (replaces second version)

comment:26 Changed 3 years ago by mvglasow (2)

Here's the patch. It applies on top of r5911 and fixes the following:

  • Only exit from roundabout (not entry or staying in it) is announced, even on ramps
  • New helper function to determine if a way is "motorway-like" (i.e. motorway or one-way trunk road)
  • Exceptions to same-street criterion apply to all motorway-like roads, as well as ramps going off motorway-like roads
  • Removed (now obsolete) check for ramps in same-street criterion (going on a ramp is already caught by a separate rule added in r5911)

I've briefly tested the code against one of last weekend's test cases and the superfluous maneuvers are gone. I'll do some more extensive testing and then update the prebuilt versions. As always, additional testers are welcome :-)

Changed 3 years ago by kazer

Highway routing comparison

Changed 3 years ago by kazer

Missing maneuver

comment:27 Changed 3 years ago by kazer

I did some tests and this patch really enhance navigation on highways.

Here is an example: Highway routing comparison

In blue, the route before the patches from this ticket. In red, the route after. This highway has 6 lanes and splits in 3, and if you're in the wrong lane ( or if you don't know which split you should follow) you can end up having to pay a toll. We can see that the patch adds 3 announcements along the way which are really helping staying on the right route. It could still be a bit better, for example announcing "stay on your left" instead of "turn left" but it's already a big improvement.

There is still a missing maneuver, tho: Missing maneuver Here, if you are coming from Powell Street, you are supposed to turn right into Frontage road then enter the highway, but currently the announcement for Frontage road is skipped, and Navit will only say "Turn right into the ramp", with the distance between the two red markers. It can be easily confusing and one could be tempted to continue on Powell Street looking for the ramp instead of going right into Frontage road and then right again into the ramp.

One last thing : to better investigate routing changes, I added a new dbus call : http://sourceforge.net/p/navit/code/5912/

You can now compare the effect of a routing change using for example:

dbus-send  --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.set_position string:"geo: $lng $lat"
dbus-send  --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.set_destination string:"geo: $dlng $dlat" string:"dbus"
dbus-send --session --type=method_call --print-reply --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.export_as_gpx string:/tmp/660.gpx

It will generate a gpx dump of the route like this one :

<?xml version='1.0' encoding='UTF-8'?>
<gpx version='1.1' creator='Navit http://navit.sourceforge.net'
     xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
     xmlns:navit='http://www.navit-project.org/schema/navit'
     xmlns='http://www.topografix.com/GPX/1/1'
     xsi:schemaLocation='http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'>
<rte>
<rtept lon='-122.2937179811110866' lat='37.8439930619099130'><name>Turn right in 50 meters into the street Shellmound Street</name></rtept>
<rtept lon='-122.2934481846293124' lat='37.8393554404405563'><name>Turn right in 500 meters into the street Shellmound Way</name></rtept>
<rtept lon='-122.2949230720629998' lat='37.8392631111721158'><name>Turn left in 125 meters into the street Christie Avenue</name></rtept>
<rtept lon='-122.2947072348775919' lat='37.8385173705367208'><name>Turn right in 80 meters into the street Powell Street</name></rtept>
<rtept lon='-122.2977829147698259' lat='37.8396182231104490'><name>Turn easily right in 400 meters into the ramp</name></rtept>
<rtept lon='-122.2960292376382938' lat='37.8362587957613954'><name>Turn right in 450 meters into the street Eastshore Freeway I 80;I 580</name></rtept>
<rtept lon='-122.2948151534702959' lat='37.8335739848470212'><name>Turn left in 300 meters into the I 580</name></rtept>
<rtept lon='-122.2938708657841005' lat='37.8293263860142446'><name>Turn left in 500 meters into the I 580</name></rtept>
<rtept lon='-122.2736631092990933' lat='37.8254763443810305'><name>Turn right in 2 kilometers into the ramp</name></rtept>
<rtept lon='-122.2701197821717756' lat='37.8193385933242894'><name>Turn right in 900 meters</name></rtept>
<rtept lon='-122.2710370902098020' lat='37.8168449861608025'><name>Turn left in 300 meters into the street 27th Street</name></rtept>
<rtept lon='-122.2698319992578746' lat='37.8164613468129716'><name>Turn left in 125 meters into the street Northgate Avenue</name></rtept>
<rtept lon='-122.2697960263936494' lat='37.8166602711681179'><name>Turn easily right in 20 meters into the ramp</name></rtept>
<rtept lon='-122.2696701213688186' lat='37.8171291621701187'><name>Turn left in 50 meters</name></rtept>
<rtept lon='-122.2688607319234961' lat='37.8208091426765094'><name>Turn right in 400 meters</name></rtept>
<rtept lon='-122.2647238525362638' lat='37.8233168235070281'><name>You have reached your destination in 600 meters</name></rtept>
</rte>
</gpx>

And you can easily use that to diff two gpx outputs ( or plot the route on a map). It's a quick hack but was helpful in reviewing patches in this ticket. One gotcha : the marker is where you are supposed to perform the maneuver, but the distance in the announcement is the distance from the previous maneuver (because it is what is used to build the announcement)

comment:28 Changed 3 years ago by kazer

I forgot to say that the patch trac660_r5911.patch was applied in r5913.

comment:29 Changed 3 years ago by mvglasow (2)

@kazer: Thanks! About your example: is the link from Powell Street to Frontage road a ramp or a secondary road in the map data you used in this test? This would make a difference in routing.

If it were all secondary (no ramps), I can explain why no maneuver is generated: at the point of the maneuver, there is only one possible way of the same category as the way leading towards it (secondary). All other ways are tertiary – thus Navit assumes that the user would follow the secondary road unless instructed otherwise.

I've had the opposite example: at http://www.openstreetmap.org/node/536468708#map=15/48.2265/11.5879&layers=N, coming from Munich on the primary road and going straight, I get an instruction to "keep left". Note that in the map data I used, the short stretch of primary between the two motorway ramps is mapped as secondary.

I have already given this some thought and one idea I had was to change the "only one street in same category" criterion to "only one street in same or next lower category". This would have given you a maneuver in your example – I have to see what it would do in my example.

comment:30 Changed 3 years ago by mvglasow (2)

  • Owner changed from KaZeR to mvglasow (2)

comment:31 Changed 3 years ago by kazer

Good catch mvglasow.

Powell and Frontage road are both secondary, and Powell becomes tertiary after this split, so it makes sense.

About your test case, I've put some ideas in #1268

comment:32 Changed 3 years ago by mvglasow (2)

Probably not the best way of mapping it (I would've made it a ramp), but I won't manage to convince every mapper of that. Let's see what I can do.

One thing that's odd is that I've run my test case (the one mentioned above) on Linux with the demo vehicle, and I don't get the "keep left" instruction which I got on my phone. Map data is the exact same though... will try replaying a recorded trace and see what happens...

comment:33 Changed 3 years ago by kazer

The mapping seems ok to me, because Frontage roads actually continues past the ramp : OSM

comment:34 Changed 3 years ago by mvglasow (2)

One step further on the Emeryville test case: the "more than one similar road and delta over 22" criterion does not fire because the difference between old and new bearing at the split is 19° for the maneuver.

For going straight the delta is 13°, hence the "not same street or ambiguous" criterion does not fire either because dlim is too low: Since both the old and new way are in a higher category than any other way at that position, dlim is set to one half the delta of the maneuver (which is 19°/2, rounded to 9°). I think I need to fiddle with the dlim calculations here...

comment:35 Changed 3 years ago by mvglasow (2)

That did the trick! I introduced an extra criterion: if the category of the old way, the category of the new way and the highest category of any other way differ by no more than 1, dlim is set so that any other way with same or lower delta as the maneuver will be considered ambiguous and trigger an announcement. Specifically, dlim = abs(d) + 1. (Adding 1 is needed because comparison is </> rather than <=/>=).

I'm not committing this yet because I can't really tell how likely this change is to have any regressions (in the form of superfluous anouncements).

I'll attach a patch as well as links to prebuilt binaries so that people can test it. I'll run my own test cases against it, in the lab and (if I can) in real life, and commit after successful testing.

comment:37 Changed 3 years ago by mvglasow (2)

I've found another issue in r5917:

http://www.openstreetmap.org/node/564869

When following Ammerseestraße to join the motorway, I get told to "keep left" here when there are no other allowed maneuvers (the only physically possible one would be to make a sharp right turn and go the wrong way into Senftenauerstraße). More testing revealed that this happens in other positions as well. I'll take a look at why this happens.

comment:38 Changed 3 years ago by mvglasow (2)

Turns out the maneuver here was generated because we're going from a secondary to a ramp (and the particular check fails to verify whether any other options are permitted).

I'm refactoring the code to have only one loop going over the entire set of available ways and analyze only those which are permitted. Furthermore I'm adding a check that suppresses maneuvers when there is only one permitted option.

comment:39 Changed 3 years ago by mvglasow (2)

The code changes have fixed the case. Running my suite of tests, I found three more interesting cases:

  1. In one case I get an announcement on a ramp where two split carriageways join, despite there being a turn restriction (the other, forbidden option being a U-turn).
  1. Another issue I found, which is even more complicated, involves T-junctions with dual-carriageway roads. Example:

http://www.openstreetmap.org/node/493880718 http://www.openstreetmap.org/#map=19/46.22227/9.04440

When I come in from the ramp, I don't get an instruction to turn left since that's the only possible maneuver at that point.

  1. At the same junction, since the road coming in is a ramp, I get a "turn easily left" announcement (telling me to stay on the ramp) at the point where I am crossing the opposite carriageway, just before the point at which I would turn left.

This is where things get interesting.

Case 1 is probably caused by the fact that is_way_allowed does not take turn restrictions into account. I'll need to dig into that more deeply to find out how Navit deals with turn restrictions in general.

Case 3 could probably be resolved by relaxing/refining the "always announce ramps" criterion: when one of the eligible ways is neither a ramp or motorway-like AND the maneuver is to go straight AND all other maneuvers involve a turn, do not announce the maneuver. I'll need to analyze the case further to see the reason for the maneuver here.

Case 2 is the really tricky one: we're not on a motorway-like road, so we expect the driver to follow the road, follow all access restrictions and go straight otherwise. We first cross the carriageway for the opposite direction (no maneuver needed since we're going straight), and once we've crossed it, turning left is the only option available, thus it is not announced.

However, drivers almost certainly expect to get told "turn left" at this point, and will get confused when they're getting near the end of the road and don't see a maneuver (or get told to go straight until shortly before the actual maneuver, and then suddenly get the nex maneuver, which may be at the other end of town).

So the rule is: when turning into a dual-carriageway road, announce the maneuver. The problem is how to detect a dual-carriageway road: we have to analyze not just a single maneuver, but also the one preceding it. This will need some more research...

comment:40 Changed 3 years ago by mvglasow (2)

Turns out analyzing previous maneuvers for case 2 is not quite as tricky as I thought. I've successfully tackled the respective test case. Currently running the test suite...

comment:41 Changed 3 years ago by mvglasow (2)

Patch attached (which fixes case 2). r5917 plus this patch fixes the Emeryville test case and the Munich-Ammerseestraße test case with no known regressions (compared to r5917) so far. (Case 1 and 3 have been around since at least 5917).

As always, if no major regressions are found, I'll commit this code in a few days. For those who can't wait, here are the attached binaries:

Last edited 3 years ago by mvglasow (2) (previous) (diff)

Changed 3 years ago by mvglasow (2)

Refine criteria for ambiguous maneuvers (fix for Emeryville test case), third try

comment:42 Changed 3 years ago by mvglasow (2)

New incarnation of the patch, which fixes case 3. The "always announce entering a ramp" rule has been restricted to apply only when all possible ways are motorway-like or ramps (indicating a potential labyrinth of ramps), or when the maneuver involves a turn (25° or more). Otherwise entering a ramp follows the same criteria as entering any other street.

I ran my test suite against the updated code, and I did see that some unexpected or unneeded maneuvers which r5917 would still generate disappear with the latest patch applied.

Binaries are at the same locations (replacing the old ones):

comment:43 Changed 3 years ago by mvglasow (2)

Committed in r5929. All that's left to do for now is handling turn restrictions... turns out this is the trickiest part of it all.

comment:44 Changed 3 years ago by mvglasow (2)

A test suite (script and data) can be found at https://github.com/mvglasow/navit-goodies/tree/master/scripts/routetest. It'll run a suite of test routes against two different git branches, export the routes as GPX and diff them.

Today in the chat I had a discussion with jandegr and tryagain if we should announce turns where they are the only option. We reached the conclusion that turns should be announced when there is a "straighter" road which we can't enter.

A clear-cut test case for this is Via_Graf 9.1439748 45.5133242 9.1391345 45.5146592

As of r5929, the right turn from Via Graf into Via Fratelli Antona Traversi is not announced because Via Graf is one way in the opposite direction after that point, thus the right turn is the only option. On the other hand, not announcing this maneuver might confuse drivers. I'll implement this.

comment:45 Changed 3 years ago by mvglasow (2)

Some more thoughts on the turn restrictions case – the test case is: Langwieder_See 11.457781 48.1648526 11.4120844 48.1983823

In the motorway ramp I am getting an announcement to go straight at the point where the two ramps going on and off the motorway join into one road. The announcement probably results from the special handling I've introduced for ramps. The reason for this were complex motorway interchanges where drivers will probably want guidance at every split.

It turns out that handling turn restrictions is extremely complex – tryagain and I spent a whole day trying to get this to work, but to no avail. Additionally, such a step is likely to be performance hungry.

I am considering an alternative: further relax the "always announce ramps" criterion so that it only applies when the route and at least one other option have a delta of less than 90°. Since on motorway interchanges the delta between two ramps is significantly lower than 90° for any allowed turn, a turn of more than 90° is likely prohibited and in any case is not what drivers would do unless instructed to do so.

comment:46 Changed 3 years ago by mvglasow (2)

Updates:

  • r5932 is a mostly cosmetic fix to use curve_limit in a more consistent manner (I'd previously introduced another threshold of 22° in the code, using one consistent value is better)
  • r5933 moves up the "always announce sharp turns over 75°" rule so that it applies even when all other options are not allowed. This fixes the issue with Via_Graf.

comment:47 Changed 3 years ago by mvglasow (2)

r5934 fixes the Langwieder_See test case using the approach I described above. Additionally it fixes a regression I'd introduced in r5933 (basically an experimental change that I ended up not needing bot forgot to undo). Tests reveal it eliminates a few other unneeded maneuvers at ramps.

Anyone who'd like to thest this build under real-life conditions is welcome. If you find an important announcement is missing, or an unnecessary announcement is made, please share a route to reproduce and the point at which you encountered the error.

If no further issues are found, I'll close this ticket soon.

comment:48 Changed 3 years ago by mvglasow (2)

I've found some problematic test cases:

Werder_W 12.8770471 52.3098972 12.7570371 52.3411968
Hamburg_Sued_S 10.073060 53.508260 10.037430 53.498250
Nuernberg_N 11.1956694 49.4085208 11.2825354 49.4965279

All have one thing in common: these are motorway interchanges where one way is mapped as highway=motorway, the others are mapped as highway=motorway_link. That makes them look to Navit like regular exits, and if the route follows the highway=motorway, nothing is announced.

Hamburg_Sued_S is the textbook example for this.

At Werder_W the name of the motorway changes at the interchange, just where the ramp leaves the motorway. This can probably be fixed by looking for a name change.

Nuernberg_N is also a special case as the ramp goes off to the left. If Navit "knows" whether the territory we're in drives on the left or on the right, we could have Navit create an announcement whenever the ramp leaves the motorway on the "wrong" side. This would have side effects only where there are actual exits on the "wrong" side.

Last edited 3 years ago by mvglasow (2) (previous) (diff)

comment:49 Changed 3 years ago by mvglasow (2)

r5935 fixes the Werder_W test case.

comment:50 Changed 3 years ago by mvglasow (2)

On Nuernberg_N and ramps on the "wrong" side: It seems Navit does not know what side of the road a particular territory drives on. The code that generates the appropriate roundabout icons uses the direction of the roundabout itself to tell if we go around it clockwise or counterclockwise.

Another idea I had was analyzing the number of lanes: Both at Hamburg_Sued_S and at Nuernberg_N the ramps have two lanes. Note that busy stretches of motorway in urban areas may occasionally have exits with 2 lanes (e.g. A9 just north of Munich), thus some more magic is required. A rule that might give us quite good accuracy would be "if the ramp has at least 2 lanes and at least as many as the motorway, assume an interchange".

The only problem is that, for all I can tell, Navit currently does not have any information on lanes in its binfile maps.

Thus, in order to solve those two cases, we'd need to

  • introduce an attribute for the number of lanes
  • adapt maptool to process the lanes=* tag in OSM data
  • implement the above logic

To get an announcement, one would need to use a map generated with an updated version of maptool.

comment:51 Changed 3 years ago by jandegr

Is it something like this what the above posts are about ?https://dl.dropboxusercontent.com/u/93775123/Navit/Capture10.JPG

Last edited 3 years ago by jandegr (previous) (diff)

comment:52 Changed 3 years ago by mvglasow (2)

I assume you mean this one: http://www.openstreetmap.org/node/271855166#map=14&layers=Q

Yes, this is the kind of problematic interchange that I meant.

As long as the route takes you on the ramp, everything's fine (current SVN can easily detect that this maneuver needs to be announced because the route goes from motorway to ramp).

However, in many (if not all) situations it is desirable to have an announcement for the main lane as well – and here lanes are our best guess.

Note: See TracTickets for help on using tickets.