Take stop signs into account during routing
This commit is contained in:
parent
3558ec9db4
commit
4432756de1
@ -30,6 +30,7 @@ function setup()
|
|||||||
use_turn_restrictions = true,
|
use_turn_restrictions = true,
|
||||||
left_hand_driving = false,
|
left_hand_driving = false,
|
||||||
traffic_light_penalty = 2,
|
traffic_light_penalty = 2,
|
||||||
|
stop_sign_penalty = 2
|
||||||
},
|
},
|
||||||
|
|
||||||
default_mode = mode.driving,
|
default_mode = mode.driving,
|
||||||
@ -481,8 +482,7 @@ function process_turn(profile, turn)
|
|||||||
if turn.has_traffic_light then
|
if turn.has_traffic_light then
|
||||||
turn.duration = profile.properties.traffic_light_penalty
|
turn.duration = profile.properties.traffic_light_penalty
|
||||||
elseif turn.has_stop_sign then
|
elseif turn.has_stop_sign then
|
||||||
-- TODO: use another constant
|
turn.duration = profile.properties.stop_sign_penalty
|
||||||
turn.duration = profile.properties.traffic_light_penalty
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,10 +9,10 @@ function TrafficSignal.get_value(node)
|
|||||||
local direction = node:get_value_by_key("traffic_signals:direction")
|
local direction = node:get_value_by_key("traffic_signals:direction")
|
||||||
if direction then
|
if direction then
|
||||||
if "forward" == direction then
|
if "forward" == direction then
|
||||||
return traffic_lights.direction_forward
|
return traffic_flow_control_direction.direction_forward
|
||||||
end
|
end
|
||||||
if "backward" == direction then
|
if "backward" == direction then
|
||||||
return traffic_lights.direction_reverse
|
return traffic_flow_control_direction.direction_reverse
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- return traffic_lights.direction_all
|
-- return traffic_lights.direction_all
|
||||||
|
@ -209,15 +209,26 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
|||||||
graph.GetEdgeData(reverse_e2).annotation_data = selectAnnotation(
|
graph.GetEdgeData(reverse_e2).annotation_data = selectAnnotation(
|
||||||
rev_edge_data2.annotation_data, rev_edge_data1.annotation_data);
|
rev_edge_data2.annotation_data, rev_edge_data1.annotation_data);
|
||||||
|
|
||||||
// Add node penalty when compress edge crosses a traffic signal
|
// Add node penalty when compress edge crosses a traffic signal/stop sign/give way
|
||||||
const bool has_forward_signal = traffic_signals.Has(node_u, node_v);
|
const bool has_forward_signal = traffic_signals.Has(node_u, node_v);
|
||||||
const bool has_reverse_signal = traffic_signals.Has(node_w, node_v);
|
const bool has_reverse_signal = traffic_signals.Has(node_w, node_v);
|
||||||
|
|
||||||
const bool has_forward_stop_sign = stop_signs.Has(node_u, node_v);
|
bool has_forward_stop_sign = stop_signs.Has(node_u, node_v);
|
||||||
const bool has_reverse_stop_sign = stop_signs.Has(node_w, node_v);
|
bool has_reverse_stop_sign = stop_signs.Has(node_w, node_v);
|
||||||
|
|
||||||
|
// we apply penalty for only one of the control flow nodes
|
||||||
|
if (has_forward_stop_sign && has_forward_signal) {
|
||||||
|
has_forward_stop_sign = false;
|
||||||
|
util::Log(logWARNING) << "Node " << node_v
|
||||||
|
<< " has both a traffic signal and a stop sign";
|
||||||
|
}
|
||||||
|
if (has_reverse_stop_sign && has_reverse_signal) {
|
||||||
|
has_forward_stop_sign = false;
|
||||||
|
util::Log(logWARNING) << "Node " << node_v
|
||||||
|
<< " has both a traffic signal and a stop sign";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: can we have a case when we have both traffic signal and stop sign? how
|
|
||||||
// should we handle it?
|
|
||||||
EdgeDuration forward_node_duration_penalty = MAXIMAL_EDGE_DURATION;
|
EdgeDuration forward_node_duration_penalty = MAXIMAL_EDGE_DURATION;
|
||||||
EdgeWeight forward_node_weight_penalty = INVALID_EDGE_WEIGHT;
|
EdgeWeight forward_node_weight_penalty = INVALID_EDGE_WEIGHT;
|
||||||
EdgeDuration reverse_node_duration_penalty = MAXIMAL_EDGE_DURATION;
|
EdgeDuration reverse_node_duration_penalty = MAXIMAL_EDGE_DURATION;
|
||||||
@ -260,22 +271,14 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
|||||||
roads_on_the_left);
|
roads_on_the_left);
|
||||||
scripting_environment.ProcessTurn(extraction_turn);
|
scripting_environment.ProcessTurn(extraction_turn);
|
||||||
|
|
||||||
std::cerr << "HAS STOP SIGN = " << extraction_turn.has_stop_sign << " "
|
|
||||||
<< extraction_turn.duration << std::endl;
|
|
||||||
|
|
||||||
auto update_direction_penalty =
|
auto update_direction_penalty =
|
||||||
[&extraction_turn, weight_multiplier](bool signal,
|
[&extraction_turn, weight_multiplier](bool has_traffic_control_node,
|
||||||
EdgeDuration &duration_penalty,
|
EdgeDuration &duration_penalty,
|
||||||
EdgeWeight &weight_penalty) {
|
EdgeWeight &weight_penalty) {
|
||||||
if (signal)
|
if (has_traffic_control_node)
|
||||||
{
|
{
|
||||||
std::cerr << "DUR = " << extraction_turn.duration
|
|
||||||
<< " WEIGHT = " << extraction_turn.weight << std::endl;
|
|
||||||
duration_penalty = extraction_turn.duration * SECOND_TO_DECISECOND;
|
duration_penalty = extraction_turn.duration * SECOND_TO_DECISECOND;
|
||||||
weight_penalty = extraction_turn.weight * weight_multiplier;
|
weight_penalty = extraction_turn.weight * weight_multiplier;
|
||||||
|
|
||||||
std::cerr << "DUR = " << duration_penalty
|
|
||||||
<< " WEIGHT = " << weight_penalty << std::endl;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1147,16 +1147,12 @@ void Sol2ScriptingEnvironment::ProcessTurn(ExtractionTurn &turn)
|
|||||||
case 2:
|
case 2:
|
||||||
if (context.has_turn_penalty_function)
|
if (context.has_turn_penalty_function)
|
||||||
{
|
{
|
||||||
std::cerr << "GOT TURN " << turn.has_stop_sign << " " << turn.has_traffic_light
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
context.turn_function(context.profile_table, std::ref(turn));
|
context.turn_function(context.profile_table, std::ref(turn));
|
||||||
|
|
||||||
// Turn weight falls back to the duration value in deciseconds
|
// Turn weight falls back to the duration value in deciseconds
|
||||||
// or uses the extracted unit-less weight value
|
// or uses the extracted unit-less weight value
|
||||||
if (context.properties.fallback_to_duration)
|
if (context.properties.fallback_to_duration)
|
||||||
{
|
{
|
||||||
std::cerr << "FALLBACK\n";
|
|
||||||
turn.weight = turn.duration;
|
turn.weight = turn.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1164,7 +1160,6 @@ void Sol2ScriptingEnvironment::ProcessTurn(ExtractionTurn &turn)
|
|||||||
{
|
{
|
||||||
// cap turn weight to max turn weight, which depend on weight precision
|
// cap turn weight to max turn weight, which depend on weight precision
|
||||||
turn.weight = std::min(turn.weight, context.properties.GetMaxTurnWeight());
|
turn.weight = std::min(turn.weight, context.properties.GetMaxTurnWeight());
|
||||||
std::cerr << "NO FALLBACK " << turn.weight << " " << turn.duration << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user