Skip to content

1. Simulation color follower

Unai Sanz edited this page Mar 23, 2023 · 4 revisions

Introduction

Nodes communication scheme.

These nodes were made at first to test the behaviour on the simulation to then do the same with a real turtlebot3 burger robot.

All the nodes in this section were tested using Gazebo, ROS2 Foxy Fitzroy distro and a turtlebot3 waffle model, so it's recommended to see this tutorial first.

The image on the right is a scheme of the nodes and the communications between them using ROS2 topics (DDS by default)

Installation and building

First of all you will first have to clone this repository in your ROS2 workspace src folder and change your branch to the tag v0.1_color_filter:

cd <your_workspace_path>/src
git clone https://github.com/USanz/follow_beacon.git
git checkout v0.1_color_filter

Then you will have to build the package and source the setup.bash:

cd <your_workspace_path>
colcon build --symlink-install --packages-select follow_beacon
source <your_workspace_path>/install/setup.bash

In this case we are using a turtlebot3 waffle model, because the goal is to reproduce this with a real turtlebot3 burger with a camera plugged in, and the waffle model already has a camera, so we can use it for this simulation. In order to set the model you can change the env variable:

export TURTLEBOT3_MODEL=waffle

Running it

In order to have an instance of gazebo running with the robot, execute:

ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py

Note: It's not mandatory to have this robot, you can have any other robot or model publishing an image in the topic "/camera/raw_image" and receiving Twist messages in the topic "/cmd_vel" in order to move itself.

You can also launch rviz2 too to see the images and debug information by clicking on the "add" button, "by topic" window and then selecting the image you want to see ("/camera/image/raw", "/sources/image_filter/image" or "/debug/image/pixel_pos"):

ros2 launch turtlebot3_bringup rviz2.launch.py

Once these steps have been done you can run the nodes one by one using the following commands:

  1. Run the image filter node:

    ros2 run follow_beacon image_color_filter --ros-args -p display_gui:=true
    

    Note: You can adjust the color filter using the GUI (remember that the sliders represent a range of a HSV space color) or deactivate it changing the parameter display_gui:=false

  2. Run the centroid finder:

    ros2 run follow_beacon operator_image
    
  3. Run the velocity publisher:

    ros2 run follow_beacon sink_motors
    
Clone this wiki locally