Skip to content
tvh25082004Public

About

Robotics is an interdisciplinary field of engineering and computer science that designs, builds, and programs machines to assist humans

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Robotics

A ROS 2 workspace for hand gesture recognition and camera streaming, enabling gesture-based robot control using MediaPipe and computer vision.

Project Structure

Robotics/
├── README.md
├── .gitignore
├── scripts/
│   └── test_cam.py              # Simple webcam test script
└── ros2_ws/
    └── src/
        ├── hand_gesture_recognition/  # Gesture recognition & robot control
        │   ├── package.xml
        │   ├── setup.py
        │   ├── config/
        │   │   └── params.yaml         # ROS 2 parameters
        │   ├── launch/
        │   │   └── hand_gesture.launch.py
        │   └── hand_gesture_recognition/
        │       ├── __init__.py
        │       ├── gesture_detector.py      # MediaPipe hand tracking
        │       └── gesture_controller.py    # Velocity command mapping
        │
        └── my_camera_pkg/            # Camera publisher & subscriber
            ├── package.xml
            ├── setup.py
            ├── launch/
            │   └── camera_launch.py
            └── my_camera_pkg/
                ├── __init__.py
                ├── camera_pub.py      # Webcam → /camera/image_raw
                └── camera_sub.py      # Subscriber with live display

Prerequisites

  • ROS 2 (Humble / Iron / Jazzy)
  • Python 3.8+
  • Webcam

Dependencies

sudo apt install python3-opencv python3-numpy
pip install mediapipe

ROS 2 packages (install via rosdep):

sudo apt install ros-<distro>-cv-bridge ros-<distro>-vision-opencv

Build

cd ros2_ws
colcon build
source install/setup.bash

Usage

1. Camera Test (standalone)

Quick test to verify your webcam works:

python3 scripts/test_cam.py

2. Camera Publisher & Subscriber

Launch the ROS 2 camera pipeline:

ros2 launch my_camera_pkg camera_launch.py

Or run individually:

# Terminal 1 — publish webcam frames
ros2 run my_camera_pkg camera_pub

# Terminal 2 — view incoming frames
ros2 run my_camera_pkg camera_sub

3. Hand Gesture Recognition

Run the full gesture recognition system:

ros2 launch hand_gesture_recognition hand_gesture.launch.py

Launch Arguments

Argument Default Description
use_webcam true Use webcam or ROS camera topic
camera_id 0 Webcam device ID
linear_speed 0.5 Max linear speed (m/s)
angular_speed 1.0 Max angular speed (rad/s)
enable_controller true Enable the robot controller node
cmd_vel_topic /cmd_vel Velocity command topic
enable_timeout true Auto-stop robot on gesture timeout
timeout_seconds 1.0 Timeout before auto-stop

Gesture Mapping

Gesture Robot Command Description
OPEN_PALM Stop Stop all motion
FIST Stop Stop all motion
POINT Forward Move forward
PEACE Backward Move backward
THUMBS_UP Rotate Left Turn counter-clockwise
THREE Rotate Right Turn clockwise
FOUR Increase Speed Speed ×1.1 (up to 2.0×)
ONE Decrease Speed Speed ×0.9 (down to 0.2×)

Note: Speed changes persist until reset. The robot auto-stops if no gesture is received within the configured timeout.

ROS 2 Topics

Published by gesture_detector

Topic Type Description
/hand_gesture String Recognized gesture ("Left: POINT")
/hand_count Int32 Number of extended fingers
/hand_position Point Wrist center coordinates (pixels)
/annotated_image Image Frame with landmarks drawn

Published by gesture_controller

Topic Type Description
/cmd_vel Twist Velocity commands to robot

Published by camera_pub

Topic Type Description
/camera/image_raw Image Raw webcam frames (60fps)

Configuration

Edit ros2_ws/src/hand_gesture_recognition/config/params.yaml to adjust:

  • Camera: device ID, resolution, confidence thresholds
  • MediaPipe: detection/tracking confidence, max hands
  • Controller: speed limits, timeout behavior

Nodes Overview

hand_gesture_recognition

Node File Role
gesture_detector gesture_detector.py Captures frames, detects hands via MediaPipe, publishes gesture data
gesture_controller gesture_controller.py Subscribes to gesture topics, publishes /cmd_vel Twist commands

my_camera_pkg

Node File Role
camera_pub camera_pub.py Opens webcam, publishes Image messages
camera_sub camera_sub.py Subscribes and displays camera feed

About

Robotics is an interdisciplinary field of engineering and computer science that designs, builds, and programs machines to assist humans

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages