IntersectionControl

Communication API

class Message(sender: str, contents: Dict[str, Any])

A class to represent a Message

Variables
  • sender – The address of the sender of the message

  • contents – A dictionary containing the message contents.

class MessagingUnit

A class to represent a communication system

An intersection manager or vehicle can have a MessagingUnit, and use it to communicate with other vehicles or intersection managers. This class can be subclassed to provide different behaviours of varying complexity. For example, an implementation that uses a discrete event simulator such as Omnet++ or ns-3 to track node connectivity and provide complex routing behaviour.

As a general rule, all MessagingUnits in an environment/experiment should be of the same type - although this API would allow for the implementation of different Unit types that behave slightly differently but are able to communicate.

abstract property address: str

The MessagingUnit’s address

abstract broadcast(message: intersection_control.core.communication.Message)

Sends a message to all reachable MessagingUnits

Parameters

message (Message) – The message to be broadcast

destroy()

Called when the user of this unit no longer exists

Useful, for example, to remove this unit from a network, if one is explicitly tracked.

Can optionally be implemented to do some clean-up functions if needed. If this isn’t needed, this method can simply be ignored.

abstract discover() List[str]

Returns a list of addresses that can be reached

Returns

A list of addresses that can be reached at this point in time

abstract receive() List[intersection_control.core.communication.Message]

Returns a list of messages received since the last time this method was called

Returns

A list of received messages

abstract send(address: str, message: intersection_control.core.communication.Message)

Sends message to the MessagingUnit with the given address

Parameters
  • address (str) – The address of the MessagingUnit that the message should be sent to

  • message (Message) – The message to be sent