ensemble.logic package¶
Submodules¶
ensemble.logic.frozen_set module¶
Frozen Set¶
This is a class describing a sorted frozen set. This is a collection implementation for a set of ordered elements that establish specific protocols for iteration, information access, element identification.
- class ensemble.logic.frozen_set.SortedFrozenSet(items=None, key='vehid')[source]¶
Bases:
collections.abc.Sequence
,collections.abc.Set
This is a collection that provides a set of properties to create a sorted frozen set.
In particular this is
- Parameters
Items (Iterable) – Inherits from the Sequence collection object.
Key (str) – Key to organize the vehicle platoon
ensemble.logic.platoon_set module¶
Platoon Set¶
This is a class describing a frozen set. This is a collection implementation for a set of ordered elements that establish specific protocols for iteration, information access, element identification.
- class ensemble.logic.platoon_set.PlatoonSet(items=None, key='x', id: int = - 1)[source]¶
Bases:
ensemble.logic.frozen_set.SortedFrozenSet
This is a collection that provides a set of properties to create a platoon frozen set.
In particular
- Parameters
Sequence (Sequence) – Inherits from the Sequence collection object.
Set (Set) – Inherits from the Set collection object.
- index(value[, start[, stop]]) integer -- return first index of value. [source]¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- pid = count(0)¶
ensemble.logic.platoon_states module¶
This module defines the basic states required to determine the status of a vehicle in a platoon formation
The states are defined as:
StandAlone: Vehicle not in a platoon formation
Joining: Vehicle willing to join a platoon or willing to create a platoon
Platooning: Vehicle inside a platoon formation
Split: Vehicle is willing to split from current platoon.
- class ensemble.logic.platoon_states.Cutin[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which declares the vehicle in a platoon functionality
Note
Transition: Cutin to Splitting
- class ensemble.logic.platoon_states.Joining[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which declares the vehicle in joining a platoon.
Note
Transition: Joining to StandAlone Transition: Joining to Platooning
- next_state(vgc: ensemble.metaclass.coordinator.AbsSingleGapCoord)[source]¶
Determines the switching condition for the state:
Note
Transition: Joining to StandAlone Transition: Joining to Platooning
- Parameters
truck (vehicle) – Platoon vehicle containing information of the ego vehicle.
- class ensemble.logic.platoon_states.Platooning[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which declares the vehicle in a platoon functionality
Note
Transition: Platooning to Splitting
- class ensemble.logic.platoon_states.Splitting[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which declares the vehicle splitting from platoon
Note
Transition: Splitting to StandAlone Transition: Splitting to Platooning
- class ensemble.logic.platoon_states.StandAlone[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which declares the vehicle in stand alone mode.
Note
Transition: StandAlone to Joining
- next_state(vgc: ensemble.metaclass.coordinator.AbsSingleGapCoord)[source]¶
Determines the switching condition for the state:
Note
Transition: StandAlone to Joining
- Parameters
truck (fgc) – Platoon vehicle containing information of the ego vehicle.
ensemble.logic.publisher module¶
Publisher¶
This module dedicates a generic object to generate a publisher pattern implementation responsible of specific methods.
- class ensemble.logic.publisher.Publisher(channels=('default',))[source]¶
Bases:
ensemble.metaclass.subject.AbsSubject
This generic class model implements a general publisher pattern to broadcast information towards different subscribers. Subscribers are intented to be objects such as vehicles or other objects that should be aware of the publisher.
In particular this creates a subject that can notify to a specific channel where subscribers are registered.
Example
Create a DataQuery for 2 type of channels,
automated
andregular
and perform a subscription>>> channels = ('auto','regular') >>> p = Publisher(channels) >>> s = Subscriber(p,'auto') # Registers a s into p
- attach(observer, channel: str, callback=None)[source]¶
Attach a new observer to a specific channel,, one can specify a method of the class to be called.
- Parameters
channel (str) – channel name
observer (observer) – observer object
callback (callable) – method to be executed when publisher notifies.
- property channels¶
- detach(observer, channel: str)[source]¶
Detach observer from the subject
- Parameters
channel (str) – channel name
observer (observer) – observer object
callback (callable) – method to be executed when publisher notifies.
ensemble.logic.runtime_machine module¶
Runtime Device¶
This module describes classes and objects to perform a runtime of a single scenario
ensemble.logic.runtime_states module¶
Runtime States¶
This module defines the basic states required to execute and launch a simulation.
The states are defined as:
Compliance: This state is defined to check availability of files and candidates.
Connect: This state is defined to process
Initialize: This state perform initialization tasks. In example, loading the file scenarios into the simulator. Declaring initial conditions for the platoon, etc.
Preroutine: Tasks to be done before the querying information from the simulator
Query: Tasks of parsing data and querying information from the simulator
Control: Perform decision tasks for the platoon
Push: Push updated information to the simulator for platoon vehicles
Postroutine: Performs tasks after the information has been pushed.
- class ensemble.logic.runtime_states.Compliance[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which declares an status to check file compliance .
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
Returns next state
- Parameters
event (str) – Event keyword for next state “connect”
- Returns
Connect object in case of switch
- Return type
- perform_check(configurator)[source]¶
This function triggers the check validation for the files raises errors in case files are not found
- Parameters
configurator (Configurator) – Configuration descriptor
- class ensemble.logic.runtime_states.Connect[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which declares the creation of a connection with the simulator
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
State to switch on event
- class ensemble.logic.runtime_states.Control[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which computes the control decision
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
State to switch on event
- class ensemble.logic.runtime_states.Initialize[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which initializes values for the scenario simulation
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
State to switch on event
- class ensemble.logic.runtime_states.PostRoutine[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which logs information or compute step indicators
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
State to switch on event
- class ensemble.logic.runtime_states.PreRoutine[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which performs task previous to the interaction with the simulator
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
State to switch on event
- class ensemble.logic.runtime_states.Push[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which pushes data back to the simulator
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
State to switch on event
- class ensemble.logic.runtime_states.Query[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which retrieves information from the simulator
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
State to switch on event
- class ensemble.logic.runtime_states.Terminate[source]¶
Bases:
ensemble.metaclass.state.AbsState
The state which declares the end of a simulation
- next_state(event: str, configurator) ensemble.metaclass.state.AbsState [source]¶
State to switch on event
ensemble.logic.statemachine module¶
ensemble.logic.subscriber module¶
Subscriber¶
This module dedicates a generic object to generate an observer pattern implementation responsible of subscribing to a publisher
- class ensemble.logic.subscriber.Subscriber(publisher, channel='default', callback=None)[source]¶
Bases:
ensemble.metaclass.observer.AbsObserver
This general dataquery model implements a general publisher pattern to broadcast information towards different subscribers. Subscribers are intented to be objects such as vehicles, front/rear gap coordinators.
This creates an subject that can notify to a specific channel where subscribers are registered or
Example
Create a DataQuery for 2 type of channels,
automated
andregular
vehicles:>>> channels = ('auto','regular') >>> query = DataQuery(channels)