PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
8.51k stars 13.51k forks source link

Camera trigger not working with control allocation #20334

Closed Jaeyoung-Lim closed 3 months ago

Jaeyoung-Lim commented 2 years ago

Describe the bug

I have tried setting up the camera trigger with the control allocation, but I could not get it to work

I am using a pixhawk4 and trying to trigger a Sony A7R camera using the seagul UAV Sync2

Expected behavior

The camera triggers on command

To reproduce

Run camera_trigger_test in nsh or try to command trigger with QGC

Log Files and Screenshots

Additional context

Jaeyoung-Lim commented 2 years ago

Camera capture seems to be not enabled even if CAM_CAP_FBACK is Enabled

INFO  [camera_capture] Capture enabled : NO
INFO  [camera_capture] Frame sequence : 0
INFO  [camera_capture] No trigger yet
INFO  [camera_capture] Number of overflows : 0
INFO  [camera_capture] Status chan: 1 edges: 0 last time: 0 last state: 0 overflows: 0 latency: 0

Failure on dmesg

ERROR [camera_capture] up_input_capture_set failed (-16)

@bkueng Is there anything more that I need to configure?

julianoes commented 2 years ago

I just ran into this as well trying to set up capture.

julianoes commented 2 years ago

From what I can tell, the capture pin is already configured as a PWM output when camera_capture tries to reconfigure it here: https://github.com/PX4/PX4-Autopilot/blob/06a0aedbdbd717cecc79b83a4686985950d83019/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c#L444

If I comment out pwm_out start in the startup camera_capture starts ok.

bkueng commented 2 years ago

@julianoes @Jaeyoung-Lim this broke recently by reordering startup commands. Can you test https://github.com/PX4/PX4-Autopilot/pull/20362?

Jaeyoung-Lim commented 2 years ago

I also noticed that when the TRIG_INTERFACE is set to Seagull MAP2, the trigger pin does not output the correct pwm output. The workaround is to set TRIG_INTERFACE to Generic PWM

saengphet commented 2 years ago

@Jaeyoung-Lim @julianoes @bkueng Hi, I tried to trigger the A7R and A5100 cameras both Seagull MAP2 and GPIO, but I failed to trigger them. The test firmware is v1.13.1. However, the previous firmware 1.12.3 works fine (I performed mapping many times, and no issue was found). Have you ever tested or faced this problem in v1.13.1 before?

The FC is Pixhawk 4 and Cube Orange, the result is the same that failed to trigger cameras. Airframe is VTOL, trigger pin56.

hamishwillee commented 2 years ago

@Jaeyoung-Lim Doesn't SEAGULL require two triggers? http://docs.px4.io/main/en/peripherals/camera.html#trigger-output-pin-configuration - I only see one in your actuator setup.

IN any case, when you (and/or @julianoes) get this setup with camera capture and trigger working, can you please

  1. reverify the docs are accurate
  2. document your setup? Image of the wiring, details of the trigger settings, and image of the actuator screen.
    • I can probably write something if you can detail your settings.

If you look at what is there now I have updated it in discussion with Beat about a month ago. But the core of this, including the geotagging stuff is more than 6 years old. The camera capture stuff is entirely "anecdotal". What we really need is stuff that people can copy-paste.

Make sense?

Jaeyoung-Lim commented 2 years ago

@saengphet Unfortunately I was not able to get it to work on a pixhawk4

IN any case, when you (and/or @julianoes) get this setup with camera capture and trigger working, can you please

reverify the docs are accurate document your setup? Image of the wiring, details of the trigger settings, and image of the actuator screen. I can probably write something if you can detail your settings.

@hamishwillee Once I get it to work yes :smile:

@Jaeyoung-Lim Doesn't SEAGULL require two triggers? http://docs.px4.io/main/en/peripherals/camera.html#trigger-output-pin-configuration - I only see one in your actuator setup.

The Seagull can be used with two wires, but this is for the "keep alive" function and is not required. I also tried with two, and I got it to work a few times, but not reliably.

saengphet commented 1 year ago

@Jaeyoung-Lim @julianoes @bkueng I can reproduce and confirm that the current master (22-nov-2022) seems to fix this issue. FC is Pixhawk4 and Cube Orange. TRIG_INTERFACE is GPIO. Camera: A7R and A6000. I wonder what the PR relates to this issue, I will try to merge it into v1.13.1. Because the UAV has already passed the flight test in MISSION mode.

the same problem https://discuss.px4.io/t/version-1-13-0-camera-trigger-pwm-does-not-working/29158

junwoo091400 commented 1 year ago

For visibility: Thread in discord where we discussed this as well: https://discord.com/channels/1022170275984457759/1042960930977353820/1042961591240495134