HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Cheap RC airplane with "outboard" Pi Zero and camera

Tue Aug 08, 2017 6:59 pm

Some time ago I saw a 20$ free shipping offer on banggood.com for 2.4G Piper J-3 Cub RC airplane and ordered it. Besides just flying, I wanted to try adding a Pi Zero with camera to the 23g weight only airplane for flight video recording on SD card.

After having received the plane I did a lot of flights to learn how to fly. Finally I was able to fly despite heavy wind (climbing is easier with that) and even in heavy rain (the built in lipo did 10min normally, did 6:20min in heavy rain). The plane never landed like a real plane (I did not add the shipped wheels), and landing happend on grass.

The first "Pi Zero with camera" experiment I did was to add a 13.8g payload to the airplane and see whether it flies with that:
Image
Lucckily the airplane did fly, in case I chose a payload position that made airplane neither font- nor rear-heavy.

Pi Zero with camera and ribbon cable does weigh 12g:
Image

Pi Zero costs 6$ with shipping. v1 camera (only available in China) 7$ and Pi Zero ribbon cable 1.10$, with free shipping from China. Together with airplane that is 40$ in total.

Next experiment was to open up the airplane and do "something useful". I chose to replace the 5.4g 150mAh lipo with a 17.8g 600mAh lipo for much extended flight time. Here you can see the opened up internals:
Image

I had to create a connector adapter, and most importantly, connect red to black and black to red since the plug into board had opposite colors than used. This shows airplane after the changes, connector adapter is hidden in the airplane, total weight 38.3g:
Image

I did fly successfully, high, and long with this modified airplane. I really like to fly very high, but the problem with that was that I only saw a "dot" in the sky and it was difficult to see the orientation of the plane in order to do the needed flight controller actions. The control range according airplane packing is 80m. Tuesday two weeks ago I did fly high and it was windy. Result was that airplane got out of control range and I could not control it anymore. I did run direction of the plane while it crashed to earth, but I was not able to see where it did land. All I knew was that it landed somewhere in this 95mx33m search area (from gmaps pedometer):
Image

I searched more than an hour that day, in gardens and looking up high trees. I did not find the airplane and ordered a new airplane (for 22$ at that time, that price range is similar on banggood.com and aliexpress.com) the same day. Plan was to add Pi Zero and camera, and go on a Search&Rescue mission when 2nd plane arrives ;-)

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Tue Aug 08, 2017 7:25 pm

Build day :

Last Saturday 2nd airplane arrived, only 11 days after ordering. Saturday was build day for Search&Rescue airplane. The airplane initially did weigh 23g:
Image

I wanted to use another type of lipos (5.2g 160mAh) than the built in 150mAh, mostly because I have 10 of them. This easily allows to change outdoor after one lipo is empty and go for the next flights. I removed the shipped 150mAh lipo and added this connector, that had VCC and GND lines soldered to 5V and GND pins on Pi Zero. Again, as described in previous posting, I had to connect red to black and vice versa:
Image

Soldering is not nice, but the conector works after having taped the blank sections. It is not nice that Pi Zero always gets lipo power and is not controlled by airplane power switch. But plugging new lipo, getting all stuffed into the front and then locking up with rubber band takes less than a minute, This is the first prototype:
Image

Updating "/etc/fake-hwclock.data" on SD card before your flights will give you roughly valid timestamps, at least for the first lipo used, For each power on after lipo change time will restart at that stored in the file.
Last edited by HermannSW on Tue Aug 08, 2017 8:09 pm, edited 1 time in total.

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Tue Aug 08, 2017 7:45 pm

Virgin flights:

On Sunday morning I stood up early because only in the early morning hours there was not much wind according weather forecast. It was foggy, and the grass was wet from morning dew:
Image

After having connected the lipo the camera started taking 10s full HD videos with 10ms shutter time, then does a "sync" to make sure data ends up on SD card, and then repeats endlessly. This is frame from 1st video taken after power on:
Image

This is the bash scipt I used (with later slight changes):

Code: Select all

$ cat home/pi/camfly 
#!/bin/bash

cd /home/pi/out.dir
mv old old_
mkdir old
mv * old

cat /proc/uptime > login.`date +%s`.txt
sync

raspivid -t 20000 -fps 25 --shutter  1000 -o fly.`date +%s`.h264
sync

while (true)
do
# raspivid -t 10000 -fps 25 --shutter 10000 -o fly.`date +%s`.h264
# raspivid -t 20000 -fps 25 --shutter  2000 -o fly.`date +%s`.h264
# raspivid -t 20000 -fps 25 --shutter  1000 -o fly.`date +%s`.h264
# raspivid -t 90000 -fps 25 --shutter  1000 -o fly.`date +%s`.h264
  raspivid -t 300000 -fps 25 --shutter  1000 -o fly.`date +%s`.h264
  sync
done
$ 
Since Pi Zero runs headless I added call to that script to /etc/rc.local:

Code: Select all

$ tail -7 etc/rc.local 
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

/home/pi/camfly &

exit 0
$ 
OK, perhaps it is not wise to land unsecured Pi Zero and camera in wet grass, but I did that many times that morning. These photos taken at home are not for the fainthearted ;-)
Image

Waterdrops on CPU, connectors, and on camera board as well. Wet grass in the propeller:
Image

I totally agree that it is better to wait for the sun to come out and wait for drying grass.

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Tue Aug 08, 2017 8:25 pm

On tree:

The following (now 20s, 2ms shutter time) video shows a flight that ends after 15s on a 5m high tree. After that all videos show mainly this view:
https://www.youtube.com/watch?v=XKSEDmEXVfs
Image

After 3.5 minutes I tried to kick the airplane out of the tree with help of a 4m long stick. Not much happened besides wobbling branches. In the end this new view was reached:
https://www.youtube.com/watch?v=fEqA57vUjIg
Image

After another 4.5 minutes I had climbed the tree [I have never climbed a tree for more than 10 years, and was surprised that I was able to] and started grabbing the airplane:
https://www.youtube.com/watch?v=r9RwFvpjhmI
Image

In the end I found a free passage in the tree to let the airplane do a free fall to ground. The camera was still recording, and this frame unveils how I was able to climb onto the >2m high lowest branch of the tree ;-)
https://www.youtube.com/watch?v=LRNUT2GKip4
Image

The flight videos were taken with 2ms shutter time, and look not sharp enough to me. All videos after that were taken with 1ms shutter time.

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Tue Aug 08, 2017 9:47 pm

Very high flight:

This posting is on a very high flight of airplane, 90s full HD 25fps 1ms shutter time videos of 3:20min flight in total. I did remount the camera, from now on direction airplane front is top of image, before it was left of image.

The first video (0s-89s) shows start and airplane climbing higher and higher. The little white dot is me ;-)
https://www.youtube.com/watch?v=bo0iMjMv46w
Image

I don't know for sure, but would say the airplane was more than 40m above ground. Sometimes the video is shaky, but that is because of the wind up there, and because of the airplane total weight below 40g.

In second video (91s-180s, 1s sync time) airplane crossed line of high trees and flew (unplanned) over settlement, here with video timestamp, the frame is just before leaving settlement area:
https://www.youtube.com/watch?v=qa0Q50m ... tu.be&t=50
Image

While the camera is mounted below airplane and takes vertical images normally, it does take other direction images when flying a curve. Here I got a birds-eye view of our house (middle house of 5 row house block bottom left):
Image

The airplane seemed to climb higher and higher, so that I stopped motors to get it a bit more down as glider. Unfortunately the glider did not make any attempt to decrease height. The trick I used is to start a long left turn. Since turns do loose height with 2 channel flight controllers, that helped to bring down the plane. Third video shows 183s-200s, 2s sync time:
https://www.youtube.com/watch?v=g_bkWS6Wkv8

After back home I made these photos to document the exact positions of Pi Zero (I use that position for trimming) and the fixed mount of camera for the shown very high flight:
Image

Image

Btw, I am really impressed on the ruggedized nature of raw Pi Zero and raw camera. When plane crashed vertically onto grass, the acceleration makes the Pi Zero move into direction of ground, and camera ribbon cable gets dissengaged from Pi Zero. The camera connector is so easy to refill with ribbon cable that it is no problem outdoor.

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Tue Aug 08, 2017 10:21 pm

Search&Rescue:

OK, now we come to the part mentioned in first posting of this thread. I did not have time to go home and look into the taken airplane videos, when someone spoke to me and told me about his drone flyaway, and that he informed policy on that, and whether I may have seen it. I had not seen it, but told him that I lost my 1st airplane two weeks ago and, and that the airplane videos should help me to find it. His response surprised me, he said "your airplane is on top of a high tree" and then showed me.

At home I used my video material to "find" the airplane that way. And the airplane was so easy to find, see this video with timestamp. Lost airplane enters video from top right, and leaves at bottom middle, can be seen easily because its yellow:
https://www.youtube.com/watch?v=bo0iMjM ... tu.be&t=52
Image

That was the "Search" part, now comes the "Rescue" part. The airplane is really difficult to see in this 12M photo of high tree with smartphone camera of my son, you have to zoom in to find it (you can see the back rudder):
Image

We brought a 7m long ladder to the tree, my son climbed it and I secured the ladder. Then I gave him the 4m long stick, and that was absolutely needed to kick the airplane out of the tree:
Image

Back at home this photo shows both planes together:
Image

The 600mAh lipo showed a voltage of 0.82V, not good. But I was able to load it to 4.2V.


So now that the planned tasks are completed, next steps are to find out how long the Pi Zero W Wifi range with direct sight is. I have one on one of my robots, but need it there. That is the reason I ordered a new Pi Zero W yesterday. If direct sight Pi Zero W Wifi range will be more than 20m, next project will be FPV airplane control via gstreamer pipeline from Pi Zero W to lapop on ground (with camera pointing to front and not to ground).

Hermann.

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Wed Aug 09, 2017 7:36 am

I forgot one important point on the value of the seven 25fps full HD videos uploaded to youtube. I used "raspivid" to record the videos (see "camfly" script in thread above), and that stores ".h264" format files. While these have no format information, although youtube complains on that, it uploads without issues. And youtube default framerate is 25 frames per second, which matches my videos. But looking the videos shows sometimes quick moves of the view. Many of you will know, but for those that do not, youtube allows single-frame-stepping back and fore!
  • stop youtube play
  • press '.' to display next frame of video
  • press ',' to display previous frame of video
Only with this single frame stepping you can watch the details, you may try with the overflight of tree where 1st airplane got found:
https://www.youtube.com/watch?v=bo0iMjM ... tu.be&t=52

Btw, depending on flight height, the movement between successive frames in video is some centimeters, or meters (in any direction because of wind and/or curve flying). But it is always only a few pixels. I really like 90fps raspivid videos for high speed stuff (like counting frames per round of my circular robot moving with 18.9m/s or 68km/h). But these flight videos taken with 25fps -- and single frame stepping youtube videos -- show that 25fps gives a wealth of information as well !

Hermann.

P.S:
Single frame stepping youtube video I found a frame taken during a steep curve flight showing Neckar valley and Eberbach more than 100 height meters below airplane:
Image

tvjon
Posts: 531
Joined: Mon Jan 07, 2013 9:11 am

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Wed Aug 09, 2017 9:06 am

Excellent write up Hermann, & very entertaining too! :-)

Now to go & watch your videos...

ElEscalador
Posts: 538
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Wed Aug 09, 2017 12:23 pm

Well that's fun!
A few of my projects below.

https://www.youtube.com/playlist?list=PLdlhFMXxFUNlMpeqHipdSIO20pb4piHfj

User avatar
bitbank
Posts: 171
Joined: Sat Nov 07, 2015 8:01 am
Location: Sarasota, Florida
Contact: Website

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Wed Aug 09, 2017 12:43 pm

Very creative and thanks for sharing the link to the plane. It would be fun to also hack the remote control receiver to control it from the RPi0. Perhaps even create an automated flight path using a GPS+compass. Lots of possibilities for fun projects. How about adding a BME280 to measure the temp/humidity/pressure at different altitudes? Need to find a longer range transmitter to get to greater heights.
The fastest code is none at all :)

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Wed Aug 09, 2017 1:39 pm

bitbank wrote:
Wed Aug 09, 2017 12:43 pm
It would be fun to also hack the remote control receiver to control it from the RPi0.
Definitely!
Perhaps even create an automated flight path using a GPS+compass. Lots of possibilities for fun projects. How about adding a BME280 to measure the temp/humidity/pressure at different altitudes? Need to find a longer range transmitter to get to greater heights.
These are fun projects, but I fear that even adding a small pressure sensor may be a problem for that airplane model. 38.3g weight seems to be at least very near to maximal weight for airplane being able to fly. But you can reduce weight by removing ribbon cable and camera (2-3g) for adding other stuff.

I had similar idea, make Pi Zero hack the "remote receiver+motor controller" board to fly automatically. Without new sensors I wanted to use the sensor I aleady have on board, the camera. Directed to front it maybe could "follow" a 1st, manually controlled airplane. The code I would use for that would be raspiraw, which allows to directly work with raw bayer data received from camera. I just posted a question wrt "yellow" detection here:
viewtopic.php?f=43&t=189661#p1196510

P.S:
A 6 axis gyrometer with header does weigh 1.2g, a 9 axis gyrometer with header does weigh 1.9g.

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Wed Aug 09, 2017 11:35 pm

I did a high flight in twilight, until lipo was empty. This took more than 7 minutes, and was first high flight where videos were taken with 300s (full HD, 25fps, 1ms shutter time).

The short shutter time resulted in "black" frames, where only sometimes a white dot appeared. That was me with white T-shirt:
Image

