During the end of the 2022 fall semester, I had the privilege of working with three other undergraduate students for the ME 598 Introduction to Robotics final project. Our group developed algorithms to autonomously navigate and localize a swing-type mobile robot inside MATLAB's Robotics Playground simulated robot environment. These algorithms then allowed the robot to sort colored objects into their respective designated zones inside the arena.
Our algorithms were modular enough to sort any provided configuration of colored objects in under 2 minutes, and our final deliverables (report, code, and video submission) all received perfect grades.
The purpose of this project was for students to develop MATLAB algorithms for the following situations:
Recognizing and seeking objects based on color
Use arena geometry to determine zone locations
Push objects to their designated zones
Avoid wall collisions
Return to arena origin
The arena walls are each 5 meters long with the origin defined at its center [0, 0]. The robot will always begin at position [-1.5, 0], and there will always be two moveable objects present, one each at [0, 1.5] and [0, -1.5]. Each object will be either red, green, or blue with no repeating colors resulting in 6 possible starting conditions.
The provided MATLAB template gave students access to the following sensors:
3 Distance Sensors
3 Color-Specific Distance Sensors
3 Color-Specific Angle Sensors
Odometry Sensors (xPose, yPose, and tPose)
During trials, the robot must operate autonomously without any form of input from users or outside of the simulation
Robot may not be modified in any way (sensor parameters, additional sensors, etc.)
Robot cannot hit the wall
The autonomy required by the robot was simplified into a repeatable loop featuring the following segments (on the right).
The robot would first determine a goal position in the simulation (i.e. puck or zone), calculate the angle between the robot to the goal position and turn to the position, and move toward the position while checking a boundary condition (i.e. distance or time). If the end condition had been met, then the robot would stop.
A Simulink function block was used to intake the robot's goal position (State / Target), x position, and y position and then use trigonometry to determine the angle from the robot to the goal position. This angle was converted to [0, 359] degrees since MATLAB's atand() function converts to [-90, 90].
Six goal positions were designated beforehand: Top Puck, Red Zone, Blue Zone, Green Zone, Bottom Puck, and Center (Home). The coordinates for the zones' locations were placed at the top right corner (red), bottom right corner (green), and middle left (blue) although the robot would never actually reach that coordinate for it would hit the wall.
The calculated angle is then compared against a range of the robot's current angle (t_pose) to determine when the robot has rotated to the correct point.
Another Simulink function block was used to identify the color of the puck by intaking the robot's 3 color-specific distance sensors (red_distance, green_distance, blue_distance).
The function block output the distance to the colored puck (Col_Distance) and a numerical reference for the color (Red = 1, Green = 2, Blue = 3).
A majority of the MATLAB logic occurred in a Stateflow block that managed the inputs of the previous 2 Simulink function blocks and output motor signals to move the robot around the simulation environment. This block would loop multiple times, following the flowchart shown at the beginning.
The robot first rotates around its center until it reaches the right angle. Depending on the goal position of the robot (see Stateflow Pause Outcomes), the robot would then move toward its goal position and perform different tasks to set up for the next goal position. The output State would then feedback into the calculate_angle Simulink block to restart the loop and determine the next goal location. This would repeat until the robot would return to the center of the arena and stop moving.
The wall avoidance algorithm pulled data from the robot's 3 distance sensors (Left_Distance, Right_Distance, and Front_Distance). These inputs were converted to a range of [0m, 2m] to prevent any nan signals.
The Stateflow block modified the incoming left and right motor signals by slowing down and reversing the output motor signals based on the distance sensors.
The lab group was able to successfully develop algorithms to autonomously control a simulated mobile robot to sort colored objects into different zones while avoiding collisions with walls. All simulations were run in under 2 minutes.
Big thanks to my groupmates who were extremely helpful and active throughout our previous labs and this final project.