Control PWM while APM is running

Hello folks.
I am trying to control PWM while APM is running. I would like to run a python script similar to the example in the GitHub docs. I need a PWM signal to activate my camera. But every time I try to run the script with APM running, it returns Error that says APM is running so that I can’t run the example. And when I comment out the APM check in the script, it returns IOError Errorno 1: Operation not permitted.
I would like to know how can I send a command so that I can send a PWM signal to my camera.

Also, how can I run a python script like the Servo.py example on the raspberry pi(Navio2) via ros? I want to be able to activate my camera from the GCS.

Thank you for your help:)

Image and ArduPilot version.
Image: latest image on emlid site - emlid-raspbian-20180525.img.xz
Ardupilot version: ArduCopter: 3.5.5 as mentioned at emlid documents
Ground station: Mission planner 1.3.56.3 build 1.3.67249097

camera: Flir duo

Hi Akihiko,

It is not recommended to run Servo.py example when ardupilot is running.

Could you please describe more detailed what you are trying to implement? You should be able to control a lot of external hardware directly from the APM.

Hello, tatiana

I am trying to turn on my camera via ros(mavros). The camera would be turned on when there is a 1/20PWM signal into it. I want to be able to control the camera during flight via mavlink(mavros). Is there a way to send commands from the GCS to control the PWM signal?

Have you checked the ardupilot docs? It’s more likely it can help you with it.

Yes, I did. I want to be able to control the camera from the terminal, but APM docs mostly just talk about mission planner GCS. I want to use Ubuntu as GCS so mission planner wont work for my situation.

Akihiko,

Parameters described in Ardupilot docs can be configured in any GCS, not only in Misson Planner, cause they are generated by the ardupilot source code.

Hello,

i’m having a similar problem and i have to do a similar thing ( altough i need a finer control than only 2 positions open/close, i need to set continues angles ).

Excluding the Servos that are controlled by the flight controller ( for rudder, ailerons, thrust, etc. ), let’s say i have a single servo on the channel 14, can i control it separately? For example publishing on a ROS topic?

Hi Nicola,

It should be possible to control Servo using ROS. However, there are no ready solutions, so you need to do some research to implement it.

Ok, i figured it out:

On your GCS, in my case is QGroundControl, if you attach the servo to the X port, then you have to find the SERVOX_FUNCTION parameter, and set it to RCINY , with Y the (unused) channel you want to use.

then you can pub on the ros topic /mavros/rc/override on the Y channel (note: i’m quite sure that if the other value for the channels are at zero they wont affect the normal behaviour of the craft, but i didn’t do enough test to prove this )

1 Like