Getting pan/tilt to work with servo pHat and RPi cam interface / Sphero RVR

Hi there!

I’ve just configured a Raspberry Pi 3 to work with the Sphero RVR, and I’m installing all the various bits and pieces from scratch. I can’t get the controls in the Pi webcam interface for pan and tilt to show up.

I’ve installed the Sparkfun code from here:

https://github.com/sparkfun/sparkfun_autonomous_kit

https://github.com/sparkfun/PiServoHat_Py

The webcam interface from here:

https://github.com/silvanmelchior/RPi_Cam_Web_Interface

And Sphero SDK from here:

https://github.com/sphero-inc/sphero-sd … ypi-python

I moved piservohat_web_interface_firmware.py into the RPi_Cam_Web_interface folder

All the hardware tests work. I can move the pan and tilt servos using the servo pre-alignment and hardware test examples.

When I start the RPi_Cam_Web_interface, I do get the video stream.

However, the little control arrows for pan and tilt don’t appear.

Is there anything I am missing?

Ok I sorted this out, following a combination of instructions from here:

https://learn.sparkfun.com/tutorials/se … l#new-page

and here:

https://elinux.org/RPi-Cam-Web-Interfac … r_Pi-Light

Setting it up the same way as the Advanced Autonomous Kit for Sphero RVR has some changes.

The first few steps are much like the Pan-Tilt camera instructions, first install the package:

git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
cd RPi_Cam_Web_Interface
./install.sh

This is different!

Copy piservohat_web_interface_firmware.py into the RPi_Cam_Web_Interface directory

Signal to the software that you want to enable pan/tilt - you do this by renaming ‘pipan_off’ to ‘pipan_on’, the software looks for that file as the signal that it should show the pan/tilt controls.

sudo mv /var/www/html/pipan_off /var/www/html/pipan_on

Set up a “pipe” between the RPi cam interface and the software that will move the motors:

sudo mknod /var/www/html/FIFO_pipan p
sudo chmod 666 /var/www/html/FIFO_pipan

Different!

Open and edit the startup script

sudo nano start.sh

Add this line to the end of the script, this starts the motor control software when the cam interface starts

python3 piservohat_web_interface_firmware.py &

Open edit the shutdown script

sudo nano stop.sh

And add these two lines to the end of the script, this shuts down motor control when you stop the cam interface

kill $(pgrep -f 'piservohat_web_interface_firmware.py')
pkill -f piservohat_web_interface_firmware.py