Servo sweep + Video record HELP!


#1

Hey all,

We’re in the last week of robotics camp. I want to do a servo sweep while recording video. I can’t get them to go at the same time. Can anyone help? Here’s my code (you can’t see the indents, but syntax is fine):

def fullsweep():
for x in range (0, 1):
with picamera.PiCamera() as camera:
print "Taking video"
camera.start_recording(‘test.h264’)
for i in range(180):
servo(i)
print i
time.sleep(.02)
time.sleep(.8)
servo(90)
time.sleep(.02)
with picamera.PiCamera() as camera:
camera.stop_recording()
print ‘Voltage:’,volt()


#2

Hey,
For the servo to do the sweep and the camera to record the video at the same time, you would have to do multithreading so that the two processes can tun in parallel. You should be able to find some tutorials to help you getting the threads to work. Another thing that might work for you is to use two different programs, one to run the servo and the other to record the video and run them from two different SSH/VNC sessions.

-karan