Activity: Claw Attachment
Use the claw to grab the Meloncube and perform delivery tasks in a warehouse scenario. Use the colour sensors on the robot to read colour codes for delivery instructions.
Setup
The initial activity can be to have an indicator line on the ground using tape, which the robot starts behind. The Meloncube can be placed 30cm in front of this line, and students can be tasked to grab the cube and bring it back over the line. Depots can then be introduced to create a warehouse scenario.
Any object can be used in place of our Meloncube, however, if you wish to use it, head on over to Printables or Thingiverse to download the print file:
Depots are walled square areas for the rover to deposit a Meloncube in. The walls can be constructed from tape on the ground or solid materials in a 20cm x 15cm area. Use the diagrams below as a reference for the layout of the depots. A number can be allocated to each depot, and students can deliver the cube to each depot on demand.
Add coloured tape to the previous challenge to add more complexity. The tape could indicate which depot the cube must be delivered to. The rover can use the colour sensor to detect the colour of the tape and use the appropriate delivery instructions. A final extension challenge is leaving the cube in one of the depots and having the rover retrieve it and put it behind the indicator line.
Here’s Our Approach
Constant - A constant is a variable that never changes when the code is run. In python, we write this in all capitals with underscores between words.
1) Setting the Constants:
Start by defining two constants: the servo claw open and close positions. Trial and error will have to be used to find the correct settings for your rover.
2) Grab and Release:
Next, make two functions for ‘grab’ and ‘release’. While these functions only have the ‘Move Servo’ block, doing this makes it easier to understand the code.
3) Data Input:
In the main code, we’ll make a variable named ‘Input’, which will request the depot number to deliver the cube.
If you’re using colour indicators instead, the input request can be replaced with an ‘if else’ statement that detects the colour and sets the input to a depot number.
4) Secure the Cube:
Once the robot has acquired the delivery instructions, the robot will approach the cube and use the ‘grab‘ function to pick up the meloncube.
5) Delivering the Cube:
Depending on how your depots are set up, create delivery instructions using movement blocks to deliver the cube. Finish off the code by releasing the cube.
Complete Code:
Tip:
You can add tracks on the ground for the rover to line-follow or create maze walls to allow the use of the IR sensors for navigation.