Dennis Salzner - 2015-11-13-Fr-WifiCar

<< Back Home

Fig.1: completed car

Fig.2: old chassis

Fig.3: motor controller

Fig.4: new aluminum chassis

Fig.5: computer control

Fig.6: front camera

Fig.7: components

A WiFi controlled car with camera

What?

I've finally gotten around to completing my WiFi controlled car. This project has been lying around for ages. I recently bought a hand-held circular saw and with it I can cut aluminum rods. That got me the motivation to finish the cars chassis.

The car connects to the local area network via WiFi. It runs two web servers, one for controlling the motors and one for viewing the web cam. After turning it on all I need to do is open the two webpages in my browser and I can control the car and see where it's going.

When?

Computer controlled cars with cameras have fascinated me for a long time. But I didn't have the knowledge to build one myself, when I was younger. My first humble attempts were to strap a Super Nintendo, with a GameBoy Cartridge Adapter and a GameBoy Camera to a remote controlled car. This did work, but the load was way too heavy for the car and there were cables dangling off the back.

With the advent of network routers like the Asus WL-500g, that could be modified to run linux and had a USB Port, I knew where I wanted to go. The USB port could be used for a web cam, as IP and Wifi cameras are still very expensive. Now we have miniature embedded Linux computers such as the RaspberryPi or BeagleboneBlack, which a perfect for the purpose.

What was troubling me then was building the chassis, battery powering the car, the software and the electronics. I got into Linux and electronics since the days my first attempts, but now I wanted flexibility in adding sensors to the car. Completing the car didn't have a high priority anymore, as other projects interested me more. I didn't want to work on the car until I had enough knowledge to quickly complete it. Discovering the I2C bus system was the final tool I needed for quickly completing the car. With it I can attach and detach boards by connecting only two wires. I don't need to plan which pins I use for what or use complicated plugs. Now I can make small boards for each purpose and connect them with I2C. Once a board is finished, it is finished and needs no further modification.

With the electronics in hand I needed a chassis. I didn't like the idea of cutting it from wood as sturdy wood is heavy. It is also very difficult to quickly add components. I needed some sort of compartmentalization.

I got rectangular aluminum tubes for my CNC mill project, but both the car and the CNC mill were lying around, because I couldn't easily cut it. Now I have the saw and the first thing I did was finish the car. With the aluminum tubes I can quickly add and remove components by screwing them into the aluminum. And aluminum rods are sturdy, cheap and light-weight.

Why?

A remote controlled car is something that almost every kid is fascinated by. Now this fascination has changed only slightly. After getting into machine learning and robot navigation through my university studies I've become interested in the idea of having an autonomous robot driving around in the apartment. In order to autonomously drive, the car needs to navigate in a map of the apartment. It therefore needs to know where it is. Indoor navigation is very difficult and requires lots of sensors. This is why I wanted a versatile robot car platform to quickly try things out. One of my previous projects was reading out a compass via I2C (see here) and this is one step in the direction of adding sensors.

Background?

There are many different types of remote controlled cars. The most basic have a 433 MHz remote control. They drive around, but they can't transmit any video. Transmitting video is actually really difficult, as it needs sophisticated hardware. Sometimes wireless cameras are added to remote controlled airplanes, but they are very expensive. When people started replacing the firmware running on home network routers, one of the first uses was connecting web cams and using them as IP cameras. Then adding motor control and adding motors and wheels from torn apart remote control cars. Robot vacuum cleaners, such as the Roomba were no good for vacuuming at first, but they had interfaces for manually controlling the motors from the very start. This combination has lead to quite a few WiFi enabled robot projects on the internet.

How?

My car isn't much different from the hundreds of Wifi cars on the internet, but mine uses I2C for controlling all of it's sensors and actuators - that includes the motors for driving and steering. And it uses an embedded computer for control with a web cam and wireless LAN USB dongle. In order to really simplify the software I've used Python Flask as in many of my previous projects (see here). The software consists of less than 50 lines of code and allows control over a web browser. That means it can also be controlled from smartphones.

I won't go into too much detail on how it works, as it is quite basic. The necessary information for building such a car can be quickly found on the internet.

  • Main Processor: The main processor is a RaspberryPi. It runs Rasbian and has all the necessary software installed for interfacing with I2C. Python and web cam streaming software have also been installed.
  • Camera: The camera is simply a USB web cam connected to a USB Port on the RaspberryPi. The "motion" package was installed. It automatically starts a stream which I can connect to with my web browser.
  • Motors: The motors are taken from an old remote control car I've taken apart. It's Nikko Deceptor - a very old remote control car - any car will do.
  • Power: I'm using the batteries that came with the remote controlled car for it's the motors. The RaspberryPi is hooked up to a USB power pack, as it needs far more energy for the web cam and the Wireless LAN.
  • Motor control: Motor control is handled by an L298 H-Bridge chip. This is connected to an I2C port-expander, the PCF8574. The H-Bridge is connected to the port-expander as if it were directly connected to the GPIO-Pins of the RaspberryPi. Search for "RaspberryPi L298 Motor control" on the Internet for more information. All of that is soldered on to a strip board (Fig.3). The batteries for the motor connect to it, as do the motors and the RaspberryPi via I2C for controlling it.
  • Chassis: The chassis is build out of four aluminum rods. Two short rods are screwed into two longer rods close to the center in a right angle (Fig.4). The axles from the remote control car are fastened to this using cable binders. I've added some thin wood which is screwed onto the aluminum rods in order to have non-conductive plates to which the circuit boards and the RaspberryPi are attached with screws. The batteries and the camera is also fastened with cable binders (Fig. 7).

Progress?

The car works well, but some issues remain. The camera stream from the web cam is unbearably slow. The RaspberryPi should have enough processing power to handle a web cam stream, so I don't really know what the issue is. Motor control works almost instantly. The batteries of the remote controlled car are very weak, perhaps I will replace them. It might be possible to run the motors off of the USB power pack. This would give me flexibility in adding a more powerful USB power pack. They also come with charging cables, are safe to use and have displays showing how much power is left.

Some ideas for components I could add:

  • nice to have
    • an I2C chip for monitoring the battery packs
    • another web cam which can rotate using servo motors
    • led lights and color indicators
  • for localization/autonomous driving
    • a laser pointer which can be used to estimate distance using the cameras
    • push buttons in order to detect collisions
    • ultrasonic range finders
    • compass
    • rotary encoders for each wheel
    • USB WiFi dongles which can measure signal strength and are pointed in different directions for WiFi localization
  • crazy
    • drive-in charging or battery pack switching. inductive charging, so the car only needs to drive over a spot to charge.
    • speaker and microphone for voice control
    • face recognition and tracking with OpenCV
  • really crazy
    • eyes with servo controlled eye lids and color LEDs
    • a Geiger counter for measuring radioactivity - nevermind
    • bridge launching and retrieval (see here)

But who knows when I'll get around to adding any of that.