1602
Robotank build-controlled Wifi, camera, cannon, etc.
Hello everyone. I did an overwhelming desire to share with the world their achievement. Achievement is a tank that rulitsya over WiFi with a gamepad, broadcast on the remote real-time video sent from the remote control and sound, and has a gun with a laser sight, out of which it is possible to shoot someone.
This post will be the first test in order to understand whether this is interesting to someone other than me. It will describe the general structure, used technologies and devices.
UPD: added video.
To start a small video to attract attention. The sound comes from the speakers of the tank.
How it all began
A long time ago I had a dream to make a robot crawler, which could be remotely steer. The main problem was the lack of directly crawler. In the end I decided to buy a radio controlled tank for demolition, but I was lucky, the store was found among the rubbish tank Snow Leopard (Pershing) - USA M26 Pogorevshikh with electronics, but completely serviceable mechanical part. It was exactly what you need.
Pursuit to the chassis were dokupleny two voltage regulator for collector engines, tripod for the camera of the two servos webcam with hardware mjpeg and external WiFi card TP-LINK TL-WN7200ND. A little later added to the list of devices, portable speakers, USB zvukovuha Creative SoundBlaster Play and a simple microphone and a pair of USB hubs to make it all connected to a control unit that became the Raspberry Pi. Tower tank was dismantled, to steer it was very uncomfortable, as all full-time mechanic was built on conventional engines without feedback.
Just specify that the pictures were made when the tank was almost ready, but not in the manufacturing process.
Nutrition and wiring
In the battery compartment, I shoved the largest Li-Po battery that there has got. She was dvuhbanochnaya 3300 mAh battery in the solid body, which is commonly used in models of cars. I was too lazy to solder, so switching was used throughout the standard development board with 2.54. Later, a second on the top cover and the ribbon cable that connects them. On each of the two motors I had my voltage regulator, which is in the form of a bonus issue stabilized power about 5.6 volts. With one controller was powered Raspberry and WiFi card, power supply from the second went to the servos and a USB hub to the periphery.
We have to make this move
We had to somehow make it. Raspberry was not chosen by chance. Firstly, it allows you to put a normal full linuh, and secondly has a bunch of GPIO legs that including can generate a pulse signal to the servo controller and stroke. Generate such a signal can be monitored ServoBlaster . After starting, it creates the file / dev / servoblaster, in which you can write something like 150 = 0, where 0 - number of the channel, and 150 - pulse length of tens of microseconds, that is 150 - is 1.5 milliseconds (most servos range of values 700-2300 ms).
So, connect the controllers 7 and 11 GPIO pins and run servoblaster team:
& lt; code class = & quot; bash & quot; & gt; # servod --min = 70 --max = 230 --p1pins = 7, 11 & lt; / code & gt; pre> Now, if we write to / dev / servoblaster line 0 = 1 = 230 and 230, the tank explode forward.
Connecting the camera
Ride up and down was great, but would like to do it at least in the next room, and ideally all over the internet, so it was necessary to establish a real-time video. On the Internet found a simple project tinycamd . project is a service that is managed by http, can take screenshots and change camera settings. Not much, but better than nothing I have not found, so I had to remember with and build upon what the author did not realize, namely, broadcast MJPEG stream for HTTP (by the way, as the modified source code share with the world?). Here it is critical that JPEG came with the camera, processor Raspberry on this is not enough. As a result, I was connected to the tank by ssh, opened the video stream through the browser, go to the house and was happy as long as it sank channel. It was very funny to first look at the frozen frame, and then get all stuck in an accelerated mode. Realtime streaming video over TCP - is evil.
Upgrades, improvements, etc.
Then came the long process of writing the server and client side Python library using c pygame to receive events from the gamepad, dopilivanie tinycamd, so he sent video streaming over UDP and setting the camera on a tripod of servos to be able to look around. Then went to the tank first trip to the office beyond line of sight. At this point, it is understood that not only wants to watch, but also to have two-way audio channel, for example, to ask colleagues to open the door or call the elevator.
Sound
To play a sound was to use cheap pocket USB speaker, bought in the supermarket stock. It was connected together with a simple microphone via USB zvukovuhu. To work with sound in handy library pyalsaaudio . After dopilivaniya server and client have the opportunity during rassekaniya the tank to talk and listen.
Light
Next fichey was light. At some point it became clear that the sensitivity of the camera can easily be missed, and there is a chance to call in the dark and do not leave. The first idea was to infrared light. Was assembled line of infrared LEDs, but experience has shown that the use of them to zero. The light is very bad and small. A ready-infrared illuminators require 12V power (and I have only 2 banks, ie the maximum 8c), guzzle a lot of current, cumbersome and are expensive. As a result, it was decided to go into the visible range, were purchased two powerful white SMD LEDs and lenses to them. To power the lights work colleagues was created by the driver from the current regulation, which is enabled through the FET supply unit on GPIO leg Raspberry. From now on, the dark rooms are no longer an obstacle.
Battery, the exact level of its charge
At all stages, it remained unclear how much longer you can go without killing the battery (Li-Po can not be discharged below 3.3V than the bank). I have not found a way to measure the voltage via GPIO feet Raspberry, therefore, as a measure put Arduino Nano, which in the future directly connected LCD screen c I2C adapter. The battery is connected via an analog divider half foot Arduino, leaving only calibrate the readings. Arduino traditionally communicates with the main unit via a COM port that is also displayed on the Raspberry GPIO feet.
What a tank without a gun
One of the last parts of the tank was the gun. The gun was bought right there in the store in the form of radio-controlled models of parts. She, however, was intended for another model of the tank, but the gist of it did not change. Pneumatic gun, has an engine, cocking spring piston, and contact that closes when fired. The horizontal pivot gun I have yet to give up in order not to carry it all the kit, which fastened on the top cover, and for vertical use powerful servo. To make it easier to steer, I did turn the gun over synchronous with the rotation of the camera. That is where we look (vertical), there and shoot. For aiming at the barrel of the gun was fasten Laser Pointer LED on. So once again not to waste battery or laser light which is not necessary, it was necessary to make the gun is turned off. The process of shot is not quite as simple. It is necessary to turn on the power of the engine and wait for contact closure, after which the engine is switched off. As a result, control and power shot and servo laser was hung on Arduino, and generates a signal for servo Raspberry. Engine gun also had to carry out a separate power cable and turn it gradually using PWM, because otherwise the interference arrives on nutrition and Arduino goes to reboot. To submit shells, ie balls, was used box of pills TicTac with a hole in the bottom.
Probably for the first time will suffice. If you liked the article, I will quietly write the details in the following posts. And finally, some photos and video svezhesnyatoe. However, the quality was not very, so I apologize in advance aesthetes.
Source: habrahabr.ru/post/244407/
It's not that life is unfair - it you have the wrong conception of justice
Renewable energy - the biggest part of the electricity Scotland