Easy camera roll stabilizer to APM


This is easy camera roll stabilizer to ArduPilotMega (I used code version 2.012). Camera mount was easy to build. Camera angle can be adjusted during flight with RC controller. Stabilization needs only one line code to program! Of course also pitch can be stabilized in the same time, but I have not yet tested this.

Camera stabilizer is normal mount with servo. Servo is connected to APM's sixth output port. (I have old 1.0 version of board, name is Out5, in new version 1.4 port name is probably Out6)

Optionally some free radio receiver channel can be connected to 6th input port(In my board name is In5, in new board probably In6)

Then I added one line to APM code: In the main program there is fast_loop. To the end of this subroutine, just above }, I added this line:


APM_RC.OutputCh(CH_6, constrain(g.rc_6.radio_in - (dcm.roll_sensor * 0.1),900,2100));


Then I uploaded program to APM, and thats it.


Also pitch can be stabilized in the same way. Servo and receiver goes to next channels, and this code can be added after the code line above.


APM_RC.OutputCh(CH_7, constrain(g.rc_7.radio_in - (dcm.pitch_sensor * 0.1),900,2100));


Some explanations to codes: It is easiest to think, that servo middle position is 150 degrees, in the program this is indicated as 1500. This is default value if receiver is not connected, and we get this value from radio receiver if knob is in the middle position.

Servo maximum turn is 60 degrees to each position, so we have minimum value 1500 - 600 = 900, and maximum value 1500 + 600 = 2100. These numbers are in the code above. If we want to reduce movement, then we must change these values. For example if camera can turn only 20 degrees to each direction, the values are 1300 and 1700.


Stabilization works always, also on manual mode. Camera can turn even 60 degrees to all directions. Probably analog servos are better, digital servos jitters very often.

In the forum there are some drawings from some other camera mounts http://www.diydrones.com/forum/topics/apmimu-camera-stabilization

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • @SciFly...and thats why we love it!
  • Someone else might beat me to it, but I got an idea from my Dragon OSD, where at the throw of a switch, aleron and elevator becomes OSD menu navigation instead of controling the plane. This could proably be implemented when you are in stabilizing or loiter mode (or any other mode), then the Aleron and Elevator stick movement becomes camera movement instead. Then combined with this kind of stabilization it would be pretty cool.

    I have been thinking about putting a heli gyro in the look instead, but this implementation of using the APM is just brilliant.

  • @Bart... thats science!!
  • nice video, but are you also working on a trigger device to take pictures?

    (i know, you do a great job, publish your results and you get more questions on the things you don't have done yet, sorrry)

  • T3

    How about rotating the whole nose...



    For heavy load, use digital brushless servos (no China pls, they will need 1000 years more to do it properly, but they will do it).


    For Hitec, the angles map -90..90deg to 0.6...2.4ms PWM (you may need to set the servo correct resolution).

  • Great work. I will be using this in my own application. Thanks
  • Really Nice!  I was wanting something like this. Thanks.
  • Camera target needs a lot more code. Joe Holdsworth is working on it for the development team. I have already done it for limited movement servos (any range) and it's all on my blog but as it requires so much code to do both stabilization with pan and tilt control I have left out the definitions file to stop novices using it and endangering the airframe.
  • What about camera targeting?You will need only 3 lines of code?
  • Brilliant idea!
This reply was deleted.