This repository contains the documentation and code for various applications in the Chipurobo AI series. The applications include motor control, lidar-based obstacle avoidance, and gesture control using Hailo.
chipurobo-ai-series/
├── src/
│ ├── motor_control/
│ │ └── motor_control.py
│ ├── lidar/
│ │ └── lidar_control.py
│ └── gesture_control/
│ └── gesture_control.py
├── README.md
└── requirements.txt
-
Clone the repository:
git clone <repository-url> cd chipurobo-ai-series
-
Install dependencies: Ensure you have Python and pip installed, then run:
pip install -r requirements.txt
-
Install additional packages for the AI camera:
sudo apt-get update sudo apt-get install -y python3-picamera2
The motor control application uses GPIO pins to control the motors of a robot. The script motor_control.py
is responsible for moving the motors forward and stopping them based on lidar input.
python -m src.motor_control.motor_control
The lidar-based obstacle avoidance application uses an RPLidar to detect obstacles and stop the motors when an obstacle is detected within a certain distance.
python -m src.lidar.lidar_control
The gesture control application uses the Hailo AI processor to recognize gestures and control the robot based on the recognized gestures.
python -m src.gesture_control.gesture_control
threading
andqueue
: Used for running pose estimation in a separate thread and managing wrist position updates.random
: Generates random brick spawn positions.math
: Provides mathematical operations (though unused here).
pygame
: For creating the game window, handling events, and rendering graphics.
gi
andGst
: For managing multimedia pipelines via GStreamer.hailo
andhailo_rpi_common
: For pose detection and landmarks extraction using Hailo's SDK.
numpy
: Efficient numerical operations.collections.namedtuple
: For defining simple game objects likePlayer
,Bullet
, andBrick
.
- Window and FPS: Dimensions (
WINDOW_WIDTH
/WINDOW_HEIGHT
) and refresh rate (FPS
). - Object Dimensions and Speeds: Sizes and velocities of the player, bullets, and bricks.
- Spawn Rate: Determines how frequently bricks spawn.
- Lives: Number of lives the player starts with.
- Position Queue Size: Capacity for storing wrist position updates.
Common RGB tuples:
- White, Red, Green, Blue, and Black.
Defined using namedtuple
for simplicity and immutability:
Player
: Paddle position and dimensions.Bullet
: Bullet position, dimensions, and velocity.Brick
: Brick position, dimensions, and velocity.
- Handles the communication between the pose estimation pipeline and the game logic.
- Tracks default wrist positions and updates a queue for real-time paddle control.
- Game Setup: Creates the game window, initializes paddle position, and resets the game state.
- Pose Estimation: Sets up callbacks to process wrist positions for paddle movement.
- Resets player position, score, lives, and clears bullets and bricks for a fresh session.
- Processes buffer data from the GStreamer pipeline.
- Extracts ROI and landmarks.
- Normalizes wrist positions relative to the frame height.
- Updates the position queue for paddle control.
spawn_brick()
: Generates bricks at random x-coordinates with fixed velocity.
- Bricks: Move downward and deduct a life if they fall out of bounds.
- Bullets: Move upward and are removed when out of bounds.
- Collisions: Detects bullet-brick collisions, increasing the score when a hit occurs.
update_player()
: Updates the paddle's position based on the average x-coordinate of the player's wrists.
- Clears the screen.
- Renders the player, bullets, bricks, score, and remaining lives.
- Runs the pose estimation pipeline separately to ensure smooth gameplay.
Handles:
- Event processing (e.g., quitting the game).
- Spawning and updating game objects.
- Rendering frames.
- Maintaining the FPS.
- Resets the game state when all lives are lost.
- Releases resources such as the Pygame window and the pose estimation pipeline when the game exits.
- Initializes the
PoseShooter
class and starts the game using therun()
method.
Make sure to install the required libraries before running the scripts. You can install the dependencies using the following command:
pip install -r requirements.txt
This project is licensed under the MIT License.