Multithreaded application to communicate with a robot using TCP & UDP socket communication. When the robot & controller are on the same network, they will be able to communicate and the controller can guide the robot through the obstacle course.
View the code on GitHub: https://github.com/Akshat55/Multithreaded-Robot-Controller
The project uses a client-server architecture where the controller (client) communicates with a robot (server). It implements two threads:
- Command thread: Handles sending commands to the robot.
- Telemetry thread: Receives and processes status updates from the robot.
Operations
The robot used in the demo was able to perform the following operations:
- Drive command
- Control Arm & Claw
- Sleep
Classes Implemented
Packet
Implements the robot’s application layer protocol. It handles packet creation that contains:
- Header with command flags (drive, arm, claw, sleep, status, acknowledgment)
- Packet counter for tracking communication
- Data payload
- CRC (Cyclic redundancy check) for data integrity
MySocket
Defines and implements TCP and UDP socket communications. The class is responsible for configuration and communication over a single socket connection. It can be instantiated to operate as a Server or Client connection. A similar instance of the class is being used by the robot.
Main
Provides user interface and coordinates communication