Skip to content

5. Real robot QR code follower using Zenoh flow

Unai Sanz edited this page May 17, 2023 · 5 revisions

Introduction

Nodes communication scheme.

All the nodes in this section were tested using ROS2 Foxy Fitzroy distro and a turtlebot3 burger model. It's recommended to see a previous page to make the QR code follower work using zenoh first.


What is Zenoh-flow?

Zenoh-flow is the union of Zenoh and data flow programming: a declarative framework for computations that span from the Cloud to the Thing.

Why use Zenoh-flow instead of ROS2 (DDS by default)?

  • Considerable reduction of the network saturation (main cause of packet lost) produced by the spam of discovering UDP multicast in DDS.

  • Easier understanding and coding of the pub/sub applications (ROS2 is hard to learn from scratch).

  • Avoiding some ROS2 errors and bugs.

  • Not perfect but better official documentation and examples, since ROS2 docs redirects to their source codes very often.

  • Simpler code for a simple application.

The image on the right is a scheme of the zenoh-flow nodes and the communications between them using Zenoh.

Installation and building

First of all you will first have to clone this repository and change your branch to the tag v3.0_qcf_zf:

git clone https://github.com/USanz/follow_beacon.git
git checkout v3.1.2_qcf_zf

Note: Now there's no need to build the package because we're only going to use the python nodes.

In this case we are using a turtlebot3 burger model with a camera plugged in. We'll need to follow the same exact steps in the robot (now we do not need to checkout to another different branch).

You will need to have installed the zenoh-bridge-dds in the robot, the zenoh router in both the computer and the robot. In order to achieve this, follow the instructions linked in the Requirements part of the README.md file.

Running it

In order to run it, we will have to run the bringup nodes to communicate in local host and have a bridge and a zenoh router running in the robot to be able to communicate with the other zenoh router that will be running in the computer, we will do this by adding ROS_LOCALHOST_ONLY=1 before both ros2 bringup and zenoh-bridge-dds commands.

Note: to see more information about the parameters file, see the previous page (the parameters are the same but they are now distributed in each src/zenoh-flow_nodes/<node_name>.yml file

  • In the robot (you can and should open a ssh session to run the commands):

    1. Run the zenoh router:

    You will have to modify the robot router config file to add your computer IP to the line 6 (inside the "connect" -> "endpoints" fields).

    Run the zenoh router with this configuration:

    cd <your_workspace_path>
    RUST_LOG=zenoh_flow=debug zenohd -c config/robot_zf_router_config.json
    
    1. Run the bridge to listen to your computer ip, and the zenoh port (7447):
    cd <zenoh-bridge-dds_installation_folder>
    ROS_LOCALHOST_ONLY=1 ./zenoh-bridge-dds -e tcp/<computer_ip>:7447
    

    Note: see the official documentation for more information about the zenoh bridge configuration.

    1. Run the bringup ROS2 nodes:
    ROS_LOCALHOST_ONLY=1 ros2 launch turtlebot3_bringup robot.launch.py
    
  • In the computer:

    1. Run the zenoh:

    You will probably have to uncomment lines 5, 6 and 7 and modify the line 6 to add your robot raspberry IP (inside the "connect" -> "endpoints" fields) in the computer router config file.

    Run the zenoh router with this configuration:

    cd <your_workspace_path>
    RUST_LOG=zenoh_flow=debug zenohd -c config/computer_zf_router_config.json
    
    1. Launch the data-flow:
    zfctl launch <your_workspace_folder>/src/follow_beacon/src/zenoh-flow_nodes/data-flow_qr_follower_robot.yaml
    
    1. If you want to see the debug information you will also need to launch a zenoh-bridge-dds and rviz in your computer running in localhost:
    cd <zenoh-bridge-dds_installation_folder>
    ROS_LOCALHOST_ONLY=1 ./zenoh-bridge-dds -e tcp/<computer_ip>:7447
    

    And in another terminal:

    cd <your_workspace_path>
    ROS_LOCALHOST_ONLY=1 rviz2 -d config/config.rviz