Camera Tracking

3689387855?profile=originalPan & Tilt with retraction running on Arduino 2560 (not APM) with some quick test code - 480i version

 


With Ardupilot Mega now in full swing and my brain going haywire thanks to the rubbish weather I have been taking distractions where I can (IR radar system for my computer desk, a segway for my action man, web enabled curtain opener and more).

Over a few hours I had my scribble pad out with some vernier calipers and a Cirrus CS301 servo. The result was a fairly small fully retractable camera system (at least in doodles). Wanting to create a quad from CF a friend offered his laser cutter (free of charge) but wanted a test subject to see how it cut. A few days later the doodle was CAD'd and then lasercut out of CF. I had three fit on a single sheet which leaves room for when I break it.

3689387917?profile=original

The entire mechanism is 120mm x 35mm x 35mm when "retracted" (these settings are yet to be finalised on plane) while when extended the assembly is  65mm below the plane. Unfortunately the camera must then be added to the bottom making it larger but as my camera (eBay keychain camera £4 each :D) is 34mm x 12mm x 55mm its quite nice.

Only thing left to do was the coding which I'd already started thinking about anyway. It uses lots of pre-existing code from within the APM sketches (so I know it works and if not I broke it). As long as the camera is on the bottom of the plane (level XY) it can be rotated in any direction (so if centered the camera will face right at 90°) and still track a GPS position. Using a few defines and a bit of math any limited movement servos can be used to track a GPS position.

As Ardupilot has been moving in this direction I undertook this myself with a hope of creating something worthy of general release later after I and the bosses had tested (why I haven't given out some details). This was saved to my drafts so it would not be published until I had finished writing the blurp explaining all of this but apparently "Save as Draft" means publish immediately. It is very flexible thanks to the variables changing servo output direction and matching center facing direction with flight bearing its limitation is just the level downwards mounting. That is my next task after testing this.

Edit: New code loaded with proof of concept spreadsheet. Here is hoping for some good weather.

3689387869?profile=original

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • If you setup the mount orientation correctly you can have it facing anyway you want with any travel amount.

  • You posted some software in the APM manual for camera tracking, and I assume that it is the latest thing. After following your instructions and not being profecient in programming I could not get it to compile. I believe that there are some other things that must be done in order for it to work. It would be wonderful if you could get it down to exactly what has to be done for non coders like me. Examples would be great. Thanks for your efforts in bringing tracking to us. I just need a little extra help.
  • Ok well APM 2.1 is out and has borked my files. I will updated when I've fixed them enough to let loose on the population.
  • Ok here is the proof of concept spreadsheet. This will let you have a look at the maths in action and wobble your head trying to find out if it is right like I have been.

  • Ok so with my muppet mistake I was get bearings referenced north and not by aircraft heading. Thanks to some wrapping all I had to do was subtract the heading from the calculation at the end.

    My real head scratching was when I was trying to figure out if the math was correct in my head (doodling didn't help either). The end result was an excel spreadsheet with some fictional information using a 10x10 grid with the plane as 0,0 in the center. I chucked some point round the aircraft and put with co-ords in a table.

    Next I simply used the maths I'd created to check whether I was getting what I wanted. Was I? No. Time to play with the variables or so I thought. Yet again I had made muppet from myself and caused the problem myself, sqrt(sq(?)+sq(?)) was sqrt(sq(?)*sq(?)). Changed and things looked WAY better. Changing one variable I got the correct results for simply level flight (only place I could check easily). Adjusting the pitch and roll cells in Excel I was the numbers change and with some eye measurement saw they were in the right direction too.

    Next part is tonight and will be transferring the Excel version into the APM code. Then its testing time :)

  • Mine will not because it uses the servo library in the APM codebase. You could you stepper motors or full rotation servos but once you do that you need to keep track of the last position and modify your tracking movement based on that position so wires do not become entangled and pull off the APM (stopping you controlling them) or break your mount (possibly ending with your camera going smash from 400ft).

    Remember this code works with ANY limited rotation servo as long as you enter the details correctly. So if you could get a 350 degree servo for the Pan part it would be almost perfect.

  • I wonder if it also will work with stepper motors.
  • I've now mounted the setup without camera to my EZ* so will do a "test" to show you guys how it should work. The code has a major omission :D that would be calculating the bearing using the get_bearing which I'm fairly sure means my bearings are always referenced due north...Doh!

    Time to find the heading variable and replace :D

  • Okily Dokily. The code is up for your eyes to look over.

    The idea is:

    • use the old code I threw together to do the pan and tilt as before.
    • create virtual co-ordinates based on the orientation of the plane and the relative lat, lon, alt from gps.

    I'm hoping that the values will work out ok but I've probably borked something. Nevermind though I'm doing my best for you guys.

  • Well then folks, after a busy weekend (60th birthday - not mine) its back to the jiggery pokery. After I poked through the Attitude code and looking at Joe's code I came to the realisation that I would need a plan of attack for joining the simple pan and tilt idea with the simple jiggle compensation idea as do both from only two servos seems problematic (you only have to look at Pete Holland's code to grasp the enormity).

    How could I make a plane using a pan and tilt system take into account for the pitch and roll of the aircraft as well as point at the target we select. Could I compensate the jiggling in the pitch and roll then do the pan and tilt from those points? After using graph paper to do copious doodles it would seem not but hey they were only doodles. What about using the plane as an absolute origin so everything else around it is cartesian co-ordinates? Oh look the code for that is above but only in flat flight (never gonna happen). What about adjusting the co-ordinates so that they are no longer subject to a pitching and rolling plane (pun intended)? Yep thats what 6 sheets of scribbles hidden away from sight I did while at a weekend long 60th celebration.

    I'll pop up the code once it has been changed from scribbles to code. Hopefully this one will pass the Weibel test ;)

This reply was deleted.