Objective:
In this lesson, we will show you how to use Python3 Flask and M-Jpeg Streamer software to control a Raspberry Pi Robot Car through Internet. You will monitor the car’s real-time movement through its’ eye(front camera).

Prerequisite

You must finish  the basic framework and motor installation in Lesson 1 : https://osoyoo.com/2020/03/19/how-to-use-osoyoo-model-pi-l298n-motor-driver-board-in-raspberry-pi-robot-car/

and  installed Servo as per Lesson 4: Obstacle Avoidance

Additional Hardware Installation:
Servo Must be installed and connected PCA9685 PWM 15 port
CSI Web Camera Must be installed and connected CSI Slot with CSI ribbon cable
You also need to enable Camera in Raspberry Pi by typing following command

sudo raspi-config

Then select ->5 Interfacing Options->P1 Camera->Yes->Ok->Finish

Software Installation:

Please install the OSOYOO web camera controlled robot car software with following shell command

wget http://osoyoo.com/driver/picar/osoyoowebcar.sh

bash osoyoowebcar.sh

Test the car:
Step 1) If you have not started Mjpeg-Streamer server yet, please run following command to start the video server:

cd ~
bash camstart.sh

Step 2)Open a new terminal window and run the webcam python program by typing following commands in terminal:

cd osoyoowebcar
nano webcar.py

Above command will edit webcar.py file, replace ip address 192.168.0.32 in line 15 to your raspberry pi IP address
Ctrl-X exit and save

nano templates/index.html

Above command will edit  index.html file, please change 192.168.0.32 in line 34 to your pi’s ip address
Ctrl-X exit and save

sudo python ~/osoyoowebcar/webcar.py

Now in your PC or cell phone browser, visit http://your_RaspberryPi_ip_address , you will see following UI:

The arrows buttons are direction control keys, red circle button in the middle is the STOP key. There are four speed control buttons in the bottom:

In the top of the page, there is a Camera Direction Slider, you can move the slider in order to rotate the servo and change the camera orientation.

Reference:
Marcelo Rovai : Python WebServer With Flask and Raspberry Pi
https://towardsdatascience.com/python-webserver-with-flask-and-raspberry-pi-398423cc6f5d