Hi guys this is another late night post but I'll try to lay it out right.
I have updated the:
- Camera tracking code to use the new DCM maths
- Camera control code to use the APM_RC stuff instead of the outdated servo_out (ashame to be honest as that was very easy to use but the new one is more accurate).
- Waypoint activity sketch to work with the new location variables (thats the only change but it make the code look harder than it is).
Thanks to Mr Doug Weibel my fears of complexity have been allayed and everything needed to get this going is in one config file. . As I have received interest I am releasing this before I have flight tested under the new APM2.1 release. My previous blog posts show my old camera setup with retraction and targeting but I now have a GoPro so its back to the drawing board.
Camera Sketch Download v1.10 (whenever I edit the file I'll increment - thanks to those wanting more)
Extract the zip file inside your APM2.1 folder with the rest of the sketches, add #include "Camera_Config.h" at the end of the header includes section in the ArduPilotMega.pde, add the do_control_video case in the handles_must void of the commands_logic.pde, add the verify_do_control_video case in the verify_must void of the commands_logic.pde and overwrite test.pde (it has a test for the camera servos).
(Click the picture at the top for an animation for where - not sure why its not doing it always though guess ning isn't gif friendly).
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.
For setup of the variables use the comments next to the variables in the config as well as the picture below.
Updated:
- Fixed codebase problems, Johann's check created, Euler angle incorrect units now fixed.
- Added stabilisation (two lines and no mathsm stupid to leave it our really).
- Added relay triggering method (thanks Kirill).
- Two methods for waypoint triggering now coded.
- Added two new triggering methods that should limit vibration.
- Separated the voids used by APM (mavlink ones and test code).
- Added test code for the camera servos (pan/pitch, tilt/roll and trigger not retraction).
- Added PAN_RATIO and TILT_RATIO to variables to change movement of servos easier.
- Alter test code to move in 15° steps around axis so checking of servo movement ratio can be done.
- Created new targeting code that works with all limited movement servo (<360) fitted the the bottom or top of the plane.
- Diagram on the maths for calculating the virtual co-ordinates
Waypoint Triggering - Do something at a waypoint.
- 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 - use camera
- servo_pic - wiggles the servo to press the camera button. You need to adjust the wiggle 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 - its only pointing at home still but with waypoint planning hopefully working this may be updated soon so it will actually be useful :) until then I wouldn't worry about it.
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.
Stabilisation
Add cam_stabilisation(); to the fast loop of the ArdupilotMega.pde just before the } at the end.
Testing your camera setup
With everything in your airframe and ready to test the connections to your servo setup and that you have configured it correctly use the test section of the CLI and use "camera". The test will:
- pan left to right in 15° increments
- pan right to left in 15° increments
- tilt up to down in 15° increments
- tilt down to up in 15° increments
- take a picture
To check angle increments use 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.
I used the previous iteration (APM1.13) of this code happily but with the changes I may have borked it somehow. The config file can be changed by anyone and has details on what each variable means.
If you do not understand any of this do not use it. This is for those pushing the envelope.
Disclaimer: I have not flight tested this code yet, I nor DIYdrones take any responsibility for damage caused.
Comments
Thanks.
Very strange about the board issues.
I can not view your page even though we are "friends" I get a memory problem from the server.
Thanks, I really would like to get to the bottom of this, it's keeping me up at night.... LOL Are there any other changes that are not posted in the V10 file?
Everything works but the tracking....
Your test.pde is the same as mine as far as I can see perhaps I picked it up after you had downloaded it. Weird that I have the same board and my outputs work as 1-8 fine while yours do not though. I'll keep poking. You can send me stuff over a message btw
Ritchie,
I have made your camera tracking mods to the latest version of APM. the Test file needed some changes to compile.
I had to change subtract 1 from each servo number to have full use of pan tilt and click.
I checked stabilization, worked great. Unfortunately I still cannot get the GPS tracking to work. it seams like it has wrong GPS location or something. The pan goes hard over, then jumps occasionally, no matter the location or velocity to the home wpt. I even have pressed the reset on the red board after GPS lock.
Thanks for your help!
If you have the older foxtrap IMU board the reset button does not work and once lock is achieved you need to reset otherwise the system does not work at all. With or without my code. As you can read from my post linked earlier I had awful problems until Chris told me.
My code does nothing to the navigation code it is only using space in the cycle. So I do not know why you navigation is not working apart from not doing a reset once you gain lock.
Has anyone else had success using the newer 1-8 board?
Well the board version may be significant I cannot confirm that without more data though. I have the ch0-7 1280 version and the Foxtrap board. You realise on the foxtrap board you can only reset by pressing the button on the APM board not the IMU right? Foxtrap reset had a bug further generations have been fixed though (mentioned in the comment of this post).
The servo movement is restricted by the code to you variable choices so you will only see a small amount of travel with only 50° and the camera trigger should sweep 90°.
I am completely stumped still why the servos are not in the right place but the movement is probably down to the settings.
Your ranges seem awfully low, is this deliberate or actual servo throw?
You have not changed the 10.31 ratios, do the servos actually move 15° accurately?
Ritchie,
I have added you as a friend, when I look at your page, there is a problem with ning.
I only have two servos sitting in the plane with servo arms on them for visual reference. I will build my mechanism this weekend.
#define CAM_SERVO 8 // Camera servo channel
#define OPEN_SERVO 5 // Retraction servo channel - my camera retracts yours might not.
#define PAN_SERVO 6 // Pan servo channel (can be pitch in stabilisation)
#define PAN_REV 1 // output is normal = 1 output is reversed = -1
#define TILT_SERVO 7 // Tilt servo channel (can be roll in stabilisation)
#define TILT_REV 1 // output is normal = 1 output is reversed = -1
#define PAN_CENTER 0 // Camera center bearing with relation to airframe forward motion - deg
#define PAN_RANGE 50 // Pan Servo sweep in degrees
#define TILT_CENTER 0 // Camera center bearing with relation to airframe forward motion - deg
#define TILT_RANGE 50 // Tilt Servo sweep in degrees
#define CAM_ANGLE 30 // Set angle in degrees
#define CAM_CLICK 45 // This is the position of the servo arm when it actually clicks
#define PAN_RATIO 10.31 // match this to the swing of your pan servo
#define TILT_RATIO 10.31 // match this to the swing of your tilt servo
Others have had channels mixing like this and I do not know why yet. I even went as far as getting servos lined up to test but they all functioned normally (pan moving left to right as a full sweep, tilt moving left to right as a full sweep and the camera servo moving just a little).
Friend me and include the changes you made to the cam_config.h file (this is an absolute must) as well as a description or photo of your setup (so I know roughly how it is setup).