maliput
PhasedDiscreteRuleStateProvider Class Referencefinal

Detailed Description

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>

Inheritance diagram for PhasedDiscreteRuleStateProvider:
[legend]

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::PhaseRingBookphase_ring_book () const
 
const api::rules::PhaseProviderphase_provider () const
 
- Public Member Functions inherited from ManualDiscreteValueRuleStateProvider
 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...
 
- Public Member Functions inherited from DiscreteValueRuleStateProvider
virtual ~DiscreteValueRuleStateProvider ()=default
 
std::optional< StateResultGetState (const Rule::Id &id) const
 Gets the state of the DiscreteValueRule identified by id. More...
 
std::optional< StateResultGetState (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< PhasedDiscreteRuleStateProviderGetDefaultPhasedDiscreteRuleStateProvider (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

- Public Types inherited from DiscreteValueRuleStateProvider
using StateResult = StateProviderResult< DiscreteValueRule::DiscreteValue >
 The state of a DiscreteValueRule, returned by DiscreteValueRuleStateProvider::GetState(const Rule::Id&). More...
 
- Protected Member Functions inherited from ManualDiscreteValueRuleStateProvider
std::map< api::rules::DiscreteValueRule::Id, api::rules::DiscreteValueRuleGetFilteredDiscreteValueRules (const api::RoadPosition &road_position, const api::rules::Rule::TypeId &rule_type, double tolerance) const
 
- Protected Member Functions inherited from DiscreteValueRuleStateProvider
 DiscreteValueRuleStateProvider ()=default
 
- Protected Attributes inherited from ManualDiscreteValueRuleStateProvider
const api::rules::RoadRulebookrulebook_ {nullptr}
 

Constructor & Destructor Documentation

◆ PhasedDiscreteRuleStateProvider()

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.

Exceptions
common::assertion_errorWhen rulebook is nullptr.
common::assertion_errorWhen phase_ring_book is nullptr.
common::assertion_errorWhen phase_provider is nullptr.

◆ ~PhasedDiscreteRuleStateProvider()

Member Function Documentation

◆ GetDefaultPhasedDiscreteRuleStateProvider()

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 
)
static

Constructs a PhasedDiscreteRuleStateProvider with the default states populated to be used when rules are not parte of a phase.

Parameters
rulebookThe RoadRulebook to use.
phase_ring_bookThe PhaseRingBook to use.
phase_providerThe PhaseProvider to use.
Exceptions
maliput::common::assertion_errorWhen phase_ring_book is nullptr.

◆ phase_provider()

const api::rules::PhaseProvider& phase_provider ( ) const

◆ phase_ring_book()

const api::rules::PhaseRingBook& phase_ring_book ( ) const

The documentation for this class was generated from the following files: