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.
- 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.
The system consists of three main nodes:
-
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.
-
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.
- Subscribes to
Ensure you have ROS 2 installed (Humble/Iron/Rolling).
-
Dependencies:
pip install yolox loguru scikit-image thop sudo apt install ros-<distro>-vision-opencv ros-<distro>-cv-bridge
-
Build: This is a ROS 2 package. Build it using
colcon:colcon build source install/setup.bash
-
Launch the System:
ros2 launch person_following_robot follow_person.launch.py
-
Configuration:
- Adjust control gains (
linear_kp,angular_kp, etc.) inperson_follower.pyto tune the response. - Camera intrinsics and model paths are configured in
person_tracker.py.
- Adjust control gains (
- Original Author: Special thanks to malwaru for the original implementation and inspiration.