Graph-based communication

Here we provide the API documentation for classes related to graph-based communication capabilities. The main class providing this functionality is Communicator, but there are also additional internal classes implementing particular features.

Communicators

class choirbot.communicator.BestEffortCommunicator(agent_id, size, in_neighbors, out_neighbors=None, differentiated_topics=False)[source]

Bases: disropt.communicators.Communicator

__init__(agent_id, size, in_neighbors, out_neighbors=None, differentiated_topics=False)[source]

Initialize self. See help(type(self)) for accurate signature.

neighbors_receive_asynchronous(neighbors)[source]

Receive data (if any) from neighbors. Overwrite if multiple messages are received.

Parameters

neighbors (list) – list of neighbors

Returns

dict containing received data

Return type

dict

neighbors_send(obj, neighbors)[source]

Send data to neighbors

Parameters
  • obj (Any) – object to send

  • neighbors (list) – list of neighbors

class choirbot.communicator.StaticCommunicator(agent_id, size, in_neighbors, out_neighbors=None, synchronous_mode=True, differentiated_topics=False)[source]

Bases: choirbot.communicator.communicator.TimeVaryingCommunicator

neighbors_exchange(send_obj, dict_neigh, stop_event=None)[source]

exchange information (synchronously) with neighbors

Parameters
  • send_obj (any) – object to send

  • in_neighbors (list) – list of in-neighbors

  • out_neighbors (list) – list of out-neighbors

  • dict_neigh – True if send_obj contains a dictionary with different objects for each neighbor

Returns

dict containing received data associated to each neighbor in in-neighbors

Return type

dict

neighbors_receive(stop_event=None)[source]

Receive data from neighbors (waits until data are received from all neighbors)

Parameters

neighbors (list) – list of neighbors

Returns

dict containing received data associated to each neighbor in neighbors

Return type

dict

neighbors_receive_asynchronous()[source]

Receive data (if any) from neighbors. Overwrite if multiple messages are received.

Parameters

neighbors (list) – list of neighbors

Returns

dict containing received data

Return type

dict

neighbors_send(obj)[source]

Send data to neighbors

Parameters
  • obj (Any) – object to send

  • neighbors (list) – list of neighbors

class choirbot.communicator.TimeVaryingCommunicator(agent_id, size, in_neighbors, out_neighbors=None, synchronous_mode=True, differentiated_topics=False)[source]

Bases: choirbot.communicator.communicator.BestEffortCommunicator

__init__(agent_id, size, in_neighbors, out_neighbors=None, synchronous_mode=True, differentiated_topics=False)[source]

Initialize self. See help(type(self)) for accurate signature.

neighbors_exchange(send_obj, in_neighbors, out_neighbors, dict_neigh, stop_event=None)[source]

exchange information (synchronously) with neighbors

Parameters
  • send_obj (any) – object to send

  • in_neighbors (list) – list of in-neighbors

  • out_neighbors (list) – list of out-neighbors

  • dict_neigh – True if send_obj contains a dictionary with different objects for each neighbor

Returns

dict containing received data associated to each neighbor in in-neighbors

Return type

dict

neighbors_receive(neighbors, stop_event=None)[source]

Receive data from neighbors (waits until data are received from all neighbors)

Parameters

neighbors (list) – list of neighbors

Returns

dict containing received data associated to each neighbor in neighbors

Return type

dict

neighbors_receive_asynchronous(neighbors)[source]

Receive data (if any) from neighbors. Overwrite if multiple messages are received.

Parameters

neighbors (list) – list of neighbors

Returns

dict containing received data

Return type

dict

Additional internal classes

class choirbot.communicator.callback_group.AuthorizationCallbackGroup[source]

Bases: rclpy.callback_groups.CallbackGroup

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

beginning_execution(entity)[source]
can_execute(entity)[source]
draw_authorization()[source]
ending_execution(entity)[source]
give_authorization(permanent=False)[source]
class choirbot.communicator.executor.SpinSomeExecutor(*, context=None)[source]

Bases: rclpy.executors.Executor

Runs callbacks and remembers when timeouts are hit

__init__(*, context=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Return type

None

spin_once(timeout_sec=None)[source]
Return type

None