-
Notifications
You must be signed in to change notification settings - Fork 0
3. Real robot QR code follower
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 it work in the simuation and the color follower nodes first.
The image on the right is a scheme of the nodes and the communications between them using ROS2 topics (DDS by default).
First of all you will first have to clone this repository in your ROS2 workspace src folder, change your branch to the tag v1.1_qr_code_follower and build it:
cd <your_workspace_path>/src
git clone https://github.com/USanz/follow_beacon.git
git checkout v1.1_qr_code_follower
cd <your_workspace_path>
colcon build --symlink-install --packages-select follow_beacon
source <your_workspace_path>/install/setup.bash
Note: It's strongly recommended to see the previous page before trying to run these nodes.
In this case we are using a turtlebot3 burger model with a camera plugged in. We'll need to do the same for the robot but in this case you will have to change the branch to cam_img_pub_v0.2:
cd <your_workspace_path>/src
git clone https://github.com/USanz/follow_beacon.git
git checkout cam_img_pub_v0.2
cd <your_workspace_path>
colcon build --symlink-install --packages-select follow_beacon
source <your_workspace_path>/install/setup.bash
Once these steps have been done you can run the nodes one by one using the following commands:
-
In the robot (you can and should open a ssh session to run the commands):
- Run the bringup:
ros2 launch turtlebot3_bringup robot.launch.py
- Run the image publisher:
ros2 run follow_beacon camera_image_pub --ros-args --params-file <your_workspace_path>/src/follow_beacon/config/params.yaml
Note: you won't have to run this node if your turtlebot3 model already has a camera as the waffle model.
-
In the computer:
-
Run only one of the QR code detector nodes:
-
Run OpenCV QR detector node:
ros2 run follow_beacon qr_code_detector --ros-args --params-file /home/usanz/zs_t3/t3_ws/src/follow_beacon/config/params.yaml
Note: this node uses the OpenCV library, which detects the QR code in a wider range of cases, but it's not able to decode the QR so the robot will follow the first detected QR code. It's better when there is a unique QR in the place you are.
-
Run Zbar QR detector node:
ros2 run follow_beacon qr_code_detector_zbar --ros-args --params-file /home/usanz/zs_t3/t3_ws/src/follow_beacon/config/params.yaml
Note: this node uses the Zbar library, which can detect and decode many QR codes in the same scene, so the robot will follow the biggest detected QR code matching the data given in the parameter "qr_data_to_track" in the config/params.yaml file. It's better when there are more than one QR codes in the scene, or when the QR code is clearer: highly visible, near the camera, straight (not rotated), etc...
-
-
Run the velocity publisher:
ros2 run follow_beacon sink_motors --ros-args --params-file <your_workspace_path>/src/follow_beacon/config/params.yaml
Note 1: remember to adjust the parameters in the config/params.yaml before and change its values. It's recommended to set the parameter "only_rotation_mode" to True to make the tests, in order not to move the robot, then it will only rotate so it can keep looking the QR code.
Note 2: you can also set the "display_gui" parameter in the config/params.yaml file to True and run only this node to test the detector until you get the right values, then you can save them in the config/params.yaml file and set the "display_gui" parameter to False again. You will have to stop the node and run it again order to apply the changes.
-
In order to run it using the zenoh bridge we will have to run the nodes to communicate in local host and have a bridge running to use zenoh above, we will do this by adding ROS_LOCALHOST_ONLY=1
before every command. In order to make the bridge communicate both parts (computer and robot), the nodes in both parts will have to run in different ROS domains, running the nodes on the robot with ROS_DOMAIN_ID=1
and the nodes running in the computer with ROS_DOMAIN_ID=2
.
To replicate this you will first have installed the zenoh-bridge-dds following their instructions, see the README.md for more information.
Note: see the notes of the previous part for more information about the parameters of the nodes.
-
In the robot (you can and should open a ssh session to run the commands):
- Run the bridge to listen on any ip, and the zenoh port (7447):
cd <zenoh-bridge-dds_installation_folder> ROS_LOCALHOST_ONLY=1 ./zenoh-bridge-dds -d 1 -l tcp/0.0.0.0:7447
Note: see the official documentation for more information about the zenoh bridge configuration.
- Run the bringup:
ROS_LOCALHOST_ONLY=1 ROS_DOMAIN_ID=1 ros2 launch turtlebot3_bringup robot.launch.py
- Run the image publisher:
ROS_LOCALHOST_ONLY=1 ROS_DOMAIN_ID=1 ros2 run follow_beacon camera_image_pub --ros-args --params-file <your_workspace_path>/src/follow_beacon/config/params.yaml
-
In the computer:
- Run the bridge:
cd <zenoh-bridge-dds_installation_folder> ROS_LOCALHOST_ONLY=1 ./zenoh-bridge-dds -d 2
-
Run only one of the QR code detector nodes:
-
Run OpenCV QR detector node:
ROS_LOCALHOST_ONLY=1 ROS_DOMAIN_ID=1 ros2 run follow_beacon qr_code_detector --ros-args --params-file /home/usanz/zs_t3/t3_ws/src/follow_beacon/config/params.yaml
-
Run Zbar QR detector node:
ROS_LOCALHOST_ONLY=1 ROS_DOMAIN_ID=1 ros2 run follow_beacon qr_code_detector_zbar --ros-args --params-file /home/usanz/zs_t3/t3_ws/src/follow_beacon/config/params.yaml
-
-
Run the velocity publisher:
ROS_LOCALHOST_ONLY=1 ROS_DOMAIN_ID=1 ros2 run follow_beacon sink_motors --ros-args --params-file <your_workspace_path>/src/follow_beacon/config/params.yaml