Easy way to call RP camera in simplebot code?

gopigo3
project
#1

Hello,

I’ve modified my own simplebot to use a grabber arm and ultrasonic sensor. I’ve placed the raspberry pi camera above the grabber arm but I am unable to “call” the camera using a keyboard entry.

Basically I want to nest the function that is performed by

sudo raspistill -o test.jpeg

within the code below:

while True:
        inp = stdscr.getkey() #Take input from the terminal
        #Move the bot
        if inp == 'w':
                fwd()
                print("fwd")

        elif inp=='a' :
                left()
                print("left")

        elif inp=='d':
                right()
                print("right")

        elif inp=='s':
                back()
                print("back")
	
        elif inp=='x':
                stop()
		print("stop")
	elif inp =='p':
        	try:
            		value = BP.get_sensor(BP.PORT_1)
            		print(value)                         
        	except brickpi3.SensorError as error:
            		print(error)

        	time.sleep(0.02)

	elif inp=='g':
		grip()
		print("grip")
	elif inp=='r':
		rgrip()
		print("release grip")
	elif inp =='q':
		BP.reset_all()

So, ideally, when I press “c” I could pull up the camera video for 5 seconds? Is there an easy way to achieve this goal?

Thanks in advance for any tips.

#2

Here is a python way to do the photo part: snapJPEG.py

but if you want to watch a video, perhaps you want to start with the Remote Camera Robot code.