maliput
|
Provides the state of Right-Of-Way api::rules::DiscreteValueRule instances based on the current api::rules::Phase.
The states of the rules that govern an intersection are organized into phases. Each phase typically assigns different states to each rule to ensure intersection safety and fairness. For example, given an intersection between streets A and B governed by Rule_A and Rule_B, respectively, two phases are necessary:
Phase | Rule_A State | Rule_B State |
---|---|---|
1 | Go | Stop |
2 | Stop | Go |
The rules above will ensure vehicles traveling on Street A do not collide with vehicles traveling on Street B and vice versa.
This state provider also acts as a ManualDiscreteValueRuleStateProvider, but it overrides the behavior for Right-Of-Way rules with the aforementioned one. At build time, it is expected that the loader calls ManualDiscreteValueRuleStateProvider::SetState() for those non Right-Of-Way rules that are part of the RoadRulebook.
#include <include/maliput/base/phased_discrete_rule_state_provider.h>
Public Member Functions | |
PhasedDiscreteRuleStateProvider (const api::rules::RoadRulebook *rulebook, const api::rules::PhaseRingBook *phase_ring_book, const api::rules::PhaseProvider *phase_provider) | |
Constructs a PhasedDiscreteRuleStateProvider. More... | |
~PhasedDiscreteRuleStateProvider () final=default | |
const api::rules::PhaseRingBook & | phase_ring_book () const |
const api::rules::PhaseProvider & | phase_provider () const |
![]() | |
ManualDiscreteValueRuleStateProvider (const api::rules::RoadRulebook *rulebook) | |
Constructs a ManualDiscreteValueRuleStateProvider. More... | |
~ManualDiscreteValueRuleStateProvider () override=default | |
void | SetState (const api::rules::Rule::Id &id, const api::rules::DiscreteValueRule::DiscreteValue &state, const std::optional< api::rules::DiscreteValueRule::DiscreteValue > &next_state, const std::optional< double > &duration_until) |
Sets the state, and optionally the next state and duration until the next state, of a DiscreteValueRule. More... | |
![]() | |
virtual | ~DiscreteValueRuleStateProvider ()=default |
std::optional< StateResult > | GetState (const Rule::Id &id) const |
Gets the state of the DiscreteValueRule identified by id . More... | |
std::optional< StateResult > | GetState (const RoadPosition &road_position, const Rule::TypeId &rule_type, double tolerance) const |
Gets the state of the DiscreteValueRule that matches provided road_position and rule_type values according to certain tolerance . More... | |
Static Public Member Functions | |
static std::unique_ptr< PhasedDiscreteRuleStateProvider > | GetDefaultPhasedDiscreteRuleStateProvider (const maliput::api::rules::RoadRulebook *rulebook, const maliput::api::rules::PhaseRingBook *phase_ring_book, const maliput::api::rules::PhaseProvider *phase_provider) |
Constructs a PhasedDiscreteRuleStateProvider with the default states populated to be used when rules are not parte of a phase. More... | |
Additional Inherited Members | |
![]() | |
using | StateResult = StateProviderResult< DiscreteValueRule::DiscreteValue > |
The state of a DiscreteValueRule, returned by DiscreteValueRuleStateProvider::GetState(const Rule::Id&). More... | |
![]() | |
std::map< api::rules::DiscreteValueRule::Id, api::rules::DiscreteValueRule > | GetFilteredDiscreteValueRules (const api::RoadPosition &road_position, const api::rules::Rule::TypeId &rule_type, double tolerance) const |
![]() | |
DiscreteValueRuleStateProvider ()=default | |
![]() | |
const api::rules::RoadRulebook * | rulebook_ {nullptr} |
PhasedDiscreteRuleStateProvider | ( | const api::rules::RoadRulebook * | rulebook, |
const api::rules::PhaseRingBook * | phase_ring_book, | ||
const api::rules::PhaseProvider * | phase_provider | ||
) |
Constructs a PhasedDiscreteRuleStateProvider.
All pointer parameters are aliased; they must not be nullptr and their lifespans must exceed that of this instance.
common::assertion_error | When rulebook is nullptr. |
common::assertion_error | When phase_ring_book is nullptr. |
common::assertion_error | When phase_provider is nullptr. |
|
finaldefault |
|
static |
Constructs a PhasedDiscreteRuleStateProvider with the default states populated to be used when rules are not parte of a phase.
rulebook | The RoadRulebook to use. |
phase_ring_book | The PhaseRingBook to use. |
phase_provider | The PhaseProvider to use. |
maliput::common::assertion_error | When phase_ring_book is nullptr. |
const api::rules::PhaseProvider& phase_provider | ( | ) | const |
const api::rules::PhaseRingBook& phase_ring_book | ( | ) | const |