# Design and Development of an Omnidirectional Three-Wheeled Industrial Mobile Robot Platform
## 5 Mechatronic Design
### Control and Simulation System  
This section presents the implementation of a control system that allows the interpretation and execution of PTP and CP instructions, fundamental for the generation of movements of the omnidirectional mobile robot. These instructions are designed to specify trajectories and motions based on key parameters, such as the initial and final coordinates (\(X\),\(Y\)), the type of trajectory (curved or linear), the velocity \(v\), and acceleration \(a\) of the robot. The different ways of encoding the trajectories are detailed below:  
* Linear trajectory: This instruction allows to perform a rectilinear displacement between two points defined by initial and final coordinates, considering constant velocity and acceleration: \[\text{line }x\,y,\,v\,a\]
* Curved path: It specifies a curvilinear motion defined by a radius \(r\), direction of rotation clockwise \(+\) or counterclockwise \(-\), and velocity and acceleration parameters: \[\text{circ }x,y,r\pm,v,a\]
* Rotate around its own axis: It allows rotating the platform around its central axis, specifying a rotation angle \(\theta_{G}\), angular velocity \(\omega_{G}\), and angular acceleration \(\alpha_{G}\): \[\text{rotate }\theta_{G},\omega_{G},\alpha_{G}\]
* Wait time: The robot pauses its operation for a time \(t\) specified in seconds, useful for synchronization with other tasks. wait \(t\)  
Once the parameters associated with the instructions are extracted and assigned to their respective global variables, an algorithm is implemented to convert them to local variables, ensuring modularity and encapsulation of the code. From these variables, the kinematic and dynamic matrices developed in Section 4 are applied to calculate the angular positions of the wheels according to the desired motion.  
Subsequently, the angular positions are transformed into numbers of steps required for the stepper motors. This process includes the generation of signals by pulse coding, ensuring precision in the execution of the movements. Finally, all the generated information is stored in an external memory (SD card), which allows recording and analyzing the system behavior for future optimizations.  
This process is visually described in the flow diagram shown in Figure 25, which illustrates the sequence of operations from the interpretation of the commands to the execution of the movement on the robotic platform.  
Figure 24: Platform safety factor regarding stress.  
Within this operation, the user first generates a.txt file with the code of the coordinates. The Matlab program is executed and subsequently outputs a new.txt file containing a group of characters to be interpreted by the microcontroller. The next step is to insert the SD into the slot and then press the \"2\" button, which represents the cycle start. A \"Cycle in Process\" indicator will light up when the cycle is running, and will turn off when the cycle is finished. If there is a case where the SD is not inserted, an \"SD Read Failed\" indicator will light up. The internal workflow of the stepper motor control algorithm is depicted in Figure 26.  
Figure 26: Flow diagram of the microcontroller algorithm.  
Figure 25: Algorithm flow diagram.