The Trash Picker
Use [Drive for] and [Turn] blocks, and the Front Distance Sensor to drive the VR Robot to collect as much trash as possible before the batteries run out.
- Select the Coral Reef Cleanup Playground.
- Code the VR Robot to collect as much trash as possible before the batteries run out.
- Set desired turn velocity. Use the [Turn] block to keep rotating the Drivetrain and use the Front Distance Sensor to check for trash.
- If the Front Distance Sensor detects a piece of trash, drive the VR Robot for the distance between the robot and the piece of trash to collect it.
- Use the [Forever] block to keep the VR Robot constantly checking for and collecting trash.
Helpful Hints
Use the FrontDistance found object block from the Sensing category to report if the Front Distance Sensor detects an object within its field of view.

Matching Python command:
front_distance.found_object()
Use the FrontDistance Reporter block from the Sensing category to get the distance of the nearest object from the Distance Sensor.

Matching Python command:
front_distance.get_distance(MM)
Use the if then block from the Control category to check if the Front Distance Sensor detects a piece of trash and run the code to collect the piece of trash if the Boolean condition is true.

Matching Python command:
if front_distance.found_object():
Use the Forever block from the Control category to keep the VR Robot constantly checking for and collecting trash.

Matching Python command:
while True: