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 #2309

Closed
wants to merge 30 commits into from

Conversation

@taedla01
Copy link
Contributor

taedla01 commented May 19, 2015

Hello everyone,

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.

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.

Tested with ArduPlane, ArduCopter (should work with ArduRover) on APM1/APM2 and PixHawk.

Regards,
Dario.

ziltoid2 and others added 3 commits May 16, 2015
velocity noise on the GPS can cause DCM to take a long time to
converge. If it takes longer than 30s then allow EKF to start
@WickedShell

This comment has been minimized.

Copy link
Contributor

WickedShell commented May 20, 2015

I really like the idea but I have a couple of questions about the implementation.

A) Have you tested this, and had good luck with always detecting the sync pulse? Past testing with the camera's I've had on hand have needed to use an oscilloscope sampling at 200MHz to briefly show the waveform, or using an interrupt, my testing showed poor accuracy in actually detecting the hot shoe when polling the pin. (And if you've tested, what cameras where used? It's going to take me a couple of days to dig out my hot shoe adapters and preform testing here).

B) I'm open to other ideas here, but I would like to see us log both when we commanded taking the picture as well as when it was actually taken. This is primarily related to my concern with point A) that we might not detect every actual photo, and I need to be able to resolve the data after the flight as best I can, even if that means some of my photos will have a larger delay and thus inaccuracy in their position.

C) The check_digital_pin helper function reapplies the pin mode/writes to it every time its called, is this truly desired/needed? (I haven't done enough with the HAL to know the answer, or if this helps with some platform).

@taedla01

This comment has been minimized.

Copy link
Contributor Author

taedla01 commented May 20, 2015

Hello @WickedShell ,

A)Yes, I've tried. I've been flying with this improvement past three years, always with APM1 (not exact same code) and now with PixHawk. As you said, usually modern cameras take a digital signal for activating the flash running too fast for be readed. For that reason, you need an universal Hot Shoe adapter which converts the digital signal into an analog signal (like a relay but all electronics). My camera is custom made, but I confirm you that code works with Sony Nex5.

B)If you look at the code, you see that only if the full cicle is true, can be return to rerun the log_picture function. Both are reciprocal.
Thus, the do_take_picture function can be being called, but if the camera does not return a signal that the photo has been taken, the CAM message is not stored.
My idea is to also store two messages in the log, the actual CAM message indicating when we made the call to do_take_picture, and a new one to which I have called TRIG and is the result of this Pull Request, which indicates when the camera is truly triggered and therefore when the log_picture function is executed.

C)I am not a programmer so I am not sure if is needed... Best would be that an official project programmer revise the above code.

Regards,
Dario.

@magicrub

This comment has been minimized.

Copy link
Contributor

magicrub commented May 20, 2015

Would be nice if the commit was cleaned up a bit. Needs an interactive rebase to consolidate and remove the revert.

@@ -937,6 +940,13 @@ static void update_mount()

#if CAMERA == ENABLED
camera.trigger_pic_cleanup();
if(camera_triggered == false && camera._feedback_pin != -1 && check_digital_pin(camera._feedback_pin) == 0){

This comment has been minimized.

Copy link
@jmachuca77

jmachuca77 May 20, 2015

Contributor

In general using "Magic numbers" is not very clear. I would add a define for what -1 and 0 mean (triggered, nottirggered). Also I think this should have its own loop, This loop seems to be for the camera mount (gimbal). And do a call into a function from the camera library, so that we don't have to duplicate code on Plane, copter and rover.

@@ -399,6 +399,24 @@ static void frsky_telemetry_send(void)
#endif

/*
check a digitial pin for high,low (1/0)
*/
static uint8_t check_digital_pin(uint8_t pin)

This comment has been minimized.

Copy link
@jmachuca77

jmachuca77 May 20, 2015

Contributor

Is this function missing from Rover? I only see it for plane and copter.

This comment has been minimized.

Copy link
@taedla01

taedla01 May 20, 2015

Author Contributor

Hi @jmachuca77 ,
This function already was in Rover, indeed is a copy-paste from it. Originally was used for AUTO_TRIGGER_PIN.

@taedla01

This comment has been minimized.

Copy link
Contributor Author

taedla01 commented May 20, 2015

@magicrub, Sorry to interrupt you... Windows GitHub client is giving me headaches ... I made an interactive rebase but I do not known why I can not clean PR commits... Is there an option to change the entire remote branch of a pull request? Sorry for the inconveniences... I am rookie with GitHub.
Please feel free to make any change that you want. As I wrote above, I am sure this is the worst code you've ever seen...

@taedla01

This comment has been minimized.

Copy link
Contributor Author

taedla01 commented Jun 7, 2015

Reorganized and updated according to new format (C++) with #2383 so will close...

Sorry for the inconvenients...
Dario.

@taedla01 taedla01 closed this Jun 7, 2015
@taedla01 taedla01 deleted the taedla01:Precise_camera_time_mark branch Jun 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.