Index>Robot Kit>Mars Rover PiCar-B Smart Robot Car Kit for RPi>Lesson 1 Introducing Web Controller UI

Lesson 1 Introducing Web Controller UI

958

Lesson 1 Introducing Web Controller UI

 

1.1 Running webServer.py Program

Raspberry Pi will automatically run the program of the robot every time it reboots. Specifically, it will run adeept_picar-b/server/webServer.py, but if the Raspberry Pi camera or the driver board Robot HAT is not connected, webServer.py will not run. It's normal because the program of the robot needs to use the camera and PCA9685 chip. The Adeept Motor HAT controls servo via PCA9685, while the Raspberry Pi communicates with PCA9685 through I2C. If Motor HAT is not installed on the Raspberry Pi, when instantiating the dependent library of PCA9685, a communication failure will occur with a program error.

You can power off the Raspberry, install the camera module and Motor HAT, and reboot. Then webServer.py can run successfully.

Under normal circumstances, you don't need to manually run webServer.py since the Raspberry Pi will automatically run the program when booting.

If you failed to open the page, you can remotely log into the Raspberry Pi via SSH and type in the command as shown below to disable all auto-run programs to release resource. Otherwise, there may be issues like camera initialization failure or occupied port.

sudo killall python3

image.png 

Type in the following code to run webServer.py:

sudo python3 adeept_picar-b/server/webServer.py

image.png 

You can access the Raspberry Pi by IP address through a web browser only when it can successfully run webServer.py.

1.2 Getting Access to Web Controller

A web controller is a web interface to control the robot product to perform various actions and it can be applied on any device that is able to run a browser, including PC, mobile phones, tablets, etc.

If you've completed all installations based on the instructional document, it will be quite easy to open a web controller.

1. Check that your device is under the same LAN with the Raspberry Pi.

2. Obtain the Raspberry Pi's IP address (refer to the Software Installation section).

3. Open a web browser (recommended to use Chrome in case of any possible incompatibility with other browsers), enter the Raspberry Pi's IP address with the port :5000, for instance: 192.168.3.44:5000

image.png

Then the web controller will be loaded into the browser.

image.png 

Modules on the web controller may vary from products. Most of them are explained below with the method for application. You can check modules on your web controller accordingly to better understand their functions and how to use them.

1.3 Function Overview of Web Controller

 

1. Video Module

Display the image captured by the camera.

image.png 

2. Hard Ware Module

image.png 

CPU Temp: Shows the temperature of the Raspberry Pi CPU.

CPU Usage: Shows the usage of the Raspberry Pi CPU

RAM Usage: Shows the usage of the Raspberry Pi memory  

3. Move Control Module

Control the movement of the robot towards the front, back, left, and right. (To turn left, you need to press "forward" and "left",To go back to the left, you need to press "back" and "left". The same to the right)

image.png 

Speed: Slide to adjust the speed of the robot's movement, for robot with wheels. It's not supported for the Adeept RaspClaws Robot.

4. Arm Control Module

Control the robotic's movements 

image.png 

UP: The robot head turns upward.

DOWN: The robot head turns downward.

LEFT: The robot head turns to the left.

RIGHT: The robot head turns to the right.

 

 

5. Actions Module

image.png 

MOTION GET: switching watchdog mode. In this mode, the robot product stops moving and reacts to the moving objects detected in the camera, and the moving objects are framed in the video of the Vedio module.

AUTO MATIC: Switch to automatic obstacle avoidance mode. In this mode, the robot product will automatically advance and use the ultrasonic module to detect obstacles. When encountering obstacles, try to find other paths.

KEEP DISTANCE: The distance is detected by ultrasonic and keep a fixed distance from the object.

TRACK LINE: switching hunting mode. In this mode, the robot product will try to move along the white lines on the black ground.

STEADY CAMERA: Voice recognition function.

 

6. FC Control Module

Control the color detection function on/off and color setup.

image.png 

COLROR: Select the color to be detected.

START: Turn on/off the color detection function.

7. PWM INIT SET Module

image.png 

Adjust the initial angle of servo to fix angle error during assembly. Servo will rotate to the initial position when initialized.

① Enter the number of the PWM port connected with the desired servo in the textbox under PWM. Click the PWM textbox and the buttons for increase and decrease will appear. Click to choose a PWM port number.

② Click the two buttons to control the servo to slightly rotate clockwise/counterclockwise.

③ Click to save the current angle of the servo as the initial.

④ Click to initialize the angle of all servos to the factory default settings.

8. Radar Scan Control Module

image.png 

 

Used to perform the ultrasound scan function and display the scan results.

 

 

1.4 Q&A

 

After the Raspberry Pi boots, I can't access the web controller page via "Raspberry Pi's IP address + :5000 (port number)" (e.g., 192.168.3.230:5000)

Take the following steps:

1. Type in the command "sudo killall python3", run the webServer.py program by "sudo python3 <your path of the webserver.py file>" (e.g., sudo python3 adeept_picar-b/server/webServer.py)

2. If error happens when running webServer.py, please check whether the camera is connected appropriately (metals of the camera flex cable and camera module should be in contact with each other)

After the Raspberry Pi boots, I got access the web controller page via "Raspberry Pi's IP address + :5000 (port number)", but I saw a non-real-time, static video and couldn't control the robot to move.

Take the following steps:

1. Check whether the Raspberry Pi has rebooted or not. If it has, the "Connect Failed" message would be prompted within 1 minute on the web controller page, and the terminal logged into Raspberry Pi via SSH would not respond.

2. Possible reason for this issue: Low power of the battery. It's suggested to change high power batteries for controlling the robot via web controller.

3. Use 18650 battery with "high rate discharge" mark or that can support large current output of up to 4A.