This project demonstrates how to control a simulated differential drive robot using natural language commands, powered by ChatGPT/Gemini large language model. The robot simulation is handled by the PyBullet physics engine.
- Natural Language Control: Speak or type commands like "move forward," "turn left," or "stop."
- ChatGPT/Gemini Integration: Leverages the ChatGPT/Gemini API to interpret diverse human commands into robot-understandable actions.
- PyBullet Simulation: Provides a lightweight and robust physics-based simulation environment for a custom differential drive robot.
- Modular Design: Easily adaptable to more complex robot models (e.g., quadrupeds, humanoids) by modifying only the robot simulation module.
-
Clone this repository:
git clone [https://github.com/your-username/RobotChatGPTControl.git](https://github.com/your-username/RobotChatGPTControl.git) # Replace with your repo URL cd RobotChatGPTControl
-
Create and activate a Python virtual environment:
python -m venv venv .\venv\Scripts\activate # On Windows # source venv/bin/activate # On Linux/macOS
-
Install dependencies:
pip install google-generativeai pybullet python-dotenv numpy
-
Set up your ChatGPT/Gemini API Key:
- Obtain an API key from the Google Cloud Console.
- Create a file named
.envin the root of this project. - Add your API key to the
.envfile:orGOOGLE_API_KEY="your_gemini_api_key_here"OPENAI_API_KEY="your_chatgpt_api_key_here"
-
Activate your virtual environment (if not already active):
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\venv\Scripts\activate # On Windows
-
Run the main script:
python main.py
-
A PyBullet simulation window will open. In your terminal, you can now type commands like "move forward a little," "turn right sharply," or "stop."
main.py: The entry point, orchestrating communication between the user, ChatGPT/Gemini, and the robot simulator.chat_interface.py: Handles API calls to ChatGPT/Gemini and translates natural language into structured robot commands.robot_simulator.py: Manages the PyBullet simulation, loads the robot model, and executes received commands.robots/: Contains the URDF (Universal Robot Description Format) files for the simulated robots (e.g.,simple_diff_drive.urdf).
Feel free to explore and modify the code to experiment with different robot behaviors or integrate other simulation environments!