liveBook · Manning

Pick-and-place robot

As explained in Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi

A pick-and-place robot is a robot that transfers objects between locations by grasping, moving, and placing them.

A pick-and-place robot transfers items between locations. In manufacturing, these robots pack produced items for shipping, offering greater speed and reliability than manual picking and placing. Their form varies with the items being handled. section 11.3.2

A snack-pushing robot demonstrates part of this workflow: it locates a snack by QR code, drives to it, moves a servo arm to push it, and returns to its start position. Pushing items toward a conveyor belt can support later factory processing. section 11.3.2

From pushing to grasping

A warehouse-style extension would replace pushing with a mechanism that grabs an item and places it at another location. This changes the robot's physical action while retaining the task of finding and transferring selected items. section 11.4.3

Listing 11.2 pusher_qr.py: Library to detect and push matching snacks
#!/usr/bin/env python3
from os.path import dirname
from csv import DictReader
from emoji import emojize
from adafruit_crickit import crickit
import motor
import os
import time
import cv2
 
ITEMS_FILE = dirname(__file__) + '/items.csv'
IMG_PATH = os.environ['XDG_RUNTIME_DIR'] + '/robo_stream.jpg'
MAX_MOVES = 20
SERVO_ANGLES = dict(up=70, down=180)
decoder = cv2.QRCodeDetector()
 
def get_items():
    lines = [emojize(i) for i in open(ITEMS_FILE)]
    return list(DictReader(lines))
 
def decode_qr():
    img = cv2.imread(IMG_PATH)
    data, points, _ = decoder.detectAndDecode(img)
    return data
 
def goto(target, direction):
    motor_func = getattr(motor, direction)
    for i in range(MAX_MOVES):
        motor_func(speed=1, duration=0.1)
        data = decode_qr()
        if data == target:
            return True
        if data == 'end' and direction == 'forward':
            return False
    return False
 
def swing_arm():
    crickit.servo_2.angle = SERVO_ANGLES['up']
    time.sleep(0.5)
    crickit.servo_2.angle = SERVO_ANGLES['down']
    time.sleep(0.5)
 
def push_item(code):
    found = goto(code, 'forward')
    if found:
        motor.backward(speed=1, duration=0.3)
        swing_arm()
    goto('start', 'backward')

The reusable library combines QR decoding, motor movement, and servo control to find and push a selected snack before returning home. section 11.3.2

How Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi covers it

How deep it goes
Introduces the category and sketches a grabbing-and-placement extension, without implementing a gripper or placement routine.
Examples
Uses a QR-coded snack pusher that drives along a track, swings a servo arm, and returns to start.
What it assumes
Assumes familiarity with the existing robot's QR detection, track movement, motor, and servo-arm behavior.
What you can do after
Evaluate/understand how a QR-guided pushing robot could evolve into a warehouse-style grabbing and placement system.
How it connects
Connects item transfer with QR code detection, servo control, motor movement, conveyor belts, and warehouse robots.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi. The section links point to the parts of the book it draws on.