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

changing lane #1

Open
arvindshekar07 opened this issue Aug 27, 2017 · 0 comments
Open

changing lane #1

arvindshekar07 opened this issue Aug 27, 2017 · 0 comments

Comments

@arvindshekar07
Copy link
Owner

changing lane to be added in the code.
at line 277 to 282

if (too_close) {
   //try and change lanes
  bool canMergeLeft = lane > 0;
  bool canMergeRight = lane < 2;
  //try merging left
  int ref_lane = lane - 1;
  if (canMergeLeft && d < (2+4*ref_lane+2) && d > (2+4*ref_lane-2)) {
          if (abs(check_car_s - car_s) < 20) {
              canMergeLeft = false;
          }
  } 

   //try merging right
  ref_lane = lane + 1;
  if (canMergeRight && d < (2+4*ref_lane+2) && d > (2+4*ref_lane-2)) {
      if (abs(check_car_s - car_s) < 20) {
           canMergeRight = false;
      }
}
}
if (canMergeLeft) {
  lane--;
} else if (canMergeRight) {
  lane++;
  }
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

No branches or pull requests

1 participant