An environment to control and manage a Freenove_4WD_Smart_Car_Kit_for_Raspberry_Pi.
The server is the car and a client is a remote host.
File client.py
handles all TCP connections with the car. (used by Flask server)
Three sockets can be opened :
- one for sending commands to the car (e.g. rotate servos, light up LEDs...)
- one for the camera stream
- one for retrieving car information (e.g. CPU usage, battery percentage...)
Folder 'car_utilities' contains low-level code to interact with the car Raspberry Pi. (from original repo)
The file app.py
is the Flask application entry point.
A Flask server used to control the car via HTTP.
The Flask application handles the client side by creating sockets. Endpoints are used to control and manage the car. Multiple clients are allowed.
The file server.py
is the server to be launched on the car. Handles incoming client connections and requests.
Launch sudo python3 server.py
on the car
Run ./venv/bin/flask --app app run
to start the Flask app.
First, initialize the connection by sending a GET request to /connect/{car_pi}
.
ci=
(client index) argument which indicates to which car to send the commands.
Name | Required | Type | Description |
---|---|---|---|
ci |
required | integer | The car index |
set up the connection between the client and a car
Lights an LED according to a given color.
Name | Required | Type | Description |
---|---|---|---|
value |
required | string | The LED index follow by three integers for RGB color.LEDINDEX_REDVALUE_GREENVALUE_BLUEVALUE e.g. value=0x01_255_255_255 will turn the LED 1 white |
Change the speed of the wheels.
Name | Required | Type | Description |
---|---|---|---|
value |
required | string | The speed for the four wheels.LEFTUPPERWHEEL_LEFTLOWERWHEEL_RIGHUPPERWHEEL_RIGHTLOWERWHEEL e.g. value=2000_2000_2000_2000 will make the car go forward |
Change the orientation of the servos.
Name | Required | Type | Description |
---|---|---|---|
value |
required | string | The servo ID followed by the degree of the angle.SERVOID_DEGREES e.g. value=0_90 will turn the servo 0 to 90 degrees |
Activate or deactivate the buzzer.
Name | Required | Type | Description |
---|---|---|---|
value |
required | integer | The activation value .ACTIVATIONVALUE e.g. value=0 will turn on the buzzer |
Start a video recording.
Name | Required | Type | Description |
---|---|---|---|
framerate |
required | integer | The number of frames per second captured. |
height |
required | integer | The height in pixels of the video. |
width |
required | integer | The width in pixels of the video. |
Stop the current video recording.
Activate the data collection.
Deactivate the data collection.