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

Vehicles unable to choose lanes when u-turn at dead-end #101

Closed
originalfoo opened this issue Feb 21, 2019 · 23 comments
Closed

Vehicles unable to choose lanes when u-turn at dead-end #101

originalfoo opened this issue Feb 21, 2019 · 23 comments
Assignees
Labels
confirmed Represents confirmed issue or bug PATHFINDER Pathfinding tweaks or issues
Milestone

Comments

@originalfoo
Copy link
Member

While testing #85 (comment) I discovered following...

When vehicle u-turns at dead-end (cul-de-sac) of road, it's only able to choose innermost lane.

This means it cannot reach buildings on the outermost lane of the segment where it did u-turn.

I'm currently testing mod settings (policies tab) to see if they make a different (allow lane change, allow u-turn).

@originalfoo
Copy link
Member Author

Changing mod options did not appear to alter the situation in any notable way.

Problem segment:

dead end

Flour mill struggling to get deliveries:

mill

I have just seen a truck deliver to mill, but it took some time for it to happen.

Maybe it's down to pseudo-random lane changing at nodes? So sometimes, rarely, a truck might choose the outer lane after u-turn?

@pcfantasy
Copy link
Contributor

@aubergine10

Yes, there is logic that u-turns only able to choose innermost lane.

Do you want to update this in some certain cases? I can help.

@originalfoo
Copy link
Member Author

Yes, specifically at end of dead-end roads like shown above. I guess in that specific situation, vehicles from any lane should be able to u-turn in to any of the lanes in opposite direction. It's only at dead-end roads though. I assume there might be a node or segment flag that can be used to identify them (see https://cslmodding.info/asset/network/#flags )

@pcfantasy
Copy link
Contributor

@aubergine10

I know, there is a OneWayOut flag in the segment or node to identify this case.

@originalfoo
Copy link
Member Author

I would do some testing first though, to check it is a valid problem. Like I say, I've seen occasional truck able to make delivery to the flour mill, but they seem few and far between.

@pcfantasy
Copy link
Contributor

pcfantasy commented Feb 22, 2019

@aubergine10

Can you try to modify blow logic and check if this issue will be solved

CustomPathFind2.cs

bool relaxedLaneRouting =
m_isRoadVehicle &&
((!m_queueItem.spawned || (m_queueItem.vehicleType & (ExtVehicleType.PublicTransport | ExtVehicleType.Emergency)) != ExtVehicleType.None) &&
(laneTransitions[k].laneId == m_startLaneA || laneTransitions[k].laneId == m_startLaneB)) || isStockUturnPoint;

@originalfoo
Copy link
Member Author

I will try.

While I do that, you might also want to investigate this potentially related issue: #85 (comment)

@originalfoo
Copy link
Member Author

It's complaining that isStockUturnPoint is undefined.

What code do I need to add to define the isStockUturnPoint?

@pcfantasy
Copy link
Contributor

@aubergine10

OK, isStockUturnPoint is in another if else, so you need to define it again
bool isStockUturnPoint = (nextNode.m_flags & (NetNode.Flags.End | NetNode.Flags.OneWayOut)) != NetNode.Flags.None;

@originalfoo
Copy link
Member Author

Ok, and that goes just above the other code you mentioned above?

Also, what is difference between CustomPathFind.cs and CustomPathFind2.cs?

@pcfantasy
Copy link
Contributor

@aubergine10

CustomPathFind.cs is useless now, you can see in the compile, TMPE is define as use FP2.

@originalfoo
Copy link
Member Author

Ok, I tested with the code changes and I see more vehicles choosing the outer lane at the u-turn near the flour mill.

However, there is still this issue where u-turns (if allowed at the junction) limit to the innermost lane at normal junctions. I would suggest in that situation, we either allow similar flexibility by default or require that "can change junctions when going straight ahead" also be enabled (for that junction) in order to get that flexibility. What do you think?

@pcfantasy
Copy link
Contributor

@aubergine10

we can use lane connector to allow vehicle to do u-turn from innermost lane to outerlane

If you mean vehicle can start u-turn at outerlane in normal junction, that is not real, because there are left turn car in innermost, u-turn car start u-turn at outerlane will confict with left turn car in innermost

@originalfoo
Copy link
Member Author

At normal junction, vehicle can only start u-turn from innermost lane, but should have at least some flexibility over which lane in turns in to as it leaves the u-turn. Currently it's limited to turning in to the innermost lane as it leaves the u-turn.

It's only at dead-ends (cul-de-sac) where vehicle can start the u-turn from any lane and leave the u-turn on any lane. The code you posted above seems to deal with this scenario very well and hopefully solves some of our pathfinding problems.

@originalfoo originalfoo added BUG Defect detected in-progress The problem is being solved currently labels Feb 22, 2019
@pcfantasy
Copy link
Contributor

@aubergine10

OK, I know your requirement now and I am familiar with these codes which related to this function, I will check these codes and give you feedback later.

@pcfantasy
Copy link
Contributor

@aubergine10

I checked the code, I think "u-turn from innermost lane and to any lane" is allowed in any junction, but this change from innermost lane to outer lane will give addition cost in TMPE logic, so vehicles will not select this path(unless the target innermost lane is congestion, this case is very rare).

You can try to build a building near the junction, disable right turn & straight & left turn path to this building(by laneconnector), only U-turn can reach this building(also, you need a 4-lane road). I think in this case, vehicles will do u-turn from innermost to outer lane and enter this building.

@originalfoo
Copy link
Member Author

Ok, I will do some more testing to see if that happens.

Is there a way to determine, when path finding, if the current segment is the first segment or the destination segment? If so, the relaxedLaneRouting could be enabled in those two cases, ensuring that vehicles can cross bus lanes when starting their journey or arriving at destination?

@pcfantasy
Copy link
Contributor

relaxedLaneRouting is now enable when starting journey

You see m_startLaneA and m_startLaneB.

But we can not let it enable when arriving, othewise in the final part, vehicles will ignore all the rules and go to the target.

bool relaxedLaneRouting =
m_isRoadVehicle &&
((!m_queueItem.spawned || (m_queueItem.vehicleType & (ExtVehicleType.PublicTransport | ExtVehicleType.Emergency)) != ExtVehicleType.None) &&
(laneTransitions[k].laneId == m_startLaneA || laneTransitions[k].laneId == m_startLaneB)) || isStockUturnPoint;

@originalfoo
Copy link
Member Author

Ah, I was assuming the 'start lane' thing was iterating lanes of current segment.

What's the difference between lane A and B?

Also, seeing a it's been about 15 years since I last did any real coding, can you check that I've understood the above code correctly..

relaxedLaneRouting =
    (
        road vehicle
        and
        ( not spawned or (public transport or emergency) )
        and
        initial segment
    )
    or
    stock turn point

Regarding the stock turn point stuff, I'm going to do some testing to see if that's given any improvement on #86...

@pcfantasy
Copy link
Contributor

@aubergine10

Seems in vannila codes, for cars, only startlaneA is used. I do not know what is the effort for startlaneB

And your understanding is 100% correct.

@originalfoo
Copy link
Member Author

originalfoo commented Feb 22, 2019

It looks like this solved bug #86 :) When road deleted, nearby vehicles aren't despawning any more (I need to do more testing to be sure).

EDIT: Confirmed - it fixes #86 as well!! :D

@originalfoo
Copy link
Member Author

Fixed in PR #104

Thanks @pcfantasy for the fix!

@VictorPhilipp VictorPhilipp self-assigned this Mar 14, 2019
@VictorPhilipp
Copy link
Collaborator

Fix was erroneous. A new fix which was implemented for #112 is upcoming for version 1.10.7

@VictorPhilipp VictorPhilipp reopened this Mar 14, 2019
@VictorPhilipp VictorPhilipp modified the milestones: 1.10.16, 1.10.17 Mar 14, 2019
@VictorPhilipp VictorPhilipp added confirmed Represents confirmed issue or bug and removed BUG Defect detected labels Mar 14, 2019
@VictorPhilipp VictorPhilipp removed the in-progress The problem is being solved currently label Mar 16, 2019
@originalfoo originalfoo added the PATHFINDER Pathfinding tweaks or issues label Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed Represents confirmed issue or bug PATHFINDER Pathfinding tweaks or issues
Projects
None yet
Development

No branches or pull requests

3 participants