Trigger an arducam camera connected to Raspberry Pi during planned mission

Hello, everyone. I’m quite new to all this DIY drones community. I built my first quadcopter using Readytosky’s Pixhawk 2.4.8 and the Copter V4.1.5 firmware and I’m using a Raspberry Pi 4 as a companion computer and I wish to take photos with an Arducam camera connected to the RPi through commands on the flight plan tab at specific waypoints during an autonomous mission. Which tools do I need to do set up the camera on the raspberry pi and perform this task?

I’m aware of dronekit-python and MAVproxy, but I don’t see much activity regarding how to use them and I’ve been reading the official documentation to see if this is possible and I’m having a hard time to know where to start.

Hi am lookin for the same solution, my goal is to capture high resolution geotaged images using pixhawk + respberry pi 4 + arducam 16mp autofocus camera. It should be abble to capture geotagged images autonomusly in while completing a mission.
please let me know if there is a lead/hint/soution.
Thank you.

Have you had any success triggering the pi
cam from the ardupilot fc? Looking for best practice to do the same thing.

//Carl

The functionality isn’t there yet, but I am slowly working on adding this capability to @stephendade’s excellent Rpanion-server: Feature request: Local image and video recording (MAVLink camera control) · Issue #167 · stephendade/Rpanion-server · GitHub

1 Like

Yes, for a simple solution you can execute a simple python script on Rpi, which will be continuously listening for a signal from pixhawk (signal responsible for triggering camera ). after detecting the signal you can trigger the cam.
Example:

import RPi.GPIO as GPIO
import os, sys
import time
import argparse

# Init GPIO, use GPIO pin 5 as input trigger from APM/Pixhawk
camTrigger = 5
GPIO.setmode(GPIO.BCM) # specify which mode to use(BCM/BOard) for pin numbering
GPIO.setwarnings(False) # It is possible that you have more than one script/circuit on the GPIO of your Raspberry Pi. As a result of this, 
                        # if RPi.GPIO detects that a pin has been configured to something other than the default (input), you get a warning when you try to configure a script. To disable these warnings:
GPIO.setup(camTrigger, GPIO.IN, GPIO.PUD_UP) # You need to set up every channel you are using as an input or an output. To configure a channel as an input:GPIO.setup(channel, GPIO.IN)
                                             # pull_up (bool or None) – If True (the default), the GPIO pin will be pulled high by default. In this case, connect the other side of the button to ground. If False, the GPIO pin will be pulled low by default. In this case, connect the other side of the button to 3V3. If None, the pin will be floating

def SendCmd(shutter):
    os.system(f'cmd /c {shutter}') #Command Prompt will be closed following the execution of the commands.the command will still get executed, but you may not be able to see it on your monitor.

shutter = "libcamera-still -t 10000 --autofocus -0 newimage.jpg"

def capture():
    while True:
		if GPIO.input(camTrigger) == True: # reading input (high/low) 
			print("Shutter Triggered")
			SendCmd(shutter)
			# Wait for it to go False
			while GPIO.input(camTrigger) == True:
				time.sleep(0.1)
			print("Shutter Off")

capture()
GPIO.cleanup()

https://ardupilot.org/copter/docs/common-pixhawk-camera-trigger-setup.html

You can use above link to configure pixhwak aux pin for cam trigger signal.
I hope it helps.

1 Like