This project demonstrates how to create a simple MoveRCCar API using FastAPI, allowing you to control an RC car using text commands from ChatGPT4.
The API was mainly written by using chatGPT itself
- Python 3.7 or higher
- FastAPI framework
- PySerial library (for controlling the RC car)
NOTE: These steps assume the use of Windows CLI or Git CLI on Windows
- Open the CLI and locate in the appropriate directory for work on this project
- Create a directory called "RC_car_api"
- Move to that directory
- Create a virtual environment for the example
python -m venv chatgpt_rccar_api_venv
- Activate the environment, using one of the following commands
source chatgpt_rccar_api_venv/bin/activate # for Unix/Linux chatgpt_rccar_api_venv\Scripts\activate # for Windows source chatgpt_rccar_api_venv/Scripts/activate # for git CLI on windows
- Clone the repository within "RC_car_api" directory with the following command:
git clone https://github.com/Karosuo/chatgpt_rccar_api.git
- Install the requirements
pip install -r chatgpt_rccar_api/requirements.txt # Remember the correct use of forward/backward slashes when using widnows CLI or git CLI
- Move into the cloned directory
- Run the server by using the following command:
uvicorn main:app --reload
In order to make the car move, we can request it directly, or make it a bit more interesting, like "Your goal is to get to the apple, which is 2 blocks ahead an 1 to the right, move the car accordingly to make it to the apple"