A real-time, bi-directional Client-Server system developed for the LEGO Mindstorms EV3 platform, utilizing TCP/IP Sockets. The EV3 (Pybricks Server) acts as a digital sentry, streaming real-time color readings from its sensor. The Desktop GUI (Python/Tkinter Client) provides visualization, user control, and the capability to transmit remote motor control commands back to the robot.
This project was developed as a laboratory exercise to demonstrate the implementation of a robust, low-latency communication model within a robotics context. It successfully bridges the gap between the embedded environment of the EV3 and a feature-rich desktop application, focusing on network-enabled remote control and sensing capabilities.
The repository is organized to clearly separate the platform-specific codebases and documentation.
| Path | Type | Content and Purpose |
|---|---|---|
Color-Sentry-EV3/ |
Repository Root | The main project directory. |
├── client/ |
Folder | Contains the code for the Client application on the PC (Graphical User Interface). |
│ ├── gui_colori.py |
Python File | The main GUI in Tkinter and the logic for managing the Socket Client. |
│ └── requirements.txt |
Text File | List of Python libraries required for the client (e.g., Pillow). |
├── ev3-server/ |
Folder | Contains the code for the Server application running on the EV3 robot. |
│ └── main.py |
Python File | The core Pybricks code for the EV3: sensor initialization, motor control, and Socket Server logic. |
├── .gitignore |
Configuration | Instructs Git which temporary files and directories (__pycache__, system files, etc.) to ignore during commits. |
└── LICENSE |
License | Contains the terms of the MIT License, defining how the code may be used and distributed by others. |
The system operates based on a strict two-component TCP/IP architecture, ensuring modularity and clear separation of concerns. The communication is established over a local network (e.g., Wi-Fi or USB tethering), with the EV3 listening on Port 12345 (as defined in ev3-server/main.py).
The EV3 Brick runs the server application, built using Pybricks (Micropython).
- Role: Data acquisition (Color Sensor on Port S1) and actuation (Motor control on Port D).
- Mechanism: Initializes a Socket Server and manages the continuous communication loop.
-
Operation:
Data Stream (EV3
$\rightarrow$ Client): Reads the current color and transmits the color name as a string in real-time. Command Stream (Client$\rightarrow$ EV3): Receives discrete commands (e.g.,START_MOTOR,STOP_MOTOR) and executes them via the Motor device interface.
The Client application runs on a standard PC.
- Role: User Interface, real-time data visualization, and remote command transmitter.
- Interface: Built with Python's Tkinter (included in standard Python 3) for the framework and Pillow (PIL) for custom graphics and visual theme implementation.
- Mechanism: Establishes a Socket Client connection to the EV3's IP address. It utilizes threading to process continuous socket data reception without interrupting the main Graphical User Interface (GUI) thread.
- Hardware: LEGO Mindstorms EV3 Brick, EV3 Color Sensor (Port S1), EV3 Large Motor (Port D).
- Software (EV3): EV3 Brick running Pybricks/Micropython.
- Software (PC): PC with Python 3.x installed.
1. Code Transfer: Upload the file located at ev3-server/main.py onto your EV3 brick.
2. Network Configuration: Ensure the EV3 is on the same local network as the Client PC and note its specific IP Address.
3. Execution: Run main.py on the EV3. The server will initialize and await a client connection on Port 12345.
-
Dependencies: This project requires Python 3.x dependencies for the Graphical User Interface (GUI). Install the necessary libraries listed in
requirements.txt:pip install -r client/requirements.txt
(Note: The primary external dependency is Pillow (PIL) for handling graphical assets, while Tkinter is included in standard Python 3 distributions.)
-
Configuration: Crucially, update the
SERVER_IPvariable within the fileclient/gui_colori.pyto match the IP Address of your EV3 Brick on the network. -
Execution: Launch the application from your command-line interface (CLI):
python client/gui_colori.py
-
Operation: Use the dedicated buttons within the GUI to initiate the socket connection, observe the real-time color stream, and transmit motor control commands remotely to the EV3 server.
- Detailed Thesis: A complete technical analysis, including communication protocols, implementation details, and performance results, is available in the
docsfolder. - License: This project is licensed under the MIT License. Refer to the LICENSE file for complete usage and redistribution terms.