13. Controlled by the APP¶
The SunFounder controller is used to control Raspberry Pi/Pico based robots.
The APP integrates Button, Switch, Joystick, D-pad, Slider and Throttle Slider widgets; Digital Display, Ultrasonic Radar, Grayscale Detection and Speedometer input widgets.
There are 17 areas A-Q , where you can place different widgets to customize your own controller.
In addition, this application provides a live video streaming service.
Let’s customize a PiCar-X controller using this app.
How to do?
Install the
sunfounder-controller
module.The
robot-hat
,vilib
, andpicar-x
modules need to be installed first, for details see: Install All the Modules(Important).cd ~ git clone https://github.com/sunfounder/sunfounder-controller.git cd ~/sunfounder-controller sudo python3 setup.py install
Run the code.
cd ~/picar-x/example sudo python3 13.app_control.py
Install SunFounder Controller from APP Store(iOS) or Google Play(Android).
Open and create a new controller.
Create a new controller by clicking on the + sign in the SunFounder Controller APP.
There are preset controllers for some products in the Preset section, which you can use as needed. Here, we select PiCar-X.
Connect to PiCar-x.
When you click the Connect button, it will automatically search for robots nearby. Its name is defined in
picarx_control.py
and it must be running at all times.Once you click on the product name, the message “Connected Successfully” will appear and the product name will appear in the upper right corner.
Note
You need to make sure that your mobile device is connected to the same LAN as PiCar-X.
If it doesn’t search automatically, you can also manually enter the IP to connect.
Run this controller.
Click the Run button to start the controller, you will see the footage of the car shooting, and now you can control your PiCar-X with these widgets.
Here are the functions of the widgets.
A: Show the current speed of the car.
E: turn on the obstacle avoidance function.
I: turn on the line following function.
J: voice recognition, press and hold this widget to start speaking, and it will show the recognized voice when you release it. We have set
forward
,backard
,left
andright
4 commands in the code to control the car.K: Control forward, backward, left, and right motions of the car.
Q: turn the head(Camera) up, down, left and right.
N: Turn on the color recognition function.
O: Turn on the face recognition function.
P: Turn on the object recognition function, it can recognize nearly 90 kinds of objects, for the list of models, please refer to: https://github.com/sunfounder/vilib/blob/master/workspace/coco_labels.txt.