This repository contains the Brain Node, a ROS-based controller for an NVIDIA Jetson Nano-powered JetBot. The system integrates real-time semantic segmentation for lane tracking and dynamic object detection to navigate warehouse environments autonomously.
The project implements a hybrid AI perception system that treats a single CSI camera as a virtual radar. By processing two deep learning models simultaneously, the robot perceives its environment and calculates smooth steering commands to stay within lanes while proactively avoiding obstructions.
- Dual-Model Inference: Runs
segNet(Lane Segmentation) anddetectNet(Object Detection) concurrently using thejetson-inferencelibrary. - Virtual Radar Ray-Casting: Uses a custom 15-ray "radar" scanning a 120° field of view to detect lane boundaries and obstacles.
- CUDA Optimization: Utilizes
cudaAllocMapped(Zero-Copy memory) to maximize efficiency on the Jetson Nano’s 4GB RAM. - Smooth Motion Control: Implements a Low Pass Filter (LPF) and "ray-jump" filtering to handle poor lighting or gaps in floor markings.
The brain_node.py manages the entire pipeline from raw pixels to motor commands.
| Component | Technology | Role |
|---|---|---|
| Vision AI | jetson-inference |
Executes .onnx models for Lane Segmentation and Object Detection. |
| Preprocessing | jetson-utils |
Handles hardware-accelerated CUDA cropping to a 224x128 Region of Interest (ROI). |
| Logic Engine | NumPy / Math |
Calculates weighted steering angles via a virtual radar lookup table. |
| Communication | ROS (rospy) |
Publishes geometry_msgs/Twist to the /cmd_vel topic for motor control. |
| Post-Processing | OpenCV |
Handles mask dilation and visual feedback. |
Instead of traditional line-following, this node uses a sophisticated ray-casting method:
- ROI Cropping: The camera feed is cropped to the bottom 224 x 128 pixels to focus on the floor and reduce background noise.
- Mask Generation:
segNetproduces a lane mask. Any objects detected bydetectNetare "burned" into this mask as impassable obstacles. - Ray-Casting: 15 virtual rays are projected from the robot's base. Each ray "walks" through the mask until it hits a boundary or obstacle.
- Weighted Voting: Rays in the center are weighted more heavily. If an obstacle is detected on the right, the weights for the right-side rays are reduced, forcing the robot to steer left.
- Steering Smoothing: A steering smoothing factor 0.7xlast_steering + 0.3xnew_angle prevents jittery movement.
- Obstacle Avoidance: The node also uses LiDAR to detect big obstacles and turns accodingly to avoid the object, LiDAR is prioritised over object and lane detections.
- Resolution: 224 x 128 (ROI).
- Lane Model (
segNet): ~18-22 FPS. - Object Model (
detectNet): ~15-20 FPS. - End-to-End Latency: < 60ms.
-
Clone the Repository:
git clone [https://github.com/your-username/lane-follower-jetbot.git](https://github.com/your-username/lane-follower-jetbot.git) cd lane-follower-jetbot -
Dependencies: Ensure you have
jetson-inferenceand ROS (Melodic or Noetic) installed on your Jetson Nano. -
Model Setup: Ensure your
.onnxmodels and label files are placed in the/modelsdirectory of thelane_followerpackage. -
Run the Node:
rosrun lane_follower brain_node.py
- Low Lighting: High ISO noise can occasionally create false boundaries in the segmentation mask.
- Total Obstruction: If the path is 100% blocked, the robot is programmed to maintain its last known valid heading at reduced speed.





