[Navigation] Unnecessary SlightTurn directions in some situations #2262

Closed
opened 2022-03-18 09:04:32 +00:00 by AntonM030481 · 17 comments
AntonM030481 commented 2022-03-18 09:04:32 +00:00 (Migrated from github.com)

For some reason I have notification 'Keep left' here, moving by main road to cross-road.
Take a note that this is Cyprus (left-side driving).
In fact a lot such kind of notifications can be heard.
Maybe this is somehow related to the fact that most of roads in Cyprus are not straight.

image

https://omaps.app/4yxfvno7P6/Strovolou_Avenue
om://4yxfvno7P6/Strovolou_Avenue

For some reason I have notification 'Keep left' here, moving by main road to cross-road. Take a note that this is Cyprus (left-side driving). In fact a lot such kind of notifications can be heard. Maybe this is somehow related to the fact that most of roads in Cyprus are not straight. <img width="414" alt="image" src="https://user-images.githubusercontent.com/85622715/158972165-7ec4fd46-cbb3-4bd8-ab24-cc58f41f600e.png"> https://omaps.app/4yxfvno7P6/Strovolou_Avenue om://4yxfvno7P6/Strovolou_Avenue
CorruptComputer commented 2022-03-18 14:51:53 +00:00 (Migrated from github.com)

I think this is a duplicate of #2238

I think this is a duplicate of #2238
AntonM030481 commented 2022-03-18 16:49:08 +00:00 (Migrated from github.com)
Agree. Very similar one. Route: https://www.openstreetmap.org/directions?engine=fossgis_osrm_car&route=35.14404%2C33.34396%3B35.14498%2C33.34465
AntonM030481 commented 2022-03-18 17:23:25 +00:00 (Migrated from github.com)

My suggestion is to not voice if:
all roads except 1 deviate more then (90 - alpha) degrees from current direction
and 1 road deviates less then (alpha) degrees from current direction

if there is 1 main road road we increase alpha trying to follow main road.
E.g. for alpha = 10

2 equal roads angles:
5, 85 - no voice.
5, 75! - voice
15!, 85 - voice

2 roads. first primary. alpha increase to 20 trying to follow main road
15, 75 - no voice
25!, 75 - voice
15, 65! - voice
75!, 5 - voice
85, 15! - voice

Edit:
Voice = directions

My suggestion is to not voice if: all roads except 1 deviate more then (90 - alpha) degrees from current direction and 1 road deviates less then (alpha) degrees from current direction if there is 1 main road road we increase alpha trying to follow main road. E.g. for alpha = 10 2 equal roads angles: 5, 85 - no voice. 5, 75! - voice 15!, 85 - voice 2 roads. first primary. alpha increase to 20 trying to follow main road 15, 75 - no voice 25!, 75 - voice 15, 65! - voice 75!, 5 - voice 85, 15! - voice Edit: Voice = directions
biodranik commented 2022-03-20 22:45:03 +00:00 (Migrated from github.com)

The problem is not in the voice but in the underlying directions. There are some unnecessary directions inserted by the algorithm. More examples where other routers don't have unnecessary turns, but OM has them, will be helpful.

Announcing a turn on the main road with clearly visible secondary roads is completely unnecessary, right? If there are no directions, then it means "continue forward on the current road", right?

The problem is not in the voice but in the underlying directions. There are some unnecessary directions inserted by the algorithm. More examples where other routers don't have unnecessary turns, but OM has them, will be helpful. Announcing a turn on the main road with clearly visible secondary roads is completely unnecessary, right? If there are no directions, then it means "continue forward on the current road", right?
AntonM030481 commented 2022-03-21 20:15:20 +00:00 (Migrated from github.com)

Exactly!

Exactly!
AntonM030481 commented 2022-03-24 12:05:58 +00:00 (Migrated from github.com)

Is it correct that white arrows - directions points? If so it's I can easily provide a lot of examples.
image
From:
https://omaps.app/0yxfvyMryq/ΚΑΠΕΚΛΟΠΟΙΕΙΟΝ_ΦΥΛΑΚΤΟΥ
To:
https://omaps.app/0yxfvwODtI/Longou

Is it correct that white arrows - directions points? If so it's I can easily provide a lot of examples. ![image](https://user-images.githubusercontent.com/85622715/159912060-da61b6ae-109a-4486-9e4f-b917254c6e82.jpeg) From: https://omaps.app/0yxfvyMryq/ΚΑΠΕΚΛΟΠΟΙΕΙΟΝ_ΦΥΛΑΚΤΟΥ To: https://omaps.app/0yxfvwODtI/Longou
AntonM030481 commented 2022-03-24 12:29:47 +00:00 (Migrated from github.com)
Another example: ![image](https://user-images.githubusercontent.com/85622715/159916410-4b81d58f-2c17-4eb9-a797-0874d402ba85.jpeg) From: https://omaps.app/0yxfvN4NFs/ To: https://omaps.app/0yxfvllmin/
biodranik commented 2022-03-24 19:50:25 +00:00 (Migrated from github.com)

Is it correct that white arrows - directions points? If so it's I can easily provide a lot of examples.

Correct, thanks!

> Is it correct that white arrows - directions points? If so it's I can easily provide a lot of examples. Correct, thanks!
AntonM030481 commented 2022-03-24 22:48:22 +00:00 (Migrated from github.com)

Can you explain current algorithm of determination of directions?
Looks like it is now:

for all intersections:
 if abs(path change angle) > alpha:
  direction = true
 else:
  direction = false
Can you explain current algorithm of determination of directions? Looks like it is now: ``` for all intersections: if abs(path change angle) > alpha: direction = true else: direction = false ```
AntonM030481 commented 2022-04-13 17:20:30 +00:00 (Migrated from github.com)

I checked the code for function GetTurnDirection.
It uses the function KeepTurnByHighwayClass
I have created function KeepTurnByAlignedAlternatives using the same design and tested it. It fixed most of issues for me.

/// * \returns true when
/// * - any alternative turn to bigger road
/// * - or any alternative turn to similar road if turns less then 70 degress (wider than SlightTurn)
/// * - or any alternative turn to smaller road if turns less than SlightTurn
/// * Returns false otherwise.
/// \param possibleTurns is all possible ways out from a junction.
/// \param turnInfo is information about ingoing and outgoing segments of the route.
bool KeepTurnByAlignedAlternatives(TurnCandidates const & possibleTurns, TurnInfo const & turnInfo,
                           NumMwmIds const & numMwmIds)
{
  // Note. The bigger road the less HighwayClass value.
  ftypes::HighwayClass outgoingRouteRoadClass = turnInfo.m_outgoing.m_highwayClass;

  // The turn should be kept if there's no any information about feature id of outgoing segment
  // just to be on the safe side. It may happen in case of outgoing segment is a finish segment.
  Segment firstOutgoingSegment;
  if (!turnInfo.m_outgoing.m_segmentRange.GetFirstSegment(numMwmIds, firstOutgoingSegment))
    return true;

  Segment inversedLastIngoingSegment;
  if (!turnInfo.m_ingoing.m_segmentRange.GetLastSegment(numMwmIds, inversedLastIngoingSegment))
    return true;
  inversedLastIngoingSegment.Inverse();

  for (auto const & t : possibleTurns.candidates)
  {
    // Let's consider all outgoing segments except for
    // (1) route outgoing segment
    // (2) a U-turn segment (inversedLastIngoingSegment)
    if (t.m_segment == firstOutgoingSegment || t.m_segment == inversedLastIngoingSegment)
      continue;
    ftypes::HighwayClass const highwayClass = t.m_highwayClass;
    // Note. The bigger road the less HighwayClass value.
    if (static_cast<int>(highwayClass) < static_cast<int>(outgoingRouteRoadClass))
    {
      // any alternative turn to bigger road causes keep turn
      return true;
    }
    else if (static_cast<int>(highwayClass) == static_cast<int>(outgoingRouteRoadClass))
    {
      // any alternative turn to similar road causes keep turn if turns less then 70 degress (wider than SlightTurn)
      if (fabs(t.m_angle) < 70)
        return true;
    }
    else
    {
      // any alternative turn to smaller road causes keep turn if turns less than SlightTurn
      if (IsGoStraightOrSlightTurn(IntermediateDirection(t.m_angle)))
        return true;
    }
  }
  return false;
}
I checked the code for function **GetTurnDirection**. It uses the function **KeepTurnByHighwayClass** I have created function **KeepTurnByAlignedAlternatives** using the same design and tested it. It fixed most of issues for me. ``` /// * \returns true when /// * - any alternative turn to bigger road /// * - or any alternative turn to similar road if turns less then 70 degress (wider than SlightTurn) /// * - or any alternative turn to smaller road if turns less than SlightTurn /// * Returns false otherwise. /// \param possibleTurns is all possible ways out from a junction. /// \param turnInfo is information about ingoing and outgoing segments of the route. bool KeepTurnByAlignedAlternatives(TurnCandidates const & possibleTurns, TurnInfo const & turnInfo, NumMwmIds const & numMwmIds) { // Note. The bigger road the less HighwayClass value. ftypes::HighwayClass outgoingRouteRoadClass = turnInfo.m_outgoing.m_highwayClass; // The turn should be kept if there's no any information about feature id of outgoing segment // just to be on the safe side. It may happen in case of outgoing segment is a finish segment. Segment firstOutgoingSegment; if (!turnInfo.m_outgoing.m_segmentRange.GetFirstSegment(numMwmIds, firstOutgoingSegment)) return true; Segment inversedLastIngoingSegment; if (!turnInfo.m_ingoing.m_segmentRange.GetLastSegment(numMwmIds, inversedLastIngoingSegment)) return true; inversedLastIngoingSegment.Inverse(); for (auto const & t : possibleTurns.candidates) { // Let's consider all outgoing segments except for // (1) route outgoing segment // (2) a U-turn segment (inversedLastIngoingSegment) if (t.m_segment == firstOutgoingSegment || t.m_segment == inversedLastIngoingSegment) continue; ftypes::HighwayClass const highwayClass = t.m_highwayClass; // Note. The bigger road the less HighwayClass value. if (static_cast<int>(highwayClass) < static_cast<int>(outgoingRouteRoadClass)) { // any alternative turn to bigger road causes keep turn return true; } else if (static_cast<int>(highwayClass) == static_cast<int>(outgoingRouteRoadClass)) { // any alternative turn to similar road causes keep turn if turns less then 70 degress (wider than SlightTurn) if (fabs(t.m_angle) < 70) return true; } else { // any alternative turn to smaller road causes keep turn if turns less than SlightTurn if (IsGoStraightOrSlightTurn(IntermediateDirection(t.m_angle))) return true; } } return false; } ```
biodranik commented 2022-04-14 00:08:23 +00:00 (Migrated from github.com)

Awesome! What cases are still not detected properly?

CC @vng

Awesome! What cases are still not detected properly? CC @vng
vng commented 2022-04-14 06:54:35 +00:00 (Migrated from github.com)

@AntonM030481 Please, make a PR with your changes.

@AntonM030481 Please, make a PR with your changes.
AntonM030481 commented 2022-04-14 07:02:26 +00:00 (Migrated from github.com)

In fact it solved all my simple cases with unnecessary SlightTurns. Compare:
image image

In fact it solved all my simple cases with unnecessary SlightTurns. Compare: <img width="455" alt="image" src="https://user-images.githubusercontent.com/85622715/163331347-6856830b-ad64-4802-b23b-2a48a90e4ad1.png"> <img width="408" alt="image" src="https://user-images.githubusercontent.com/85622715/163330863-3664149e-ca22-4a5d-b8be-cec40f0aa4fb.png">
AntonM030481 commented 2022-04-14 07:34:20 +00:00 (Migrated from github.com)

BTW this helped me to identify road mapping issues.
E.g. here turn is kept, because of allowance of going back using the primary road link.
The question is only about TurnSlightLeft direction.
Maybe we need to convert it to GoStraight if all alternatives turn more then 90 degress:
image

This is more tricky one. Let's agree that direction is still needed here.
But TurnSlightLeft is questionable again.
Maybe we need to convert it to GoStraight if all alternatives turn more then current turn in the same direction:
image

BTW this helped me to identify road mapping issues. E.g. here turn is kept, because of allowance of going back using the primary road link. The question is only about TurnSlightLeft direction. Maybe we need to convert it to GoStraight if all alternatives turn more then 90 degress: <img width="808" alt="image" src="https://user-images.githubusercontent.com/85622715/163334447-5c0a6b80-b927-439a-9980-2a12bb83d61d.png"> This is more tricky one. Let's agree that direction is still needed here. But TurnSlightLeft is questionable again. Maybe we need to convert it to GoStraight if all alternatives turn more then current turn in the same direction: <img width="811" alt="image" src="https://user-images.githubusercontent.com/85622715/163335771-b92607f3-a81f-48fb-bdde-1c53fcb1aa93.png">
biodranik commented 2022-04-14 11:54:41 +00:00 (Migrated from github.com)

Probably "go straight" is a good option.
Alternatively, using Keep Left in the first one would be safer for drivers if there is an alternative right turn/U-turn (the idea is to avoid a wrong right turn). In the second example, the current instruction is obviously a bug, the proper instruction should be Keep Right, not Left, to avoid the obviously incorrect left turn/link. Keep Straight would also be ok.

Probably "go straight" is a good option. Alternatively, using Keep Left in the first one would be safer for drivers if there is an alternative right turn/U-turn (the idea is to avoid a wrong right turn). In the second example, the current instruction is obviously a bug, the proper instruction should be Keep **Right**, not Left, to avoid the obviously incorrect left turn/link. *Keep Straight* would also be ok.
biodranik commented 2022-04-14 11:55:23 +00:00 (Migrated from github.com)

In any case, your current implementation is better than the existing one. Let's check it in reality. Can you please create a PR?

In any case, your current implementation is better than the existing one. Let's check it in reality. Can you please create a PR?
AntonM030481 commented 2022-04-14 15:11:30 +00:00 (Migrated from github.com)

In any case, your current implementation is better than the existing one. Let's check it in reality. Can you please create a PR?

Sure. This is my 1st pull request to GitHub, so it's a bit challenging :)
#2397

> In any case, your current implementation is better than the existing one. Let's check it in reality. Can you please create a PR? Sure. This is my 1st pull request to GitHub, so it's a bit challenging :) #2397
This repo is archived. You cannot comment on issues.
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: organicmaps/organicmaps-tmp#2262
No description provided.