Skip to content

A ROS 2 package for autonomous person following using YoloX detection and ByteTrack with RGB-D depth estimation and PD control.

Notifications You must be signed in to change notification settings

OpenMind/ros2-person-follower

Repository files navigation

Person Following Robot

This project implements a robust person-following behavior for a robot (simulated or real) using YoloX with ByteTrack for person detection/tracking and a PID-based controller for smooth following.

Key Features

  • Person Detection & Tracking: Uses YoloX for high-performance detection and ByteTrack for robust multi-object tracking.
  • Depth-Based Localization: accurate distance estimation using RGB-D camera data (e.g., RealSense).
  • Smooth Control: Implements a PD (Proportional-Derivative) controller for both linear and angular velocities to ensure smooth following and rotation.
  • Safety: Includes handling for "Person Lost" scenarios and collision avoidance logic.

Architecture

The system consists of three main nodes:

  1. person_tracker.py:

    • Subscribes to RGB and Depth camera streams.
    • Runs YoloX inference to detect persons.
    • Uses ByteTrack to assign consistent IDs to detected persons.
    • Calculates the 3D position of the target person relative to the robot.
    • Publishes the target pose to tracked_person/position.
  2. person_follower.py:

    • Subscribes to tracked_person/position.
    • Calculates the error in distance and angle.
    • Computes velocity commands (cmd_vel) using a PD controller to keep the person at a desired distance and centered in the view.

Installation & Dependencies

Ensure you have ROS 2 installed (Humble/Iron/Rolling).

  1. Dependencies:

    pip install yolox loguru scikit-image thop
    sudo apt install ros-<distro>-vision-opencv ros-<distro>-cv-bridge
  2. Build: This is a ROS 2 package. Build it using colcon:

    colcon build
    source install/setup.bash

Usage

  1. Launch the System:

    ros2 launch person_following_robot follow_person.launch.py
  2. Configuration:

    • Adjust control gains (linear_kp, angular_kp, etc.) in person_follower.py to tune the response.
    • Camera intrinsics and model paths are configured in person_tracker.py.

Credits

  • Original Author: Special thanks to malwaru for the original implementation and inspiration.

About

A ROS 2 package for autonomous person following using YoloX detection and ByteTrack with RGB-D depth estimation and PD control.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages