Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All: Precise Camera Feedback messages #2383

Closed
wants to merge 16 commits into from

Conversation

taedla01
Copy link
Contributor

@taedla01 taedla01 commented Jun 7, 2015

Hello everyone,

Well, I think this is the ultimate for make affordable this thing...

I want to achieve the exact time and precise coordinates where the pictures are taken. It not depends on PixHawk, as it sends the order to trigger, but is the camera itself who actually decides when to make the shot.
Some miliseconds are wasted between Pixhawk triggering and camera shooting. This time is variable and depends on multiple factors: light, focus, shutter,... so the best solution is to use a synchronized flag or a signal, i.e, the camera flash (best solution that I found).

Well, this is not the best solution and sure this is the worst code you've ever seen, but... it works!

Please give me time to complete here the explanation of how to add the hardware necesary for this and how the code works.

Here you are:

Firstly you need an universal Hot Shoe adapter. Not all Hot Shoes will work. You need one that supports Preflash and Flash Ready emulation. I have tried 5 adapters and just one has worked...
Connecting it to the PixHawk is very easy, as you can see below, but be careful: BE SURE THAT YOUR CAMERA OUTPUTS A MAXIMUM OF 5,7 VOLTS THROUGH HOT SHOE FLASH PINS or you will burn your PixHawk.

hot-shoe-trigger

Secondly, you need to configure CAMERA_FEEDBACK_PIN through Mission Planner.
Then, when the function do_take_picture will be called, for example with "Trigger camera now", the code will generate a flag for wait to the Hot Shoe response.
If the Pixhawk detects an input from the Hot Shoe pin, i.e, camera has been truely triggered, a CAM message will be saved to the Dataflash log.

Finally, code will reset the cicle, waiting for a new do_take_picture.
With all, we have a consistent Log, with the same number of CAM messages and pictures, and the best... precise coordinates and time marks for each picture.

I have included an option for log a "TRIGGER" message that corresponds with the "normal" CAM messages. So now we have two signals or logs for the trigger process: when you require to the camera to shot a picture, the "TRIGGER" (TRIG) message is generated, and then, when the camera really takes the picture, the "CAMERA_FEEDBACK" (CAM) message will be saved.

This is highly useful for compare the time and conditions we have between we order the trigger with the autopilot board and when camera really takes the picture.

sin titulo

For configure the "TRIGGER" message, you need to enable it trough CLI, i.e, Enable CLI in the full parameter list and reset the board. Go to Mission Planner/Terminal and connect with the controller. Then activate (enable) the TRIGGER msg typing "ENABLE TRIGGER" inside logs menu (for Rover #2381 has to be merged).

Tested with ArduPlane, ArduCopter and APMrover2 on APM1/APM2 and PixHawk.
Fully compatible with Sony NEX series and Olympus E-PMx series (both with universal hot shoe adapters).

I can provide log files to confirm the operation of this pull request if necessary.

Regards,
Dario.

Added _feedback_pin;
Added _camera_triggered;
Included FEEDBACK_PIN parameter and his default definition
DataFlash.h: added support for Trigger MSG, supressed TAB separations
and file reorganized
LogFile.cpp: included Trigger packet
Message DISABLE by default. Can be ENABLED trough CLI
Message DISABLE by default. Can be ENABLED trough CLI
Log.cpp: corrected according to defines.h
Message DISABLE by default. Can be ENABLED trough CLI
Log.cpp: corrected according to defines.h
system.cpp: included support for digital pin. Already included in
APMrover2.
system.cpp: included support for digital pin. Already included in
APMrover2.
Corrected comments and functions added
Added update_trigger and check_digital_pin functions
Added update_trigger and check_digital_pin functions
@taedla01 taedla01 changed the title Precise camera trigger All: Precise Camera Feedback messages Jun 7, 2015
@WickedShell
Copy link
Contributor

Based on my conversation with @tridge when discussing the initial issue #2309 it makes more sense to do this using interrupts much the same way that the PulsedLight can input information (timers triggered on rising edge). And it makes more sense to simply extend this aspect that is currently hardcoded. The goal here is to avoid polling for the pin state, as that requires external circuitry in the flash hot shoe adapter, meaning that only some hot shoe adapters will work. (as well as being a slightly less accurate method). My benchmarking in the past has shown a very short signal here for the flash, that could easily be missed.

I'm willing to do the rework for it, but I think it's going to take at least two weeks to a month before I get to sit down and look at this aspect of it. This should also still log the standard cam message as well as the trigger feedback message (allows tagging software to handle a photo where the feedback was missed, as well as diagnose if commands were simply sent to rapidly to trigger the camera).

@magicrub magicrub added the Plane label Jun 10, 2015
@magicrub magicrub added this to the Plane 3.4.0 milestone Jun 10, 2015
@taedla01
Copy link
Contributor Author

Hello everyone,

@rmackay9 @WickedShell @tridge
WickedShell has proposed a solution based on PulsedLight sensors code, ie, timers triggered on rising edge.
Our last efforts to make this to work have resulted on a halted Pixhawk board due to electric noise coming from the camera. Here you can see the noise going through the Pixhawk:

img-20150709-wa0073

Seriously, we need to isolate wires between camera an controller with an aditional optocoupled electronic board. So we can not connect directly the camera hot shoe to the Pixhawk.

The measurements that we have realized with several cameras (Olympus, Sony Nex series, Ricoh, Canon) show that the hot shoe trigger duration varies between the camera brands, for example, Ricoh outputs a signal of 1ms, as opposed, 12 ms for Canon.

Ricoh hot shoe in action:
img-20150709-wa0075

We have made an electronic that solves this problem and universalizes the use of this pull request. So Universal Hot Shoe adapter is no more needed.
This circuit is very simple, based on an optocoupler, little capacitors and resistors, which raise the hot shoe trigger to an standard value of 20ms and elevates the logical level for polling the pin. We have to improve a bit the aesthetic of the new electronic, but is fully functional.

The different between using this pull request or not is that the camera shutter lag causes a mean deviation of photographs of about 2 meters from their ideal coordinates.

We are using a RTK GPS system, so achieving the best georreferenced photos is crucial for simplify postprocessing work.

Some users have already asked me about when this code could be included due to the high accuracy it grants. I can provide logs and software jobs that support the difference in time, effort and result that means the use of this pull request.

So please consider merging this new code.

Thanks for your time and effort,
Dario.

@wjax
Copy link

wjax commented Aug 14, 2015

Hi Dario,

I just wanted to say thanks for this great addition (whenever that happens to be merged). Also thanks for the awesome explanation and time you have taken to investigate signal timings etc.

Efforts are beeing made in L1 and L1/L2 GPS raw recording with Ublox and others and this is the missing part.
I hope devs consider this PR as it pushes the APM autopilot another step closer to non-GCPs surveys.

Does anyone knows if this is going to be merged?

A+

@WickedShell
Copy link
Contributor

I thought I had replied to this awhile ago, but it apparently got lost in my email as a draft instead...

Yeah the optoisolater is an expected requirement to do this. Would you mind sharing the circuit you used?

Have you had any cases of having photos but not having a feedback time for them? This is still my biggest fear about polling as opposed to using a hardware capture timer.

@taedla01
Copy link
Contributor Author

Hello everyone,

@WickedShell, we are working on developing a final circuit. It will be integrated on an universal hot shoe, so any camera with an universal hot shoe rail will be able to work perfectly. It has a Camera Trigger integrated too, so you just need to use one hardware to trigger the camera and give the feedback to the Pixhawk. Our plans is to make it open source, but maybe would be a good idea to have the support of 3DR or anyone that could make several pcbs.

I have several flights with more than a thousand of photos, and always I have been having the same number of photos as CAM messages (and of course my new TRIG messages). I have a Microsoft Excel macro for verify the messages and photos reference numbers plus the GeoTool on Mission Planner. Yeah! It works like a charm! The key is to standarize the hot shoe trigger duration, and this is made by our circuit.

The results on photogrametry software are impressive... less than 1 meter of absolute error in Photoscan without an RTK system... Give me some hours and I will be able to post here an example (I am on holidays).

Here you can see one of our prototypes:

xa9rflicf6nctral3z2pgl-2dnm4ylzw50zm-f1cm78

I need to make in this Pull Request a Little change to adjust the frequency of the function before it can be merged...
For more information please, contact privately with me.

Regards from Spain.
Dario.

@taedla01
Copy link
Contributor Author

Hello everyone,

@WickedShell @rmackay9 @tridge :
As it promised, here you can see the difference between using the normal CAM message (called TRIG in my code) and the new CAM messages generated with the help of the Camera Hot Shoe:

*Always working on WGS84 coordinates. See and compare photo data between both images. As you can see, same flight, same photos (34), but different coordinates and therefore different result.

With normal CAM msgs (here is called TRIG):

la caldera 11 - camvstrig jpg

With custom CAM msgs:

la caldera 11 - cam jpg

The difference is obvious. ;)

Cheers,
Dario.

@magicrub
Copy link
Contributor

This needs a rebase on master due to the namespace change of HAL to access hal.*

@magicrub
Copy link
Contributor

Closing due to working being required and rebase request ignored. Please reopen if you are able to rebase.

@magicrub magicrub closed this Dec 15, 2015
@magicrub magicrub modified the milestones: Plane v3.5.0, Plane 3.4.0 Dec 21, 2015
@CraigElder CraigElder reopened this Dec 21, 2015
@taedla01
Copy link
Contributor Author

Hello everyone,
I am sorry for not to have answered before. In recent months I have been busy with other projects and thought that this pull request had been rejected. I've seen the ads about this PR when I was searching into my oldest email address. It's Christmas and it could take some time to update the pull request if necessary. I need some days to update my knowledge regarding latest master branch changes.

Regards from Spain,
Dario.

@jmachuca77
Copy link
Contributor

Created a new pull request with the rebase for this pull request #3446
Dario if you could test it with your hardware that would be great, I have to create the hotshoe adapter in order to test it.

@magicrub
Copy link
Contributor

magicrub commented Jan 7, 2016

closed, replaced by #3446

@magicrub magicrub closed this Jan 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants