Let's Make Robots! | RobotShop

Raspberry Pi Robot Arm with simple Computer Vision

Looks for screws and picks them up

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Very cool project!

I like the fact that you implemented a sinewave pattern for acceleration. Servo are often doing brutal movements and your arm movement are much more elegant.

I was quite surprised in your last video however, why is there such a lag between your movements and the movement of your robot? The PI CPU is a powerhouse compared to an Arduino so I don't understand why the arm doesn't follow your movements in real time.

I like your project and I'm curious, I might take an evening to peek into your code to see how you made it. :o)

Hello Drake,

You are of course right. The Raspberry Pi is a powerhouse and even I must admit that I probably should have done the position following in real time.

Here however is the reason, why I at the time considered this the best solution: I remember doing the following in real time. The movement was quite shaky and I didn't like it. I wanted to use the sinewave start/stop controller. But the thing only works if there's a fixed goal position. So the way the arm following works is that the joints wont except a new goal position until they reach their current goal position. Another thing I noticed was, that there can be a lot of shaking going on when all the joints move at the same time. It looked a bit clumsy sometimes. That's why I decided that the joints should move one after another.

The result was acceptable movement, from the viewpoint of elegance. But with a lot of lag. I probably should have rewritten the controller... But you know how it is when hacking around on robots... Sometimes, other things seem more important; At the time I was all about getting a camera hooked on the thing and finally start with the Image processing algorithms. ^^

That make sense. :)

Especially if we consider this step as a transition to the camera processing (when the robot knows exactly it's destination)

great project buddy - can't wait to see how it develops!

Hello craighisset,

Thanks for the comment. I'm actually not sure if there will be a "next step" for this project. At the Moment I'm giving the ancient quest of "making a Servo from a geared motor" a try. ^^

You did a great job on the smooth movement of the servos.  That is hard to do.

That is cool you did your own video processing stuff.  OpenCV makes it a lot easier.

Thanks for sharing.

Regards,

Bill

Hello Bill, Thanks for the comment!

The smooth movement actually wasn't that hard to do. The reason beeing that I used Dynamixel servos, which provide an easy way to control not only the goal position, but also the current speed! 

A super project!.

As someone who has no mechanical skills do you have any construction details?

 

Many thanks

 

BD

Hello BD,

The construction is quite simple. Just go to the DIY center of your choice and buy some aluminium profiles. Some kind of quadratic profiles will do the job. Then you need a drill. And 4 Dynamixel AX-12As. Just drill some holes in such a way, that you can screw the profiles on the Dynamixels. The rotating part of the Dynamixel servo has 4 M2.5 (or M2 I'm not sure anymore) holes on it. just screw the aluminium profile on it and you'll get the same thing I've done (or maybe even better, depending on how much time you spend on polishing the thing!). the profile should be about 12 cm long. I remember shorting at least one a little bit more because the servos reached their limits when doing some certain postures.

-Nekojiru 

Can you expand on how you smoothed the movement? In laymens terms? How can I reproduce or learn from your code to implement the same smoothing in my own dynamixel motors?