examples.communication_schemes package
Submodules
examples.communication_schemes.channeling_example module
Channeling Example using Wrapyfi.
This script demonstrates message channeling through three different middleware (A, B, and C) using the MiddlewareCommunicator within the Wrapyfi library. It allows message publishing and listening functionalities between processes or machines.
- Demonstrations:
Using NativeObject, Image, and AudioChunk messages
Transmitting messages through different middlewares (e.g., ROS, YARP, ZeroMQ)
Applying the PUB/SUB pattern with channeling
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)
NumPy: Used for creating arrays (installed with Wrapyfi)
- Install using pip:
pip install numpy
- Run:
- # On machine 1 (or process 1): Mode: Publisher sends messages through channels A [ZeroMQ], B [ROS 2], and C [YARP]
python3 channeling_example.py --mode publish --mware_A zeromq --mware_B ros2 --mware_C yarp
- # On machine 2 (or process 2): Mode: Listener waits for message from channels A [ZeroMQ], B [ROS 2], and C [YARP]
python3 channeling_example.py --mode listen --mware_A zeromq --mware_B ros2 --mware_C yarp
- # On machine 3 (or process 3): Mode: Listener waits for message from channel C [YARP]
python3 channeling_example.py --mode listen --mware_C yarp
- # On machine 4 (or process 4) [OPTIONAL]: Mode: Listener waits for message from channel B [ROS 2]
python3 channeling_example.py --mode listen --mware_B ros2
- class examples.communication_schemes.channeling_example.ChannelingCls[source]
Bases:
MiddlewareCommunicator
examples.communication_schemes.forwarding_example module
Forwarding Example using Wrapyfi.
This script demonstrates message forwarding using the MiddlewareCommunicator within the Wrapyfi library. The communication follows chained forwarding through two methods, enabling PUB/SUB pattern that allows message publishing and listening functionalities between processes or machines.
- Demonstrations:
Using the NativeObject message
Transmitting a Python object with predefined message
Applying the PUB/SUB pattern with forwarding through two communication methods
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)
- Run:
# On machine 1 (or process 1): Mode Chain A: Publisher [ZeroMQ], Chain B: Disabled (chain A & B can have different middleware by setting the –mware_… argument but it should be consistent on all machines or processes)
python3 forwarding_example.py --mware_chain_A zeromq --mode_chain_A publish --mode_chain_B disable
# On machine 2 (or process 2): Mode Chain A: Listener [ZeroMQ], Chain B: Publisher [ROS 2] (chain A & B can have different middleware by setting the –mware_… argument but it should be consistent on all machines or processes)
python3 forwarding_example.py --mware_chain_A zeromq --mode_chain_A listen --mware_chain_B ros2 --mode_chain_B publish
# On machine 3 (or process 3): Mode Chain A: Disabled, Chain B: Listener [ROS 2] (chain A & B can have different middleware by setting the –mware_… argument but it should be consistent on all machines or processes)
python3 forwarding_example.py --mode_chain_A disable --mware_chain_B ros2 --mode_chain_B listen
- class examples.communication_schemes.forwarding_example.ForwardCls[source]
Bases:
MiddlewareCommunicator
examples.communication_schemes.mirroring_example module
Mirroring Example using Wrapyfi.
This script demonstrates the capability to mirror messages using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB and REQ/REP patterns, allowing message publishing, listening, requesting, and replying functionalities between processes or machines.
- Demonstrations:
Using the NativeObject message
Transmitting a Python object with user input and predefined message
Applying the PUB/SUB and REQ/REP patterns with mirroring
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)
- Run:
- # Alternative 1: PUB/SUB
# On machine 1 (or process 1): Publishing mode - Publisher waits for keyboard input and transmits message
python3 mirroring_example.py --mode publish
# On machine 2 (or process 2): Listening mode - Listener waits for message and prints the received object
python3 mirroring_example.py --mode listen
- # Alternative 2: REQ/REP
# On machine 1 (or process 1): Replying mode - Replier waits for a message, sends a reply, and prints the received object
python3 mirroring_example.py --mode reply
# On machine 2 (or process 2): Requesting mode - Requester sends a predefined message and waits for a reply
python3 mirroring_example.py --mode request
- class examples.communication_schemes.mirroring_example.MirrorCls[source]
Bases:
MiddlewareCommunicator