I learned several methods on how to make a video brighter with ffmpeg. For most I did not have the filter needed installed. This was the command I used to increase brightness by factor of 8:

Code: Select all

ffmpeg -i inp.h264 -vf "split [main][tmp]; [tmp] lutyuv="y=val*8" [tmp2]; [main][tmp2] overlay" outp8.h264 
Image

That gave much more details, and showed the footpaths and other details. The 2nd video was terminated by lipo power exhausted, and the last seconds have not been written to SD card. I concatenated both videos, after 5min there is a short 3s gap where the last blocks from 1st video were synced to SD card.:

Code: Select all

ffmpeg -i 'concat:outp8.h264|outp8b.h264' -codec copy outpAll.h264
Here is the 6:58min video, don't forget to select 1080p in youtube:
https://www.youtube.com/watch?v=eVUE3xc ... e=youtu.be

What I find remarkable is that it is the normal v1 camera, not the NoIR camera. Many details are hidden in black, which can be unveiled by increasing brightness. Of course this video does not look as nice as those taken with daylight/sunlight.

Hermann.

P.S:
I tested the 1st, rescued airplane with a 10.2g 380mAh lipo instead of the 600mAh lipo, total airplane weight 30.1g. Had a 23min continuous flight with that.

Later I did put remote controller on our window board, started the motors and then went with only airplane outdoor to measure control distance. I was able to go near to creek with motors still running, a few steps further motors stopped, going quickly back motors started again. Theer are some small trees and garages near plain sight connection between controller and airplane, so the real controller distance may be even larger than 142m.That is definitely more than the 80m mentioned on airplane packing:
Image

cpunk
Posts: 58
Joined: Thu Jun 29, 2017 12:39 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Thu Aug 10, 2017 12:50 pm

Quite impressive for such a small plane. :) I'm used to them blowing away with wind. :D

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Thu Aug 10, 2017 8:04 pm

I'm used to them blowing away with wind.
I would have expected this for heavy wind myself. As I said I just recently learned to fly at all, never did before. In learning I tried to push the limits, fly with quite some raining, flying despite heavy wind. It seems that the motors are correctly sized, maybe even a bit oversized. If I move the Raspberry Pi into a little bit too wide back position, making the airplain rear-heavy, the motors allow to go nearly vertically into the sky, before falling off a side. They are just not powerful enough to complete a full looping. Three weeks ago I ordered a pair of spare motors for 1.39$, just in case. I had no problems with the motors I have in both planes, though.

Today I wanted to temporarily use the airplane camera for a side project:
viewtopic.php?f=43&t=189661&p=1197130#p1197130
Sadly "vcgencmd get_camera" always said not detected. I tried different ribbon cables at the other Pi Zero W, no luck. Them I used the camera sitting on top of motor test station for the side project. Finally I reconnected the camera back to airplane and tried there -- not detected :-( I was sure that ribbon cable was connected good, at camera module and at Pi Zero sitting on top of airplane. I looked around for another reason and saw the little connector cable from camera to camera board:
Image

I softly pressed on the connector and it made "click". Then I tested again, and now camera gets detected and works fine. The only explanation I have for this is that the very last flight yesterday evening, better its crash landing, was done with so much power, that it disconnected this little connector ;-)

cpunk
Posts: 58
Joined: Thu Jun 29, 2017 12:39 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Sun Aug 13, 2017 6:13 pm

The (fresh) water resistance of unprotected electronics is quite surprising sometimes (at low voltage?). :D

But salt water does things quickly. I have once landed a foam glider in sea, and within the 7 seconds it took me to disconnect power, the receiver and motor controller had already conducted a lot of electrolysis on themselves. :P

HermannSW
Posts: 177
Joined: Fri Jul 22, 2016 9:09 pm

Re: Cheap RC airplane with "outboard" Pi Zero and camera

Mon Aug 14, 2017 11:22 pm

The (fresh) water resistance of unprotected electronics is quite surprising sometimes (at low voltage?). :D
Yes, really.

Next step is to determine altitude by BMP180 pressure sensor connected to the Pi Zero on RC airplane.

Writing to SD card only helps after the flight. Last week I ordered a new Pi Zero W which will replace Pi Zero on airplane. It will act as "flying wireless access point" and provide webserver with altitude information.

On weekend I received new Lolin (Arduino) ESP32 with OLED. Plan is to power from wireless airplane remote control and act as airplane altimeter on ground, connecting to flying access point, querying altitude and displaying that:
https://www.youtube.com/watch?v=CcYm_lZPtZk
Image

Will be interesting how high WLAN connection will work, at least direct sight is given.

Hermann.

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 12 guests