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

add permissive movement to allowed #2373

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

adev4a
Copy link
Contributor

@adev4a adev4a commented Apr 30, 2024

PR Details

This PR adds Permissive movements to the lci strategic plugin planning logic. It extends the functionality for protected movements to permissive movements as well.

Description

During voices integration testing it was found that SPAT messages published by the virtual econolite controller were being published with the permissive movement type.

Related GitHub Issue

Related Jira Key

Motivation and Context

How Has This Been Tested?

Types of changes

  • Defect fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that cause existing functionality to change)

Checklist:

  • I have added any new packages to the sonar-scanner.properties file
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@adev4a adev4a requested a review from MishkaMN May 1, 2024 13:55
Comment on lines 328 to 329
can_make_early_arrival = ((early_arrival_state_by_algo_optional.get().second == lanelet::CarmaTrafficSignalState::PROTECTED_MOVEMENT_ALLOWED)
|| (early_arrival_state_by_algo_optional.get().second == lanelet::CarmaTrafficSignalState::PERMISSIVE_MOVEMENT_ALLOWED));
Copy link
Contributor

Choose a reason for hiding this comment

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

All of the OR or AND conditions added in this PR can be made concise by using helper function called
isAllowedMovement where

bool isAllowedMovement(const lanelet::CarmaTrafficSignalState& state) {
    return state == lanelet::CarmaTrafficSignalState::PROTECTED_MOVEMENT_ALLOWED ||
           state == lanelet::CarmaTrafficSignalState::PERMISSIVE_MOVEMENT_ALLOWED;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Same goes for isClearanceMovement() function and add the permissive clearance to supported signals as well

@@ -369,15 +369,20 @@ std::tuple<rclcpp::Time, bool, bool> LCIStrategicPlugin::get_final_entry_time_an
RCLCPP_DEBUG_STREAM(rclcpp::get_logger("lci_strategic_plugin"), "normal_arrival_signal_end_time: " << std::to_string(lanelet::time::toSec(normal_arrival_state_green_et_optional.get().first)));

// nearest_green_signal_start_time = normal_arrival_signal_end_time (green guaranteed) - green_signal_duration
nearest_green_signal_start_time = rclcpp::Time(lanelet::time::toSec(normal_arrival_state_green_et_optional.get().first - traffic_light->signal_durations[lanelet::CarmaTrafficSignalState::PROTECTED_MOVEMENT_ALLOWED]) * 1e9);
if(traffic_light->signal_durations[lanelet::CarmaTrafficSignalState::PROTECTED_MOVEMENT_ALLOWED]){
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we create a helper function like getAllowedState(const lanelet::CarmaTrafficSignalPtr& signal)
which can iterate over the available states and return correct "green" state from either of protected or permissive. Same applies to getClearanceState()
this way we don't need to create this if function, which is increasing the cognitive complexity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats a nice suggestion

Copy link
Contributor Author

@adev4a adev4a May 9, 2024

Choose a reason for hiding this comment

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

Just added this

@adev4a adev4a requested a review from MishkaMN May 10, 2024 14:14
@@ -251,6 +250,17 @@ rclcpp::Duration LCIStrategicPlugin::get_earliest_entry_time(double remaining_di

}

int LCIStrategicPlugin::getClearanceDuration(lanelet::CarmaTrafficSignalPtr traffic_light)
Copy link
Contributor

Choose a reason for hiding this comment

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

The name is little misleading as it is getting movement allowed durations not clearance

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.

2 participants