Online First Person Rc Car Racing
About the project
This system allows users to create RC cars that can be controlled over the internet! I have used this project to allow people from all over the world to race around a track I made in my house using a first person camera on the car to guide them. There is a video about the project on my channel: www.youtube.com/@ollieq
Project info
Items used in this project
Hardware components
Software apps and online services
Story
I can't really explain to you every single step, as this project took months, (it felt like longer!) with lots of iterations to try and improve it, it has now become part of my university work to make it completely autonomous, meaning, I will be adding AI to make the cars return the start automatically and automatic timing etc. As I am now working on it at university I am not allowed to release the code, unfortunately.
I can do my best to explain how it works and you guys can whip some code together to fill in the gaps.
Firstly I stripped the RC car controllers apart and then soldered a wire to each button on the controller. Then I added a transistor to each button that an Arduino Uno could open or close, opening the transistor made the controller think the button was being pressed, therefore making the car move. (The cars motors and onboard controller are completely stock, the cars are technically being controlled by the controller like normal).
The Arduino Uno, that is hooked up to the controllers will then listen over serial for commands telling it which directions the car should be moving, and therefore which transistors to open.
The main change to the car is the Raspberry Pi on top. This has an Adafruit Lipo battery hat to allow the rpi to run without being plugged in, this seems to last around 2 hours per charge. The sole purpose of this Rpi is to stream the video feed. I initially used an ESP32-Cam but this had some real overheating issues so I left the microcontroller system to go for a much beefier Rpi. The Rpi is simply running rpi-mjpg-streamer.
I would also recommend printing a cover for the GPIO pins as in my initial testing someone drove the car under my sofa, some of the pins bent and lots of them got shorted, luckily everything survived and was fine.
I then wrote an Express app in NodeJS to control the queue for the match and take the inputs to move the cars, this was pretty complex as I didn't want multiple people having multiple tabs open which would fill the queue up with fake users.
When the client started the game they would be given access to the video stream, which was being proxied to them via an `NGINX` instance on an AWS EC2, which would use mjpeg-proxy to ensure that only one video stream was being sent by the Rpi (as it will quite easily get overwhelmed) this mjpeg-proxy instance will then copy the contents of that one stream and stream it to all of its clients, taking away any strain on the Rpi.
I think thats a very high level explination of how this works. It is going to be seeing a lot of improvements in the future, but they will take a little while to come as I try to upload my projects to YouTube every month so I don't always have long, especially now I am in my last year of university. My main focus is to move away from using MJPEG as it is extremely bandwith hungry and wasteful.
I am more than happy to respond to any queries or questions!
I create videos about these projects but they do not intend to explan too much, they are more for entertainment, they can be found on my YouTube.
Leave your feedback...