Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend roundabout phrases #2378

Merged
merged 17 commits into from
May 16, 2020
Merged

Extend roundabout phrases #2378

merged 17 commits into from
May 16, 2020

Conversation

dgearhart
Copy link
Member

@dgearhart dgearhart commented May 14, 2020

Issue

Extend roundabout phrase to include street names and toward signs.

Example#1

< Before
< 2: Enter the roundabout and take the 1st exit.
<    VERBAL_ALERT: Enter the roundabout and take the 1st exit.
<    VERBAL_PRE: Enter the roundabout and take the 1st exit.
> After
> 2: Enter the roundabout and take the 1st exit onto US 322/East Governor Road.
>    VERBAL_ALERT: Enter the roundabout and take the 1st exit onto U.S. 3 22.
>    VERBAL_PRE: Enter the roundabout and take the 1st exit onto U.S. 3 22, East Governor Road.

Example#2

image

< BEFORE
< 2: Enter the roundabout and take the 3rd exit. 
<    VERBAL_ALERT: Enter the roundabout and take the 3rd exit.
<    VERBAL_PRE: Enter the roundabout and take the 3rd exit.
> AFTER
> 2: Enter Dupont Circle Northwest and take the 3rd exit onto 19th Street Northwest. 
>    VERBAL_ALERT: Enter Dupont Circle Northwest and take the 3rd exit onto 19th Street Northwest.
>    VERBAL_PRE: Enter Dupont Circle Northwest and take the 3rd exit onto 19th Street Northwest.

Example#3

< BEFORE
< 2: Enter the roundabout and take the 3rd exit.
<    VERBAL_ALERT: Enter the roundabout and take the 3rd exit.
<    VERBAL_PRE: Enter the roundabout and take the 3rd exit.
< 3: Exit the roundabout onto Dhünner Straße/L 409.
<    VERBAL_PRE: Exit the roundabout onto Dhünner Straße, L 4 09. Then, in 200 feet, You will arrive at Dhünner Straße.
> AFTER
> 2: Enter the roundabout and take the 3rd exit toward A 1/Remscheid/Wermelskirchen.
>    VERBAL_ALERT: Enter the roundabout and take the 3rd exit toward A 1.
>    VERBAL_PRE: Enter the roundabout and take the 3rd exit toward A 1, Remscheid.
> 3: Exit the roundabout toward A 1/Remscheid/Wermelskirchen. 
>    VERBAL_PRE: Exit the roundabout toward A 1, Remscheid. Then, in 200 feet, You will arrive at Dhünner Straße.

Impacts 49% of routes

Tasklist

  • Add tests
  • Add #fixes with the issue number that this PR addresses
  • Generally use squash merge to rebase and clean comments before merging
  • Update the changelog

Added roundabout instructions gurka tests
Fixed street name assignemtn in the NarrativeBuilder::FormEnterRoundaboutInstruction method
…rbal phrase blocks.

Updated the narrative dictionary and builder for the new phrases.
Added named roundabout gurka tests.
@dgearhart dgearhart self-assigned this May 14, 2020
DirectionsLeg_Maneuver_Type_kDestination});
int maneuver_index = 1;

// TODO: known issue - future update to end on a roundabout
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What instruction is announced when you end on a roundabout now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has the ordinal exit value included

test/gurka/gurka.h Outdated Show resolved Hide resolved
* @param maneuver_index the specified maneuver index to inspect
* @param expected_instructions the set of four instructions expected in the DirectionsLeg for the
* route at specified maneuver index.
* The four instructions shall be in this order:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: how about using an unordered_map instead of a vector so that order doesn't matter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then the function call would have more clutter with it - looks nice and simple now:

  gurka::assert::raw::expect_instructions_at_maneuver_index(
      result, maneuver_index,
      {"Enter Dupont Circle and take the 1st exit toward A 95/B 2/München/Kürten.",
       "Enter Dupont Circle and take the 1st exit toward A 95.",
       "Enter Dupont Circle and take the 1st exit toward A 95, München.", ""});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downside of using a vector is that the caller needs to know/remember the order in which the items need to be put. Using a hashmap makes it a bit more explicit:

gurka::assert::raw::expect_instructions_at_maneuver_index(
    result, maneuver_index,
      {{"text", "Enter Dupont Circle and take the 1st exit toward A 95/B 2/München/Kürten."},
       {"verbal_transition", "Enter Dupont Circle and take the 1st exit toward A 95."},
       {"verbal_pre_transition", "Enter Dupont Circle and take the 1st exit toward A 95, München."},
       {"verbal_post_transition", ""}});

But I leave it to you. I guess its okay with vector too. We'll learn the order :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss Monday - we can add an issue to switch it if needed

Copy link
Contributor

@mandeepsandhu mandeepsandhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only minor comments. Approving it since I don't want to hold you up.

@@ -353,7 +353,21 @@
"enter_roundabout": {
"phrases": {
"0": "Enter thee Cap'n wheel.",
"1": "Enter thee Cap'n wheel and take th' <ORDINAL_VALUE> spoke."
"1": "Enter thee Cap'n wheel and take th' <ORDINAL_VALUE> spoke.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does ...-x-pirate mean?

Copy link
Member Author

@dgearhart dgearhart May 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non standard language extension - pirate language narrative FTW 🏴‍☠️

@@ -353,7 +353,21 @@
"enter_roundabout": {
"phrases": {
"0": "सर्कल प्रवेश करें.",
"1": "सर्कल प्रवेश करें और <ORDINAL_VALUE> निकास लें."
"1": "सर्कल प्रवेश करें और <ORDINAL_VALUE> निकास लें.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a comment for this PR, but this caught my eye - spelling out "circle" in Hindi seems a bit odd for roundabout. The colloquial term for traffic circle is "roundabout" (or "Gol Chakkra" in Hindi). Anyway, we dont need to change anything in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix anything that is incorrect

roundabout_exit_begin_street_names_ = std::move(roundabout_exit_begin_street_names);
}

bool Maneuver::HasRoundaboutExitBeginStreetNames() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this camel-case while the others snake-case? Looking at maneuver.h, it seems like only getters/setters use camel-case? I must say its a strange convention.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we started we followed the google spec - similar to how protobuf files are

const std::string& delim,
const VerbalTextFormatter* verbal_formatter) const {
std::string guide_string;
if (HasGuideBranch() && HasGuideToward() && ((max_count == 0) || (max_count > 1))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont follow the max_count check. Since its an unsigned int, it'll always be >0 or >1.

A slightly more concise version of what this function is doing:

std::string guide_string;
if (HasGuideBranch()) {
  guide_string += GetGuideBranchString(static_cast<uint32_t>(std::round(max_count / 2)),
                              limit_by_consecutive_count, delim, verbal_formatter);
  if (HasGuideToward())
    guide_string += delim;
}
if (HasGuideToward()) {
     guide_string +=
         GetGuideTowardString(max_count, limit_by_consecutive_count, delim, verbal_formatter);
 }

But you can leave it as-is too (except for maybe the max_count check?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_count == 0 means no limit
so this is checking if there is no limit or greater than one
we want to split the max_count between branch and toward

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the split, but not the need for the check (((max_count == 0) || (max_count > 1)) is always true). Also std::round isn't doing anything, since we're using integer division which will return an integer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A slightly more concise version of what this function is doing:

This is different functionality

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the split, but not the need for the check (((max_count == 0) || (max_count > 1)) is always true).

It is not true if max_count == 1
I was trying to be explicit about either unlimited count or greater than one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also std::round isn't doing anything, since we're using integer division which will return an integer.

@mandeepsandhu good catch - I will fix, thanks

* @param maneuver_index the specified maneuver index to inspect
* @param expected_instructions the set of four instructions expected in the DirectionsLeg for the
* route at specified maneuver index.
* The four instructions shall be in this order:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downside of using a vector is that the caller needs to know/remember the order in which the items need to be put. Using a hashmap makes it a bit more explicit:

gurka::assert::raw::expect_instructions_at_maneuver_index(
    result, maneuver_index,
      {{"text", "Enter Dupont Circle and take the 1st exit toward A 95/B 2/München/Kürten."},
       {"verbal_transition", "Enter Dupont Circle and take the 1st exit toward A 95."},
       {"verbal_pre_transition", "Enter Dupont Circle and take the 1st exit toward A 95, München."},
       {"verbal_post_transition", ""}});

But I leave it to you. I guess its okay with vector too. We'll learn the order :)

@dgearhart dgearhart merged commit b81aa89 into master May 16, 2020
@dgearhart dgearhart deleted the extend_roundabout_phrases branch May 16, 2020 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants