Controlling Raspberry Pi Camera module with Python RCinput not possible?

I attached a camera module to the raspberry Pi and have it taking a picture every five seconds, starting the Python script from rc.local. However I do not really want to take pictures when te quad is on my desk. I figured I could trigger the camera from the remote following the Python RCinput example. But that does not work, because apparently I can’t run APM and access RCinput through a Python script at te same time.

Is there a way I can achieve this?

1 Like

Probably not what you’re after, but anywho:

I ssh into the rpi over a hotspot (after I get a fix) and issue the command (raspistill or raspivid) over the terminal – and then take off. It was the quickest/easiest solution for me.

Let me know if you find a way to ingest the background process.

Thanks for the tip! But I would also like to be able to trigger the Pi Camera without always bringing a laptop into the field. Triggering it from the RC would also be faster. Was really expecting this would be a piece of cake with a Navio board…

According to NAVIO’s introduction, RCInput in PPM/SBUS is integrated in Linux sysfs as /sys/kernel/rcio/rcin .

I suppose once APM starts, it takes control of all the rcin files, reading up buffers from each file every loop, resulting in empty output of your code.

If it is the case, I think there may be a solution like disabling RCn in APM parameters list or altering the source code of APM, etc. So that APM leaves RCn untouched, then you can writing your code to read from that channel.

Have you looked at the DroneKit?

@beeven Thanks! At least I now better understand why it is not working. The solutions sounds seems well above my current abilities

@igor.vereninov Read about Dronekit before, but I thought ‘companion computer’ would mean ‘ground station’

Trying it out now, but I am having trouble connecting. Shouldn’t this work:
vehicle = connect(’/dev/ttyAMA0’, baud=57600, wait_ready=True)

Because it is not (dronekit.APIException: Timeout in initializing connection.)

@Etienne

I guess this thread can help!

Took a look at DroneKit today, it is something running on your mobile or ground station in place of APM Mission Planner. You can programmably control the vehicle. Once connected to your vehicle, the connection to APM Mission planner drops. It is not aimed to “execute our own program” in the drone.

@george.staroselskiy’s suggestion to modify UserCode.cpp is fantastic. I think it’s better to import our own library in the USERHOOK_init and put all our own code in that library, so that we don’t have to compile the whole Ardupilot every time we change our code.

@Etienne Companion computer does not mean GCS, it is an onboard computer that augments autopilot. It case with Navio2 it is a companion + autopilot in one. You can run DroneKit right on it. The error that you are getting shows that you should not connect two applications over UART ( it is meant for RPI connected to Pixhawk over UART). With Navio2 you should use UDP port. For example --connect udpin:0.0.0.0:14550

@beeven[quote=“beeven, post:8, topic:2665”]
it is something running on your mobile or ground station in place of APM Mission Planner. You can programmably control the vehicle.
[/quote]

You actually can, and you can run it right on the Rpi. Please see my response above.

May I know what specific camera module you attached to your Raspberry Pi and how were you able to make it capture image every five seconds? Thanks in advance :slight_smile:

I used a Raspberry Pi Camera Module (Buy a Raspberry Pi Camera Module 2 – Raspberry Pi) and wrote a Python script that launched on startup and takes and picture every five seconds.

Would you be kind enough to share your references in making the script. This is exactly what we need in our project Sir and we’re having a hard time figuring how to do so. Thank you :slight_smile: