Raspberry Pi Robot Arm with simple Computer Vision
A small Raspberry Pi robot arm I made over the past few month.
The robot arm is made of:
· 4 Dynamixel AX-12A servos
· 1 Raspberry Pi 2 model B
· 1 Raspberry Pi camera module
· 1 Electromagnet on the top
· Aluminum, wood
· A small circuit for communicating with the servos (see here for more info’s)
· Colorful ribbon cables
The Robot is able to search for screws (image processing with the Raspberry Pi camera module), pick them up and put them somewhere. Things I tried to optimize while building the thing:
1. Make it move as smooth as possible
2. Make it pick up the screws as consistent as possible
I wasn't satisfied with the servos moving around when given just the goal position. The stopping and starting was too harsh, too sudden. The robot arm was shaking after reaching it's goal position. I tried to fix this by implementing a software start-stop controller. Given a goal position, it makes sure that both the start and stops are shaped in the form of a sinewave. This means, that the motor would start fast, but slow down as it reaches it's goal speed. The same goes for stopping. The robot arm slows down fast at first, but slowly in the end. This was supposed to make it move more elegant, more smoothly. And to a certain degree, it works well.
The second thing worth mentioning is the Image Processing. I didn’t use OpenCV. The image processing algorithms applied here are all very simple. I wanted to write them by my own. An important library which I used was pythons "picamera". "picamera" provides an easy way to get greyscale pixel data from the Raspberry Pi camera module. The pixeldata then was put through some algorithms: Edge Detection, Binarization, Pixel Expansion, Labeling and Object Extraction. After that, the robot knows the positions of the objects in front of him (only in the x-y plane though). and it's area in pixels. It won't try to pick up an object if it's too small.
Here's the source code: screwPicker @ GitHub
Some words to the 3 videos I embedded:
1. The first video shows the robot searching for screws and other things and picking them up. In the second half of the video, I tried to convey how the robot sees the things.
2. The second video shows the robot picking up a small "mountain of metallic things". Notice that the robot thinks the mountain is one big object most of the time. It tries to pick it up and after putting it somewhere it checks if there is something left and then starts over again.
3. The last video is the oldest one. In it you can see how I tried to teach it positions with a small wooden replica arm. Note that there's no camera on the robot arm at the time.
Looks for screws and picks them up
- CPU: Raspberry Pi 2
- Operating system: Linux
- Power source: 12v
- Programming language: Python
- Sensors / input devices: Raspberry Pi camera module
- Target environment: indoor