Code - Robot 4
Context
The code below presents the different steps involved in the transfer, detection, and placement process of square tokens from Conveyor 4 to the Vision Set, where they will later be picked and sorted by Robot 5.

Below is a detailed step-by-step explanation of the robot's behavior:
1. Initialization and Main Loop
Before starting the loop, the robot configures its tools by performing the tool scan and conveyor scan functions. The program then enters an infinite loop, allowing the robot to first move to its waiting position directly above the conveyor belt.

Active Conveyor Management (repeat while Get: DI5)
-
Condition: The robot executes the inner block as long as input DI5 (the IR sensor) remains active.
-
Action: The conveyor runs at maximum speed to transport square tokens while no object is detected by the sensor.
-
Trigger Event: As soon as a part interrupts the sensor beam connected to DI5, the program immediately exits this sub-loop.
```
```
Stopping and Picking the Part
Once the part has been detected by the DI5 sensor:
-
Delay: The robot waits for 2 seconds. This allows the part to travel precisely from the sensor position to the pick location and settle against the mechanical stop.
-
Conveyor Stop: The conveyor is stopped to ensure a stable and accurate pick operation.
-
Approach (Pre-Grasp): The robot moves down toward the part in two stages.
-
Pick: The vacuum pump is activated to grip the part.

Transfer and Release
Once the robot has picked up the part:
-
Clearance Move: The robot moves back up to a safe intermediate position immediately after the pick. This position uses the same coordinates as the approach position.
-
Move to the Placement Area: The robot rotates toward the Vision Set and then moves down to the placement location.
-
Placement: The robot opens and deactivates the vacuum pump to release the part.
-
Safety Retreat: The robot raises slightly to avoid colliding with the deposited object, after which the main loop starts again from the beginning.
Summary
The robot runs the conveyor and waits for a part to pass in front of the DI5 sensor. It then waits 2 seconds to allow the object to settle against the mechanical stop, stops the conveyor, picks up the object, rotates toward the opposite side to place it in the Vision Set, and finally restarts the conveyor for the next part.

