This project implements a comprehensive navigation and object detection system for the JetBot robot, designed for autonomous navigation in a structured environment. It leverages ROS (Robot Operating System) for inter-process communication, OpenCV for image processing, and a YOLO model for object detection. The robot uses a state machine to manage its behavior, including line following, intersection handling, obstacle avoidance, and map-based navigation. It can load maps from either an API or a local file and communicates with other systems via MQTT.
π₯ First Prize - FPT EDU HACKATHON 2025 (Chip AI) - Awarded 1st place for the JetBot navigation and perception system.
A comprehensive JetBot navigation and object-detection system that combines ROS-based control, visual line following, LiDAR intersection detection, map-based A* planning, and YOLO-based object recognition. Designed for structured environments, it supports API-driven maps, MQTT telemetry, and modular detection pipelines.
- State Machine Control: Manages the robot's behavior through distinct states like
WAITING_FOR_LINE,DRIVING_STRAIGHT, etc., enabling complex decision-making. - Line Following: Employs image processing to accurately follow lines on the ground, ensuring adherence to the designated path.
- Intersection Handling: Detects and intelligently handles intersections based on map data and sensor input, allowing for route adjustments.
- Obstacle Avoidance: Utilizes laser scan data to identify and avoid obstacles, preventing collisions and ensuring safe navigation.
- Map-Based Navigation: Navigates a predefined map from a start node to an end node, leveraging path planning algorithms for efficient routing.
- Object Detection: Integrates YOLO for real-time object detection in the camera feed, triggering specific actions or events based on identified objects.
- QR Code Reading: Capable of reading QR codes using
pyzbar, enabling interaction with the environment through encoded information. - MQTT Communication: Facilitates communication with other systems using MQTT, enabling remote monitoring and control.
- Video Recording: Records the robot's camera feed to a video file, providing a visual record of the robot's activities.
- Dynamic Map Loading: Supports loading maps from either an API or a local file, providing flexibility in map source.
- Robot Operating System (ROS): Provides the framework for communication and control.
- OpenCV (cv2): Used for image processing tasks, such as line detection and camera feed analysis.
- NumPy: Employed for numerical computations and array manipulations.
- Python: The primary programming language.
- Time: Python's time module for time-related operations.
- OS: Python's operating system module.
- JSON: Python's JSON module for handling JSON data.
- Math: Python's math module for mathematical functions.
- Enum: Python's enum module for creating enumerations.
- Requests: Python's requests library for making HTTP requests (for API map loading).
- JetBot: JetBot library for controlling the JetBot robot hardware.
- ONNX Runtime: Used for running the YOLO object detection model.
- pyzbar: pyzbar library for decoding QR codes and barcodes.
- paho-mqtt: MQTT client library for communication.
- sensor_msgs.msg.LaserScan: ROS message type for laser scan data.
- sensor_msgs.msg.Image: ROS message type for image data.
- Custom Modules:
opposite_detector.py: Implements obstacle detection using laser scans.map_navigator.py: Manages map data and path planning.api_utils.py: Interacts with the Hackathon API.
- ROS (Robot Operating System) installed and configured.
- JetBot robot hardware set up.
- Python 3.6 or higher.
- Required Python packages installed (see
requirements.txtor individual file dependencies). - ONNX Runtime installed.
- A suitable YOLO model for object detection.
-
Clone the repository:
git clone <repository_url> cd <repository_directory>
-
Install the required Python packages:
pip install -r requirements.txt # If you have a requirements.txt file # OR install dependencies manually based on the files pip install rospy cv2 numpy jetbot onnxruntime pyzbar paho-mqtt requests networkx
-
Build the ROS package:
cd <your_ros_workspace>/src ln -s <path_to_repository> # Create a symbolic link to your package cd .. catkin_make source devel/setup.bash
-
Launch the ROS core:
roscore
-
Run the main control script (e.g.,
problem_a.pyorproblem_b.py):rosrun <package_name> problem_a.py # or problem_b.py
Replace
<package_name>with the name of your ROS package. -
Ensure that the JetBot hardware is properly initialized and connected.
The robot's behavior is controlled by the state machine implemented in the main control script (problem_a.py or problem_b.py). You can configure various parameters, such as line following thresholds, object detection confidence, and navigation settings, through the ROS parameter server.
To interact with the robot, you can use ROS topics and services. For example, you can publish commands to control the robot's movement or subscribe to topics to monitor its state and sensor data.
βββ api_utils.py # Defines the HackathonAPI class for API interactions.
βββ map_navigator.py # Implements map loading, parsing, and path planning.
βββ opposite_detector.py # Detects obstacles directly opposite the robot using laser scans.
βββ problem_a.py # Main control logic for the JetBot robot (Problem A).
βββ problem-b-blue.py # Main control logic for the JetBot robot (Blue Team).
βββ README.md # This file.
βββ ... # Other configuration files, models, etc.