Script to retract lens into the body, UAV mapping - Script Writing - CHDK Forum

Script to retract lens into the body, UAV mapping

  • 23 Replies
  • 14717 Views
Script to retract lens into the body, UAV mapping
« on: 14 / November / 2014, 13:28:59 »
Advertisements
Hi new to this forum, ive written an arduino sketch to make an interface between my UAV's flight controller and the USB power lead so it can automatically trigger camera functions as required. Only problem now is that the camera lens will be protruding from the bottom of the UAV's fuselage. This will total the camera on landing and on any failed take off.

Ideally the camera should function as follows.

start script running and load in plane, cam goes into sleep mode with lens retracted.
cam stays in sleep until Auto waypoint mode is selected on the autopilot. this will be a usb trigger.
when in auto mode the lens should extend, and will shoot as commanded by the AP. and sleep in between.
when any other flight mode the cam should retract the lens and sleep.
upon landing the cam can be switched back on.


So the question is which function should be used to retract? perhaps:

press "display"
sleep 100

or;

click "display"
sleep 100

then i could just call shoot to wake it and extend the lens?

Re: Script to retract lens into the body, UAV mapping
« Reply #1 on: 14 / November / 2014, 13:39:21 »
Camera model is SX200is.

just been reading about the poke command. perhaps i can poke it as required to extend / retract the lens?

Re: Script to retract lens into the body, UAV mapping
« Reply #2 on: 14 / November / 2014, 13:55:25 »
also which IDE's are people using for basic / lua scripting?

*

Offline ahull

  • *****
  • 634
Re: Script to retract lens into the body, UAV mapping
« Reply #3 on: 14 / November / 2014, 15:02:30 »
also which IDE's are people using for basic / lua scripting?

vi :P

A more serious answer would be ... if I ever needed an IDE plugin fur LUA, I would probably use Eclipse... but vi/vim  and sometimes gedit works well for pretty much everything I do, but neither is strictly speaking an IDE. Setting syntax highlighting in vi is fairly trivial, and since CHDK scripts don't often stretch to more than one lua file, I don't need much more. 

http://lua-users.org/wiki/LuaIntegratedDevelopmentEnvironments
« Last Edit: 14 / November / 2014, 15:08:02 by ahull »

Re: Script to retract lens into the body, UAV mapping
« Reply #4 on: 14 / November / 2014, 15:27:40 »
Hi new to this forum, ive written an arduino sketch to make an interface between my UAV's flight controller and the USB power lead so it can automatically trigger camera functions as required. Only problem now is that the camera lens will be protruding from the bottom of the UAV's fuselage. This will total the camera on landing and on any failed take off.
You might find parts (or all) of this script useful : KAP UAV Exposure Control Script.  It will shoot under USB control as you describe and retract the lens for take off & landings.  It also offers advanced exposure control to try and get the highest possible shutter speeds at the highest acceptable ISO setting. And much much more.

Quote
then i could just call shoot to wake it and extend the lens?
The secret to managing the lens extension & retraction is to have the script switch the camera between shooting & playback modes with the  Canon Lens Retract setting set to 0 sec.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Script to retract lens into the body, UAV mapping
« Reply #5 on: 15 / November / 2014, 10:02:44 »
@title  APM shooter
rem by Ben Harvey Benny_H88, modified version of 3dr_shoot.bas



while 1
   do
      k = get_usb_power
   until k>0
   if k < 5 then gosub "ch1down"   
   if k > 4 and k < 8 then gosub "ch1mid"
   if k > 7 and k < 11 then gosub "ch1up"
   if k > 10 then print "error"
wend
end

:ch1up
   print "Ch1Up-Shoot; k
   shoot
   sleep 1000
   return

:ch1mid
   print "Ch1Mid-Stowed"; k
   press "display"
   sleep 1000
   return

:ch1down
   print "Ch1Down-Extended"; k
   release "display"
   sleep 1000
   return


any thoughts as to why this may not run?

Re: Script to retract lens into the body, UAV mapping
« Reply #6 on: 15 / November / 2014, 10:09:36 »
any thoughts as to why this may not run?
It's always hard to provide tech support when a user posts a comment that only says something like "Doesn't work".

What does "may not run" mean.  May not run on Tuesdays?  Runs and crashes sometimes but not others?  Runs but does not respond to signals from my uController?  Responses to my uController but not always with the expected printed message? Detailed descriptions of what you did and what you saw are almost always needed.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Script to retract lens into the body, UAV mapping
« Reply #7 on: 15 / November / 2014, 11:16:11 »
@title simple shoot

:loop
wait_click 1
is_key k "remote"
rem if 5v is applied goes to shoot else goes to retract
if k = 1 then gosub "shoot"
if k = 0 then gosub "retract"


goto "loop"
end

:shoot
rem focus camera, shoots, saves time pic taken in t
   print "Shoot"; k
   print "setting focus"
      x=get_hyp_dist
   set_focus x
   print "Shoot"; k
   shoot
   t = get_day_seconds
   sleep 500
   return

:retract
rem compares time since last shot if more than 60 sec retracts lens
   x = get_day_seconds

   if x-t > 60
      print "retract"; k
      click "display"
      sleep 1000
      return

heres another idea, if a photo hasnt been taken in a certain amount of time then retract lens

Re: Script to retract lens into the body, UAV mapping
« Reply #8 on: 15 / November / 2014, 11:23:03 »
my apologies,

uBASIC: 18 Unk label
TERMINATED

ive no idea what the error means

are there any tutorials for writing scripts? it would be handy to know how to properly write the various statements as they are nothing like the c i am used to

*

Offline zeno

  • *****
  • 891
Re: Script to retract lens into the body, UAV mapping
« Reply #9 on: 15 / November / 2014, 11:54:57 »
That error means that line 18 of the script references an unknown label. Looking at the two scripts you posted, I can't see what the problem is. You might try debugging your script on a PC or Mac using my uBASIC debugger - see
http://www.zenoshrdlu.com/kapstuff/zubdb.html
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

 

Related Topics


SimplePortal © 2008-2014, SimplePortal