Controlling PTZ from command line for scheduling presets.

Support and queries relating to all previous versions of ZoneMinder
Locked
lspiehler
Posts: 21
Joined: Tue May 19, 2009 1:54 pm

Controlling PTZ from command line for scheduling presets.

Post by lspiehler »

I understand the usage for zmcontrol.pl is:
Usage: zmcontrol.pl --id <monitor_id> --command=<command> <various>

but I don't really know the options for $command or "various options." Can someone please give me an example command for moving a given camera id to a given preset? My goal is to schedule a preset so that the camera monitors my kid's bus stop at a scheduled time every day and then returns home after a short amount of time. Thank you for any help!!!
mrd
Posts: 269
Joined: Wed Apr 26, 2006 12:39 am
Location: Boston USA

Post by mrd »

If you have a PTZ camera working on your system, you should be able to look in the /var/log/zm/zmcontrol.log file and see what is being executed when you move the camera with the ZM controls.

I think it's:

zmcontrol.pl --id=3 --command="presetgoto 2"

I'll have to try this out when I get a chance, but there are a few posts that talk about what you want to do.

http://www.zoneminder.com/forums/viewtopic.php?t=12929
MRD
lspiehler
Posts: 21
Joined: Tue May 19, 2009 1:54 pm

Any other ideas?

Post by lspiehler »

I tried the command and it goes through without error, but I didn't get any movement. I'm stumped. If you have any other ideas, let me know, please.
mrd
Posts: 269
Joined: Wed Apr 26, 2006 12:39 am
Location: Boston USA

Post by mrd »

The first thing to verify is that you can move the camera with the ZM controls. If that works, then we can get the zmcontrol command to work.
MRD
lspiehler
Posts: 21
Joined: Tue May 19, 2009 1:54 pm

Post by lspiehler »

Controls from the web interface work fine, but there is no option to schedule controls from the front end. I need to figure out how to move to a preset from the command line so that I can schedule that command as a cron job and have a second cron job return it to the default location shortly afterward. My reason for this is in my first post. Thanks for the help. Please, let me know about any other ideas.
[/list]
mrd
Posts: 269
Joined: Wed Apr 26, 2006 12:39 am
Location: Boston USA

Post by mrd »

What is the output of /var/logs/zm/zmcontrol.log?

It might output the command strings that are sent if you raise the DEBUG level, although I've never been able to get DEBUG to work on ZM myself.

What camera are you using?
MRD
lspiehler
Posts: 21
Joined: Tue May 19, 2009 1:54 pm

Post by lspiehler »

With debugging set a level 9, all I get is:

10/15/2009 16:20:15.554061 zmcontrol[4238].INF [Starting control server 2/PelcoD]
10/15/2009 16:20:15.558138 zmcontrol[4241].INF [Control server 2/PelcoD starting at 09/10/15 16:20:15]
10/15/2009 16:20:16.581280 zmcontrol[4241].FAT [Can't access preset=4 member of object of class ZoneMinder::Control::PelcoD]
10/15/2009 16:20:54.963589 zmcontrol[4262].INF [Starting control server 2/PelcoD]
10/15/2009 16:20:54.967800 zmcontrol[4265].INF [Control server 2/PelcoD starting at 09/10/15 16:20:54]
10/15/2009 16:20:55.996647 zmcontrol[4265].FAT [Can't access presetgoto=4 member of object of class ZoneMinder::Control::PelcoD]
10/15/09 16:23:36.089723 zmcontrol[4391].INF [Starting control server 2/PelcoD]
10/15/09 16:23:36.093721 zmcontrol[4394].INF [Control server 2/PelcoD starting at 09/10/15 16:23:36]
10/15/09 16:53:44.420512 zmcontrol[4394].INF [Control server 2/PelcoD exiting at 09/10/15 16:53:44]
10/15/09 18:18:46.063412 zmcontrol[5544].INF [Starting control server 2/PelcoD]
10/15/09 18:18:46.067349 zmcontrol[5548].INF [Control server 2/PelcoD starting at 09/10/15 18:18:46]
10/15/09 18:27:44.923752 zmcontrol[3801].INF [Starting control server 2/PelcoD]
10/15/09 18:27:44.949371 zmcontrol[3804].INF [Control server 2/PelcoD starting at 09/10/15 18:27:44]

but I'm still open for ideas! Thanks again.
lspiehler
Posts: 21
Joined: Tue May 19, 2009 1:54 pm

Post by lspiehler »

Sorry, I'm using 2 RS-485 cameras with the pelco-D protocol.
mrd
Posts: 269
Joined: Wed Apr 26, 2006 12:39 am
Location: Boston USA

Post by mrd »

Ok... I looked at the code.

Code: Select all

if ( !GetOptions(
    'id=i'=>\$id,
    'command=s'=>\$options{command},
    'xcoord=i'=>\$options{xcoord},
    'ycoord=i'=>\$options{ycoord},
    'speed=i'=>\$options{speed},
    'step=i'=>\$options{step},
    'panspeed=i'=>\$options{panspeed},
    'tiltspeed=i'=>\$options{tiltspeed},
    'panstep=i'=>\$options{panstep},
    'tiltstep=i'=>\$options{tiltstep},
    'preset=i'=>\$options{preset},
    'autostop'=>\$options{autostop},
    )
)
zmcontrol.pl --id=<Monitor ID> --command=presetGoto --preset=<1 to what ever number of presets your camera supports>
MRD
mrd
Posts: 269
Joined: Wed Apr 26, 2006 12:39 am
Location: Boston USA

Post by mrd »

You should also take a look at the post I mentioned (I wrote it) and there is a link to a script that I wrote discussed there that does a "Patrol" of camera presets for monitoring (recording) different areas of my home at different times using cron. You can adapt the code or at least the concepts into your needs.
MRD
lspiehler
Posts: 21
Joined: Tue May 19, 2009 1:54 pm

Post by lspiehler »

You are the man!!! Thank you so much for your help. For the reference of anyone interested in the topic of this post, the exact command I used to accomplish my goal is:

/usr/lib/zm/bin/zmcontrol.pl --id=2 --command=presetGoto --preset=4

Now I'm off to complete my project!!!
Locked