Canada
Asked — Edited

Camera Control Questions

In a couple of scripts I have commands to start a camera, however, if the camera is already on, when the command to start it runs - the camera stops. Also, in a script, I have a command to stop a camera and when that runs the camera does not stop. My project has 2 cameras.

Has anyone else run across this?


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

#1  

So I've been playing around with problem a little more. When I run this script with the cameras turned off everything works.


ControlCommand("Camera", CameraStart)
sleep(5000)
ControlCommand("Camera", CameraStop)
sleep(5000)
ControlCommand("Camera2", CameraStart)
sleep(5000)
ControlCommand("Camera2", CameraStop)


If I run it with the the cameras on they shut off when they should be on. I'm still unable to get Camera2 to stop in a this script though. Can anyone see what the problem might be?


Sayezb("OK, where's that charging dock")
sleep(1000)
ControlCommand("Camera2", CameraStart)

SendSerial(1.D0,9600,0)
ControlCommand("Auto Position", AutoPositionFrame, "Look back", 25,2,2)
ControlCommand("Script Manager", ScriptStart, "Eyes Right")
Servo(1.22,40)
sleep(2000)

:backup

ControlCommand("Camera2", CameraMultiColorTracking, "Lime")

if($Cameraistracking = 1)
Stop()
sleep(200)
GoTo(step 2)
sleep(2000)
Else


SendSerial(1.D0,9600,215)
SendSerial(1.D0,9600,40) 

sleep(2500)
Goto(backup)
endif

:step 2
Waitfor($cameraverticalquadrant = "middle",200)
sleep(1000)
ControlCommand("Camera2", CameraMultiColorTrackingDisable)

Sayezbwait("there it is")
Sleep(500)
Reverse()

$onlyreverse = 0 
$closenough = 35 # Change for minimum distance
:loop
if ($onlyreverse=1)
  if ($direction="reverse")
    GOTO(sensorcheck)
  endif 
ELSE 
  GOTO(sensorcheck)
endif 
GOTO(loop)

:sensorcheck
$howclose = GetPing(1.d9,1.d8)


if($howclose < $closenough)
print(1)

ControlCommand("Script Manager", ScriptStart, "Rest")
Sleep(500)
Sayezbwait("OK, plug me in")
Sleep(1000)
ControlCommand("Camera2", CameraStop)
else
sleep(1000)
Goto(loop)
endif

#2  

This may help. In my init script, I toggle the camera off and back on as a workarond to the issue that the grid lines are sometimes off center. I use the $IsCameraActive variable to determine if it is running first. I only have one camera, so I am not sure what the variable name is with a second camera or if you will need to customize it.


# Stop, and restart the camera
if ($IsCameraActive = 1)
ControlCommand("Camera", CameraStop)
endif
sleep(1000)
if ($IsCameraActive = 0)
ControlCommand("Camera", CameraStart)
endif

#3  

@thetechguru, that got me thinking on the right track. I'll put a couple of " check camera" lines in. Thanks for your help.

#4  

I've tried to run the code below to control a second camera but I get the dreaded - Variable not defined: $IsCamera2Active. I've tried to define Camera2 with it's connection number - $Camera2 = EZB://192.168.2.94 but that doesn't work.


if ($IsCamera2Active = 1)
ControlCommand("Camera2", CameraStop)
endif

How do I define Camera2 ?

Thanks

#5  

You define the variables in the settings of the camera object. There are automatically created variables when you add the camera object, but when you add a second camera, it doesn't create new variables, so you need to manually update them.

Click on the settings gear in the lower left corner of the camera object, then the scripts button, then the variables tab, and rename all the variables to reference your second camera.

See screen shot below:

User-inserted image