Closed iskess closed 10 years ago
iskess, Are you talking planes or copters? or both?
I was thinking about Planes, but it should apply equally to both.
You could always use the DO_SET_RELAY or DO_REPEAT_SERVO command in the flight planner to trigger at a particular waypoint. It's a bit cumbersome to put one of thee commands after every waypoint, but it does work.
Also, if you are using CHDK scripting, you can 'activate' your camera at certain waypoints and deactivate when done. This tutorial explains the process: http://copter.ardupilot.com/wiki/common-chdk-camera-control-tutorial/
-Brandon
On Tue, Aug 6, 2013 at 10:18 AM, iskess notifications@github.com wrote:
I was thinking about Planes, but it should apply equally to both.
— Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-22195331 .
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
Both options you propose defeat the whole purpose of CAM_TRIGG_DIST. I don't want to associate the shutter with navigation other then to start and stop the distance based triggering at the beginning and end of the target area. . The CHDK option is a time based intervalometer, not distance based and leaves inconsistent overlap due to wind.
I disagree because when you launch your aircraft, that usually isn't the start of your Flight Plan.. Sometimes it takes a bit to get to your first waypoint when doing aerial mapping. Sometimes, to clear obstacles you set a few waypoints so you know it isn't going to run into anything. Maybe have a default to start distance calculating at a specific waypoint (CAM_TRIGG_START)? Or maybe even once your set altitude has been reached?
BTW Brandon, I merged your CameraPlanner into the current version on GitHub (locally anyway).. So far, it looks good, plan to try it out this week..
Dennis, Good to hear, let me know if you have any questions or comments.
Triggering a camera with DO_SET_RELAY or DO_REPEAT_SERVO is by no means the best solution for time/space based camera triggering. However, if I understood the original request correctly--to start camera triggering at a specific absolute location other than Home--the only way to do this is to associate the shutter with navigation. Currently this functionality is implemented at the mission planning level. Certainly though, a distance offset would be a nice addition to CAM_TRIGG_DIST, but that again would be a relative thing rather than an absolute location.
-Brandon
On Mon, Aug 12, 2013 at 7:39 AM, Dennis Megarry notifications@github.comwrote:
I disagree because when you launch your aircraft, that usually isn't the start of your Flight Plan.. Sometimes it takes a bit to get to your first waypoint when doing aerial mapping. Sometimes, to clear obstacles you set a few waypoints so you know it isn't going to run into anything. Maybe have a default to start distance calculating at a specific waypoint (CAM_TRIGG_START)? Or maybe even once your set altitude has been reached?
BTW Brandon, I merged your CameraPlanner into the current version on GitHub (locally anyway).. So far, it looks good, plan to try it out this week..
— Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-22497765 .
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
DO_REPEAT_SERVO? not DO_SET_SERVO? Maybe that's why I couldn't get that working! It would trigger on the first waypoint but none after that.. lol
Brandon, in the Camera Grid screen I added an option to use waypoints instead of CAM_TRIGG_DIST if wanted. But hard coded Param1 (Channel) and Param2 (PWM) for the waypoint (which was DO_SET_SERVO) as I wasn't to sure if I'd screw anything up by using the parameters list..
Denis, Did you try the 'draw interior waypoints checkbox? This basically draws a grid as gridv2 normally does with waypoints inside the box, not just at the edge. I like the idea though of being able to customize the output channel, that shouldn't mess with anything i'm, doing
Yeah, DO_REPEAT is the one you want--that one got me too!!
Just to let you know where i'm going with the Camera Planner, i'm going to make a basic tab and an advanced tab. What you see now is basically the advanced tab, the basic tab will have a pull down list of common sensor sizes and then altitude. Overlap and sidelap will be statically set at 50% The idea is to make the simplest possible screen that is likely to generate good results. I'll add camera channel control to the advanced screen.
-Brandon
On Mon, Aug 12, 2013 at 10:29 AM, Dennis Megarry notifications@github.comwrote:
DO_REPEAT_SERVO? not DO_SET_SERVO? Maybe that's why I couldn't get that working! It would trigger on the first waypoint but none after that.. lol
Brandon, in the Camera Grid screen I added an option to use waypoints instead of CAM_TRIGG_DIST if wanted. But hard coded Param1 (Channel) and Param2 (PWM) for the waypoint (which was DO_SET_SERVO) as I wasn't to sure if I'd screw anything up by using the parameters list..
— Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-22510238 .
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
Yeah.. sorry.. that's where I put the option because it used a function already that added DO_DIGICAM_CONTROL points to the flight plan in function AddDigicamControlPhoto(), so I copied that function and named it AddShutterTrigger() and then changed the MAV_CMD's to:
Commands.Rows[selectedrow].Cells[Command.Index].Value = MAVLink.MAV_CMDDO_SET_SERVO.ToString(); ChangeColumnHeader(MAVLink.MAV_CMD.DO_SET_SERVO.ToString(); Commands.Rows[selectedrow].Cells[Param1.Index].Value = 7; Commands.Rows[selectedrow].Cells[Param2.Index].Value = 2000;
So now has the option to do old or new inside waypoints.. :)
From my google searches, I don't think DO_DIGICAM_CONTROL works or at least doesn't work for fixed wing?
Can someone answer this part of the question:
"I thought perhaps I could use DO_SET_PARAMETER to toggle CAM_TRIGG_DIST, however it asks for the Parameter number and I don't know how to identify that."
you can see what parameters a cmd accepts in AdruPilot/Mavlink/MAVLinkTypes.cs and the column headers from mavcmd.xml
Perhaps someone can help me out and tell me if the CAM_TRIGG_DIST is can be controlled by the DO_SET_PARAMETER, and if so, what number do I enter to identify that parameter? I don't know how to seach the code for the answers yet.
Iskess, I thought that do-set-parameter mission command had been removed from the mission planner. I've never heard of it being used by anyone and it's potentially quite dangerous.
In any case, if you are somehow able to use it, i believe you need to provide an eeprom number. You can find the number for a particular parameter by looking in the Parameters.h file. You will see at the top of each group how the parameter has a number. So log_bitmask is "20". the next one, last_filenumber, would be 21, etc. I'm interested to hear if it actually works.
// Misc // k_param_log_bitmask= 20, k_param_log_last_filenumber, // *\ Deprecated - remove // with next eeprom number // change k_param_toy_yaw_rate, // THOR The memory // location for the // Yaw Rate 1 = fast, // 2 = med, 3 = slow
k_param_crosstrack_min_distance, // deprecated - remove with next eeprom number change k_param_rssi_pin, k_param_throttle_accel_enabled, // deprecated - remove k_param_wp_yaw_behavior, k_param_acro_trainer, k_param_pilot_velocity_z_max,
-Randy
From: iskess notifications@github.com To: diydrones/ardupilot ardupilot@noreply.github.com Cc: Randy Mackay rmackay9@yahoo.com Sent: Friday, August 23, 2013 4:51 PM Subject: Re: [ardupilot] CAM_TRIGG_DIST activation in a flight plan (#482)
Perhaps someone can help me out and tell me if the CAM_TRIGG_DIST is can be controlled by the DO_SET_PARAMETER, and if so, what number do I enter to identify that parameter? I don't know how to seach the code for the answers yet. — Reply to this email directly or view it on GitHub.
Randy, I don't know if it is working, but DO_SET_PARAMETER is still in Mission Planner. I searched through Parameters.h as you suggested and didn't find any reference to CAM_TRIGG_DIST. Actually there are other parameters that aren't listed in there, so perhaps there is another location? The only reference I found for Cameras was: // Camera and mount parameters // k_param_camera = 160, k_param_camera_mount, k_param_camera_mount2, Any other leads?
what version of mission planner are you using?
Just updated to .72 and its still there as a DO_SET command choice. Does it not work? Perhaps someone could test it with a benign parameter and see if it changes at the correct point in the flight plan.
it wasn't removed from apm:plane, it is now.
Why is it being removed? Does it not work? I don't know any other way to accomplish what I need to do: turn on CAM_TRIGG_DIST when I reach my subject area, then turn it off when I'm done so I don't take photos on the 2 mile flight home.
Iam
On Aug 24, 2013, at 3:29 PM, meee1 notifications@github.com wrote:
it wasn't removed from apm:plane, it is now.
— Reply to this email directly or view it on GitHub.
it has never worked.
It works fine for me in AdruPlane..
To turn it off I use DO_SET_SERVO and have a command in my script to shut it down.. Works perfectly.. :)
@wavfact could you please explain in further detail? Are you responding to Meee1 and saying that SET_PARAMETER works, or are you saying that you are able to toggle CAM_TRIGG_DIST using a script? Could you share your script with us? Thank you
I use the CameraGrid in MP which triggers CAM_TRIGG_DIST.. I have RCH7 setup as my camera trigger..
I'm sorry for being so dense, perhaps you can step me through it. You are saying that CAM_TRIGG_DIST will not trigger the camera until it reaches the area defined by the CameraGrid? Or are you saying that when you activate RCH7 it starts the automatic distance based triggering? Or is it either/or? How are you utilizing DO_SET_SERVO to "shut it down"? I'm royally confused here. You are the first to report that CAM_TRIGG_DIST can be toggled in flight without modifying the parameters. Please spell it out for me, I would be very grateful.
Unfortunately I am about to leave on vacation (tomorrow morning) and can't setup my APM to get the parameters.. For the DO_SET_SERVO I send a PWM to channel & that I have setup in my script to shut the camera down..
As for CAM_TRIGG_DIST, once you start flying, it will trigger the camera at a specific distance from the last trigger point. So if CameraGrid says 300M, then every 300M it till trigger the camera.. A good way to test it is setup a small grid around your house and walk it with your setup.. But first you MUST have your 3 position switch working in manual mode to insure it works.. I used the script from the CHDK page on AdruPilot's wiki and modified the zoom and the shutdown.. I left one alone because CAM_TRIGG_DIST will trigger a second PWM after the shuitter one so I set mine up just to zoom out a little so the lens retracts a bit..
Iskess,
Ah right...of course. that's not a top level parameter but instead is part of a library. According to MichaelO it's never worked anyway so he's removed it for copter some time ago and it'll be gone for plane in the next release as well. Sorry!
-Randy
From: iskess notifications@github.com To: diydrones/ardupilot ardupilot@noreply.github.com Cc: Randy Mackay rmackay9@yahoo.com Sent: Sunday, August 25, 2013 5:53 AM Subject: Re: [ardupilot] CAM_TRIGG_DIST activation in a flight plan (#482)
Randy, I don't know if it is working, but DO_SET_PARAMETER is still in Mission Planner. I searched through Parameters.h as you suggested and didn't find any reference to CAM_TRIGG_DIST. Actually there are other parameters that aren't listed in there, so perhaps there is another location? The only reference I found for Cameras was: // Camera and mount parameters // k_param_camera = 160, k_param_camera_mount, k_param_camera_mount2, Any other leads? — Reply to this email directly or view it on GitHub.
I know Brandon Basso has done a lot of work with CAM_TRIGG_DIST for plane and let me assure you, it works fine.. I would hope he would have a say in it being taken out.. But then, I'll just add it right back in my custom version.. :)
On another note, I just bought a quad so getting into copters now. I'll make sure its working and have a custom version available to anyone who wants it.
@Wavfact, No, no. My comment was in response to iskess's question about the SET_PARAMETER mission command.
Hi all,
So if i'm getting this right, we basically want a way to have CAM_TRIGG_DISTANCE to have an offset distance/time before starting. This makes sense to support at the flight code level. I'll look into adding it. Tridge wrote the code, but after having a look, it doesn't seem too hard to do.
I've used DO_SET_SERVO and DO_REPEAT_SERVO quite a bit. They are really useful for doing complicated things like triggering a camera inside a box and at specific waypoints so that you don't get a bunch of pictures when the aircraft is banked--ie. when making turns outside of a box. The problem with absolute position (waypoint) based triggering is that you need to make the wp radius small if you want triggering to actually occur at the waypoint, but too small means that your plane/copter will miss the waypoints.
I dont quite see how DO_SET_SERVO could be combined with CAM_TRIGG_DIST though. Dennis--are you saying that you run a CHDK script that turns the camera off at a certain point in the mission? I can see that working with something like the attached 3DRmap.bas script, if that's similar to what you're doing.
For reference, I run the 3DRshoot.bas CHDK script with CAM_TRIGG_DIST. It wouldn't be too hard to modify it so that it waits for a DO_REPEAT_RELAY command to enter into shoot mode once it's reached a certain waypoint. To be specific....
Hope that makes sense. I didn't get to test the script, so i'm not 100% sure it works. I'll give it a shot this week and write a post if it works out.
-Cheers Brandon
On Mon, Aug 26, 2013 at 4:48 AM, Randy Mackay notifications@github.comwrote:
@Wavfact https://github.com/Wavfact, No, no. My comment was in response to iskess's question about the SET_PARAMETER mission command.
— Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-23257447 .
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
Brandon, thank you for spelling this out. I look forward to the results of your testing. Ideally it would be better to not require CHDK so other cameras can be used. CAM_TRIGG_DIST should somehow be able to be initiated and stopped at a waypoint.
I am with the OP, I would really really like a way to turn on and off the CAM_TRIGG_DIST in flight. I could do all the CHDK stuff to prevent the camera from actually taking photos but then I have to sift through the log file and try to figure out which CAM data log matches the images i actually took...
I just thought of a work around that isnt ideal but is better than having hundreds of photos you dont need. Launch, fly to the target zone and set it to loiter. Then push a new param value for CAM_TRIGG_DIST through the telemetry radio, fly the pattern and then set it back to zero before the flight back to the landing zone
Ben--Nice workaround.
I'll look into implementing an offset to CAM_TRIGG_DIST.
-Brandon
On Tue, Sep 3, 2013 at 3:38 PM, ben howard notifications@github.com wrote:
I just thought of a work around that isnt ideal but is better than having hundreds of photos you dont need. Launch, fly to the target zone and set it to loiter. Then push a new param value for CAM_TRIGG_DIST through the telemetry radio, fly the pattern and then set it back to zero before the flight back to the landing zone
— Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-23752880 .
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
Sweet! Any kind of pre programmable way to turn on and off the CAM_TRIGG_DIST value while you are over the target zone would be great. Maybe use one of the DO_DIGICAM_CONTROL sort of params to set it or make it active? An offset (time or distance) isnt ideal because you have to estimate that time or distance and if you have wind or use a loiter to climb to altitude it would be a rough estimate at best.
bbasso: "I didn't get to test the script, so i'm not 100% sure it works. I'll give it a shot this week and write a post if it works out."
Did you ever get that CHDK script working? Any progress on finding a way to activate/deactivate CAM_TRIGG_DIST over a waypoint or remotely via RC radio? Thank you.
I haven't been able to try it out, but will probably give it a shot sometime this week. Shoulds be pretty easy to test on the ground though, all you need to do is make a cable with the following pinout:
USB-mini B to servo connector
Ground(5)(black) ---> Ground(black) Data(3)(green) ---> Power(red) Power 5v(1)(red) ---> Signal(white)
https://en.wikipedia.org/wiki/USB#Physical_appearance
On Tue, Sep 10, 2013 at 6:59 PM, iskess notifications@github.com wrote:
bbasso:
"I didn't get to test the script, so i'm not 100% sure it works. I'll give it a shot this week and write a post if it works out."
Did you ever get that CHDK script working? Any progress on finding a way to activate/deactivate CAM_TRIGG_DIST over a waypoint or remotely via RC radio? Thank you.
— Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-24208287 .
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
Brandon: "4. Run something like 3DRshoot, except with an additional case which is triggered by DO_REPEAT_RELAY. See attached 3DRshoot_offset"
,I don't see the attachment, did you forget to upload it?
I don't have my gear handy to setup and see what I have set in my flight plan.. I beleive I used a DO_SET_SERVO command after my mission is done to send a signal to my CHDK script which shuts down the camera. I'm using the genWIREUSB-2 cable which I can send 6 different commands to the camera (7 of I use the second signal wire). But only use 2 commands. I had a nasty crash a couple weeks ago and have been busy rebuilding my plane. I hope to be in the air today though and can run more tests.
Attached
On Sun, Sep 15, 2013 at 1:55 AM, iskess notifications@github.com wrote:
Brandon: "4. Run something like 3DRshoot, except with an additional case which is
triggered by DO_REPEAT_RELAY. See attached 3DRshoot_offset"
,I don't see the attachment, did you forget to upload it?
— Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-24466972 .
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
Brandon, I still don't see the attachment. Actually I don't see anyway that you can post an attachment here. Maybe I'm missing something, github isn't very intuitive. Right now we are using a special cable and trigging off the APM's ch7 output. CAM_TRIGG_DIST is working well this way, but I would like to use some of the servo signal bandwidth to shut down the Canon over a waypoint using DO_SET_SERVO as described by Dennis. I can also make a simple cable as you described and switch to Relay if that is better. I just don't know how to write this script. Could you try emailing your script to me at iskess(at)hottmail.com. Or maybe past the script text here? Dennis, can you post yours too? Hopefully we will have an APM firmware solution someday soon. Thank you
I never got a script from Brandon or Dennis. Unfortunately no attachments are allowed here. Could one of you email my a script to iskess@hotmail.com? At the very least, could someone tell me what command is used to shut down the camera? Will it shut down and completely retract the lens for landing?
use the CHDK script command shut_down
Things to note; 1; Doesn't work on all cameras 2: You can not restart the camera in flight, must be done manually.
You can play with alternate zoom levels that will retract the lens enough without turning off the camera
Script 3DRShoot.bas copied below. I'll put it up on the camera tutorial wiki as well.
You can add the shut_down command in another case if you'd like. You could have the camera shut down if it gets an error, for example. The only case this script has is shoot on 100ms USB pulse. In practice, shut_down is a bit dangerous because you can not turn the camera back on. With the PWM to USB pulses CHDK cable http://www.gentles.ltd.uk/gentwire/Manual-usbc2.pdf(the one that lets you trigger different modes based on an input PWM) i've seen quite a bit of noise which nearly always triggers the shut_down case by mistake. I'm working to solve this at the script level and will post that one as well when it's ready.
@title 3DR Shooter rem author Brandon Basso, 3D Robotics rem This script looks for a 100ms USB pulse and takes a picture when it sees it
@param o Zoom-extended @default o 100 @param i Zoom-stowed @default i 30 @param s Zoom-shoot @default s 10
set_zoom s
while 1 do k = get_usb_power until k>0 if k > 8 and k < 12 then gosub "shoot" if k > 19 then print "error" wend end
:shoot print "Shoot!" shoot sleep 1000 return
On Sat, Sep 21, 2013 at 3:34 AM, Dennis Megarry notifications@github.comwrote:
use the CHDK script command shut_down
— Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-24860118 .
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
Thank you both for your posts. I'm sorry to hear that shut_down can be commanded by a spurious PWM signal. I have a project in a couple of weeks where I will need to be landing in some harsh terrain, and I am eager to find a way to secure the camera for landing. Shut_down seemed perfect. What if the script required the PWM to be at a value for longer than a certain time period (say 10 secs) before commanding the shut_down? How would one script that? I just started learning how to write scripts this week, so I appreciate your patience with me.
I'm using the GenWIRE USB2 cable and have no experienced any rogue signals.. They have a tiny circuit board in the cable so maybe that has something to do with it? For $50 you can't beat it and gives you the ability to use 6 different signals.. I did take my cable apart to see if I could recreate the cable but stopped when I seen the PCB..
I'm using this $28 cable from Flytron meant for Ricoh. http://www.flytron.com/rc-shutters/92-ricoh-remote-shutter.html So far it works fine for triggering CAM_TRIGG_DIST via CHDK, but I haven't tried multiple PWMs yet for different functions. It only has 1 servo wire so it could only allow 3 functions rather than 6. All I need is trigger and shutdown. I'm hoping this works because $50 is a bit pricey and we have a Ricoh camera also.
Branden, I don't understand how you plan to use a simple USB cable w/o a PCB to trigger the shutter via CAM_TRIGG_DIST and also have CHDK listen for DO_REPEATRELAY to start/stop triggering. Won't the constant stream of distance based trigger relay signals over-ride the waypoint based DO command? I wish you could explain, or paste your script text here. You have attempted to attach it twice, but pasting the test is the only way it works. The script you pasted above only triggers the camera. Thank you
Hi all. Is there any progress on this? I'm new to the Ardupilot project as of a few months ago, and have been building a mapping UAV for work. I'm up to the stage where I have written a working CHDK script to take photos when pulses are sent from APM Plane (using CAM_TRIGG_DIST), through a GentWire USB 2 cable. I am now facing this issue - I need a way to shut down the camera when the mapping part of the mission is complete. Ideally, I would like to be able to place a waypoint that disables the APM Plane camera triggering.
Aaron,
You can use the shut_downhttp://chdk.wikia.com/wiki/UBASIC/TutorialScratchpadcommand in CHDK and map that to one of the options on your GentWire USB 2 cable.
You can alternatively set CAM_TRIGG_DIST to 0 when your mission is complete.
In my experience with the GentWire cable, its conversion of PWM to USB pulses is pretty noisy, so if you don't sufficiently separate your triggering levels, you can spill over into unintended modes. If one of those modes is shut_down, than you camera turns off and there is no way to turn it back on, and you imaging mission is over.
-Brandon
Brandon Basso, PhD :: Senior Research and Development Engineer :: 3D Robotics :: Berkeley, CA
On Mon, Feb 17, 2014 at 4:28 PM, Aaron Snoswell notifications@github.comwrote:
Hi all. Is there any progress on this? I'm new to the Ardupilot project as of a few months ago, and have been building a mapping UAV for work. I'm up to the stage where I have written a working CHDK script to take photos when pulses are sent from APM Plane (using CAM_TRIGG_DIST), through a GentWire USB 2 cable. I am now facing this issue - I need a way to shut down the camera when the mapping part of the mission is complete. Ideally, I would like to be able to place a waypoint that disables the APM Plane camera triggering.
Reply to this email directly or view it on GitHubhttps://github.com/diydrones/ardupilot/issues/482#issuecomment-35335938 .
Thanks for the fast reply Brandon,
Your advice sounds good - I had arrived at the same conclusions.
I don't like the idea of manually setting CAM_TRIG_DIST in while in flight; it seems to me that writing to EEPROM while in flight could unexpectedly block the APM CPU or cause corruption - is there any merit to this worry?
As for the other option, using the shut_down
command. I'm currently trying this within my script but am facing a potentially CHDK related issue. My script I'm using is below (same script in uBASIC and Lua).
In uBASIC:
@title Mapping Camera Script (uBASIC)
rem Author: Aaron Snoswell
rem This program waits for pulses from the connected GentWireUSB2 cable and
rem does something based on the length of the pulses
print "Mapping Script (uBASIC)"
sleep 1000
a = 0
print "Shutter Disabled"
while 1
do
k = get_usb_power
until k>0
if k < 5 then gosub "ch1up"
if k > 4 and k < 8 then gosub "ch1mid"
if k > 7 and k < 11 then gosub "ch1down"
if k > 10 and k < 14 then gosub "ch2up"
if k > 13 and k < 17 then gosub "ch2mid"
if k > 16 and k < 20 then gosub "ch2down"
if k > 19 then print "ERR "; k
wend
end
:ch1up
if a > 0 then print "Shooting"
if a > 0 then shoot
return
:ch1mid
return
:ch1down
return
:ch2up
if a < 1 then print "Shutter Enabled"
if a < 1 then a = 1
return
:ch2mid
if a > 0 then print "Shutter Disabled"
if a > 0 then a = 0
return
:ch2down
print "Shutting Camera Down for Landing"
shut_down
return
In Lua:
--[[
@title Mapping Script (Lua)
Author: Aaron Snoswell
This program waits for pulses from the connected GentWireUSB2 cable and
does something based on the length of the pulses
--]]
print("Mapping Script (Lua)")
sleep(1000)
-- Disable shutter initially
shutter_enabled = false
print("Shutter Disabled")
function ch1_up()
if(shutter_enabled == true) then
print("Shooting")
shoot()
sleep(200)
end
return
end
function ch1_mid()
return
end
function ch1_down()
return
end
function ch2_up()
if(shutter_enabled == false) then
print("Shutter Enabled")
shutter_enabled = true
end
return
end
function ch2_mid()
if(shutter_enabled == true) then
print("Shutter Disabled")
shutter_enabled = false
end
return
end
function ch2_down()
print("Shutting Down for landing")
post_levent_to_ui('PressPowerButton')
repeat
-- Pass
until false
end
function err_msg(pulse_length)
print("Err: "..pulse_length)
return
end
-- Main program loop
repeat
pulse_length = 0
-- Wait for a USB pulse
repeat
-- Retrieves the length (in mS) of the most recent USB power pulse
pulse_length = get_usb_power()
until pulse_length > 0
-- Do something based on the pulse length
if(pulse_length < 5) then ch1_up()
elseif(pulse_length > 4 and pulse_length < 8) then ch1_mid()
elseif(pulse_length > 7 and pulse_length < 11) then ch1_down()
elseif(pulse_length > 10 and pulse_length < 14) then ch2_up()
elseif(pulse_length > 13 and pulse_length < 17) then ch2_mid()
elseif(pulse_length > 16 and pulse_length < 20) then ch2_down()
else err_msg(pulse_length) end
until false
As you can see, I'm using the second GentWire input to either enable (up) or disable (mid) the shutter triggering, and when the second channel is switched down, I'm shutting the camera down. The issue I am facing is that the get_usb_power(0) CHDK function "returns the pulse width of the most recent USB power activation and clears that value".
What I appear to be observing in my bench tests is that the shutter trigger signal (from CAM_TRIG_DIST) has a high probability of happening after the shutdown signal is sent, but before my CHDK script gets a chance to read the power down signal. Hence, I can send 6 or 7 shut down signals, but the camera just keeps missing the signal and taking photos. Does that make sense?
At work we have a requirement that the shutter be retracted before landing, hence I need this not to happen :) For this reason I was hoping there may have been some progress on adding a feature to mission planner to disable triggering with a waypoint - this way the shut down command will not be overwritten by the more frequent take photo commands.
Thanks,
AS
Also, in reply to your comments,
I've noticed that the Gentwire output (on a scope) is indeed a very noisy pulse, but I haven't yet had any issues with the signals overlapping or being incorrect - perhaps this is being in part caused by noise within your UAV(s)?
The ability to set CAM_TRIGG_DIST in missions was added a couple of releases ago in plane. It should be in the mission editor in MissionPlanner now, although I don't use MP so haven't checked. We also need to document it!
The new CAM_TRIGG_DIST parameter is a fantastic addition but lacks the ability to activate it over waypoints resulting in excess data. My target site is 2 miles away from my launch site and I don't want photographs being triggered until I reach the target area. I thought perhaps I could use DO_SET_PARAMETER to toggle CAM_TRIGG_DIST, however it asks for the Parameter number and I don't know how to identify that. Ideally I could activate CAM_TRIGG_DIST using an assigned channel on my controller so it wouldn't even require a flight plan.