Skip to content
Arthur Benemann edited this page Mar 15, 2013 · 1 revision

http://api.ning.com:80/files/Dkny0E7F9OlMPEAEa8Ar4lpbCBr8TB2FMyfCLSXlkCN11H8BN1I4DlUcM1QCg*lFdI7UPMvMjtpOUMY5TK-5Ng__/CameraConfig.jpg

To enable auto camera tracking and stabilization, you must add some code to APM in Arduino and compile and load the code using that.

This code, contributed by Ritchie Wilson, add the following functionality:

  • Waypoint Triggering: Trigger the camera at a waypoint
  • Camera Triggering: Manually trigger the camera with a RC signal
  • Stabilization: Keep the camera level while the plane is turning
  • Position Tracking: Keep the camera pointed at a position on the ground

Instructions

  1. Extract the zip file found in this post inside your APM2.x folder with the rest of the sketches
  2. Add #include "!Camera_Config.h" at the end of the header includes section in the !ArduPilotMega.pde
  3. Add the do_control_video case in the handles_must void of the commands_logic.pde
  4. Add the verify_do_control_video case in the verify_must void of the commands_logic.pde

The variables in the config are fully commented so you can change them as you need. This works with all servos of limited range (<360) and the tilt servo only move to vertical so the picture is always the right way up. The crucial numbers are the PAN_RATIO and TILT_RATIO they adjust the movement per degree of the servos, get this wrong and the system will not point where it should.

Camera system needs to be on the bottom of your craft for this to work as you cannot track a ground target with your camera not able to point down.

Use the test in the CLI to check servo movement. The test will:

  1. pan left to right in 15° increments
  2. pan right to left in 15° increments
  3. tilt up to down in 15° increments
  4. tilt down to up in 15° increments
  5. take a picture To check angle increments use this picture this picture around your servo. If the movement is less than 15° you need to increase the ratio value and if it is more you need to decrease the ratio value. If everything moves as it is supposed to well done you have configured the entire setup and are ready to use it on a flight.

Waypoint Triggering

  • Waypoint triggering using the waypoint_check code you need to add waypoint_check(); to case 1 of the medium loop in !ArdupilotMega.pde then change the values in waypoint_check to the waypoints you wish to take picture at.
  • Mission planner to use waypoint triggering (far easier in the field) you need to add picture_time_check(); to case 1 of the medium loop in !ArdupilotMega.pde then in the mission planner add do_control_video waypoint to start and stop taking photos at waypoints.

Camera Triggering

  • servo_pic - wiggles the servo to press the camera button. You need to adjust the wiggle (CAM_CLICK) to press the button correctly without stalling the servo.
  • throttle_pic - turns off the throttle, waits (time), uses servo_pic to use camera then turns throttle back on. The wait is derived from the # of cycles the medium loop sees (default = 10).
  • distance_pic - turns off the throttle, waits (distance), uses servo_pic to use camera then turns throttle back on. The wait is controlled by the distance to the waypoint (default <3).

GPS Tracking

It's only pointing at home still but with waypoint planning hopefully working this may be updated soon so it will actually be useful ;-) Currently grabs waypoint 0 (home) and tracks that.

  • Add GPS_track(); to the fast loop of the !ArdupilotMega.pde just before the } at the end.

Stabilization

Add cam_stabilisation(); to the fast loop of the !ArdupilotMega.pde just before the } at the end.

Clone this wiki locally