# Show RF: Self Driving Robot Lane Detection

**URL:** <https://discuss.roboflow.com/t/show-rf-self-driving-robot-lane-detection/710>\
**Category:** ✨ Show & Tell\
**Created:** [July 20, 2022, 5:48pm UTC](https://discuss.roboflow.com/t/show-rf-self-driving-robot-lane-detection/710 "2022-07-20T17:48:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![James](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/james/32/568_2.png) [@James](https://discuss.roboflow.com/u/James)\
**Post date:** [July 20, 2022, 5:48pm UTC](https://discuss.roboflow.com/t/show-rf-self-driving-robot-lane-detection/710/1 "2022-07-20T17:48:33Z")

</div>

**_A Self Driving Robot Created with Roboflow_**

**About Me**

Hello everyone!

First, a bit about me. I am a high school student in the US, and I love making software and machine learning projects.

**The Project**

For this project, I really wanted to make a self driving car, but I’m not going to risk my car for this project, so I decided to make it with some things lying around my house. I used the following:

- 1x LEGO Functions: Power Functions Motor Set 8293
- 4x LEGO Functions Power Functions M-Motor 8883
- 1x LEGO Functions: Power Functions IR Receiver 8884

I then used a IR transmitter connected to a Raspberry Pi 4 to control the motors and IR receiver on the robot itself. I then created a REST API with express.js (I know, not the best way to do it, but it was the fastest to get up and running) running on the Pi so I can send requests from my computer to control the motors. I then created a Python library so I can easily control the robot through Python.

Now the next major issue: how am I going to deal with and label the data coming from the robot to see what lanes and paths the robot can travel in? This is where the amazing Roboflow came into play. I have used Roboflow before and it is by far the best and easiest way to create and train datasets. I spent several hours labeling data for the road and lanes. Sadly, because I needed to use instance segmentation to separate the lanes, turns, and paths for the robot, I couldn’t use the Roboflow Train feature. This would have made my life easier and I wish I could have used it because Roboflow.js has the best FPS in browser by far, and amazing accuracy.

I ended up using Meta’s Detectron 2 model to train on all of this data, and I got some amazing results.

Below are some of the results.

**Results**

With this image, we can see that the robot is driving in the middle of an intersection.  
Input Image:

 ![](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/44df524f8ffcb5905cb217fa033353e12ea313af.jpeg)  
Predictions Image:  
Here is the key to the numbers:

1. Right Lane
2. Left Lane
3. Left Turn
4. Right Turn
5. Straight

 ![](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/4e05f937bf90a018df86d1b6c26a3acff297418f.jpeg)  
In this image, we can see that it pretty much nails all of the turns in the intersection. The left turn (seen in red) and the straight through the intersection (seen in dark blue) are both extremely accurate. A different example is seen below.

With this image, we can see the robot right before it enters the intersection.  
Sadly, I cannot post the before image because I am a new user and can only post 2 links per post.

Predictions Image:

1. Right Lane
2. Left Lane
3. Left Turn
4. Right Turn
5. Straight

 ![ewf](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/c9fe4ea7077e4bfeaf6f4db329c8f424e7bd8eba.jpeg)

We can see that all of the right turn (blue), straight (purple), and left turn (bright green) segmentations have worked beautifully.

My next step will be getting this model to run in realtime on a laptop, which will be the next challenge. This is currently running on a customized Colab notebook. This is why Roboflow Train is superior. I can easily use it in realtime _and_ it is accurate.

Anyways, I hoped you enjoyed this quick show and tell, and I will keep working on this project with the help of Roboflow!

**Links:**  
Coming soon, I don’t have permission to post them yet.

---

<div class="post-metadata">

**Author:** ![James](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/james/32/568_2.png) [@James](https://discuss.roboflow.com/u/James)\
**Post date:** [July 20, 2022, 5:49pm UTC](https://discuss.roboflow.com/t/show-rf-self-driving-robot-lane-detection/710/2 "2022-07-20T17:49:18Z")

</div>

About the model:

> **[Detectron2: A PyTorch-based modular object detection library](https://ai.facebook.com/blog/-detectron2-a-pytorch-based-modular-object-detection-library-/)**
>
> We are open-sourcing Detectron2, the second-generation of our widely used object-recognition platform. Detectron2 has been rewritten from the ground up in PyTorch to enable faster model iteration and deployment.

> **[GitHub - facebookresearch/detectron2: Detectron2 is a platform for object...](https://github.com/facebookresearch/detectron2)**
>
> Detectron2 is a platform for object detection, segmentation and other visual recognition tasks. - GitHub - facebookresearch/detectron2: Detectron2 is a platform for object detection, segmentation a...

---

<div class="post-metadata">

**Author:** ![Mohamed](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/mohamed/32/62_2.png) [@Mohamed](https://discuss.roboflow.com/u/Mohamed)\
**Post date:** [August 10, 2022, 3:48pm UTC](https://discuss.roboflow.com/t/show-rf-self-driving-robot-lane-detection/710/3 "2022-08-10T15:48:53Z")

</div>

This is excellent work @James!! Please email me at [mohamed@roboflow.com](mailto:mohamed@roboflow.com) so I can add some extra features and training credits to your account!
