Food
Living
Outside
Play
Technology
Workshop
Drawing Robot by lakshay garg on October 8, 2014
Table of Contents Drawing Robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Intro: Drawing Robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
Step 1: Parts, tools and software required . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
Step 2: Mechanical Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
Step 3: Electronics part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
Step 4: Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
Step 5: Coding continued.......... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
http://www.instructables.com/id/Drawing-Robot/
Intro: Drawing Robot Fixing my drawing incapability with my robotics skills and to me results were not that bad. Now I can at least save my self from humiliation in my drawing class. This project is good for beginners and gives sufficient exposure to arduino, matlab coding and mechanics. There is not much in the electronics department. The bot is a basic 2DOF arm with a pen manipulator. This project involves application of inverse kinematics and canny edge detection.
Step 1: Parts, tools and software required 1. Mechanical Mechanix kit Nut and bolts Pen Holder (Clothespin) 2X Caster wheels 2. Electronics Arduino uno PCB or Bread board Power Supply (5V adapter with 2A current) USB Cable 3. Servo Motors servos 4. Tools Soldering Iron Soldering Wire Screw driver Drilling Machine 5. Software Arduino IDE Matlab (with Arduino IO) Above links are for India, so you can find this stuff with your local retailer easily. You can take any servos with torque greater than 7Kg.cm and for bread board users soldering iron and wire are not required.
http://www.instructables.com/id/Drawing-Robot/
Step 2: Mechanical Design From the pictures above you get the idea of what the design is and how you should go about assembling it. It is more like playing with maker kits when you were 5 or 6 years old. So lets start step by step construction. 1. Drill two holes in each of the horns such that the distance between the two holes is same for all the horns as given in the picture. 2. Now we have to make a rigid support for one end. Drill four holes at appropriate distances as the screws of the servo and attach the servo to the box. We will use this setup to give a rigid support to the setup. 3. Join two combinations of aluminium stripes from the kit to any two horns as shown in the picture such that the distance between the two horns should be ~20 cm. 4. Now attach one horn to the servo with rigid support and one to the other servo and before fixing the horns, calibrate the servos to 90 degrees so that rigid servo is parallel to the stripes and the free end servo is perpendicular to it. 5. Now take two longest stripes (15 cm) fro the kit and attach them to the lower end of the free end servo parallel with it. 6. Then attach caster wheels at the bottom of the arm with the pen which we constructed in step 5 for proper balance and support. 7. The last servo should be attached at the end point of the step 5 with feviquick or glue gun anything that makes it rigid there. 8. With a stripe of appropriate length and clothespin attach the pen to the servo such that the distance from the free end horn and the pen tip should be ~20cm. While construction two points should be kept in mind that the distances mentioned above should be 20 cm and calibration should be done properly. Rest of the construction depends on the availability of parts and your wish. For example instead of aluminium stripes from the kit you can use rulers for arms etc.
http://www.instructables.com/id/Drawing-Robot/
Step 3: Electronics part The picture above is self explanatory you can either make a shield for the arduino as I have done or a bread board for the circuit.
Step 4: Coding This part of the project is the most interesting part and the most important as well. Let me give you a briefing of what is happening. First we take an image and find its edges with the help of canny edge detection and we are going to draw this image. Drawing the image has two parts PART 1: First we find the pixel which is 1 as our image is now in the form of 0s and 1s and then check its local pixels if any one of them is also 1 then the pen reaches that pixel and deletes the previous 1. The function repeats it self recursively and creates smooth lines. PART 2: The second part involves the inverse kinematics part of how to reach that particular pixel. It simply takes in the coordinates of the pixel and calculates the corresponding angles for the pivots, the calculations are shown in the above picture. The above explanation is not required for the execution of the code it is just for understanding. Now how to setup Matlab and arduino for the execution of the code. First install the arduino IO package on matlab (all the instructions are given with the package). Now replace the arduino.m file with the file the file that I have uploaded with same name. Download and save finaldraw.m and draw.m in matlab directory. Upload the adioes.ino file that I have uploaded to the arduino board. See to which port your arduino is connected and then go to finaldraw.m and change COM3 to your port.
http://www.instructables.com/id/Drawing-Robot/
Change the extension of the image which you want to draw to .png. This can be done in any image editor now save this image to the matlab directory. Open the finaldraw.m and change emma.png to your image name with .png extension.Save the finaldraw.m file. I have uploaded the picture of emma watson as a sample, so you can use it for testing and you can also adjust the parameters of the canny edge detection function according to your need. We are done now connect the arduino to your PC and switch on the power supply and type finaldraw in matlab command line. HAVE FUN !!! If you are facing any problems then comment below.
File Downloads
finaldraw.m (735 bytes) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'finaldraw.m']
draw.m (1 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'draw.m']
arduino.m (96 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'arduino.m']
adioes.ino (25 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'adioes.ino']
http://www.instructables.com/id/Drawing-Robot/
Step 5: Coding continued.......... The working of the algorithm is very simple, it is just the matter of visualizing how the bot approaches the image drawing. This is an elaborate explanation and feel free to skip it. Firstly, I convert the the image that I want to draw in png format using some image editor, then I save the Image in the matlab directory. Now our algorithm converts this image using canny edge detection as given in the image above. The mysterious part is drawing this image. What the algo does is it starts checking the pixels of the converted image and when it finds 1 which is indicated as the white pixel in the image above, the pen tip reaches that point (The reaching part is covered in the previous step clearly) and puts the pen down then it checks neighboring 8 pixels, if it finds a 1 it reaches that point without lifting the pen up and deletes the previous pixel to avoid repetition. Now this continues till it finds no 1s in the neighborhood(this is a recursive function) hence it draws smooth line deleting it simultaneously. Then it completes other branches of lines that emerge from the drawn line as it checks every neighboring pixel. This algorithm ultimately creates the whole image. Now watch the video given in the beginning again and try to connect the dots you will surely feel a GEEKY MENTAL ORGASM that I felt when I figured this elegant algorithm after a lot of failed attempts. HOPE YOU LIKED MY INSTRUCTABLE IT WAS MY FIRST SO APOLOGIES FOR A ROUGH TUTORIAL!!!!!!!
Related Instructables
"Can" Bot by ywj_pheej
Tic-Tac-Toe Robot by OddBot
How To Build Your Own Instructables Robot Assistant by JellyWoo
Robotic Arm Plays TIC TAC TOE Game vs human and Draw any shape on an A4 Paper (video) by yasser89
Arduino robot arm (Photos) by marti558
Instructables Site Robot by sunshiine
Advertisements
Comments 31 comments Add Comment
hmshiv1 says:
Oct 26, 2014. 10:59 AM REPLY
Hi Lakshay, Very nice project. how much the whole thing cost in India. I am from Bangalore. I work for underprivileged children.
goldenshuttle says:
Oct 26, 2014. 9:21 AM REPLY if we can only put our hands on how these face-follow small camera's work? or find IC chip that is dedicated for the task of face detection/tracking, one can make a lot of stand-alone amazing Arduino projects. on the other hand; say if a low-re monochrome camera takes a momentarily picture and sends object outline to Arduino which controls x-y servo's to draw the object (with z servo to lift or lower the pen), one may get a stand-alone arduino portrait painter...easily said than done.
askjerry says:
Oct 26, 2014. 9:05 AM REPLY
Drawing with robots is a lot of fun once you get it figured out. PUMA 1 PUMA 2
Electrospark says: Nice! You could make a manual one! ^_^
http://www.instructables.com/id/Drawing-Robot/
Oct 26, 2014. 8:08 AM REPLY
grover.surendra says:
Oct 26, 2014. 5:09 AM REPLY
Very good job.. Keep it up.. Best wishes
mario.malizia.332 says:
Oct 26, 2014. 3:13 AM REPLY
Hi ! I got this problem! Undefined function 'rgb2gray' for input arguments of type 'uint8'. Error in finaldraw (line 2) i=rgb2gray(u);
lakshay garg says:
Oct 26, 2014. 3:55 AM REPLY
post the error that you are getting
mario.malizia.332 says:
Oct 26, 2014. 5:08 AM REPLY
this is the error in Matlab line These are the first three line of (finaldraw.m) u=imread('trollface.png'); i=rgb2gray(u); w=edge(i,'canny',[.05,.20]);
mario59 says:
Oct 26, 2014. 2:15 AM REPLY
Hi to all! It's a nice work. Just to mention, there's another Italian guy, Livio, who did this *FANTASTIC* job. I personally tried it, and it's all *real*: The full project (Open source) can be found here: http://www.theremino.com/en/blog/robotics-and-cnc/ ciao!
lakshay garg says:
Oct 26, 2014. 2:38 AM REPLY Wow really liked the accuracy of those servos. To be honest my project is not so accurate but it also uses real world photos and their processing can never be accurate, in fact you cannot define accuracy in drawings/sketches so my project works good enough in that department.
mario.malizia.332 says:
Oct 26, 2014. 2:52 AM
(removed by author or community request)
lakshay garg says:
Oct 26, 2014. 3:54 AM REPLY
post the error
lakshay garg says:
Oct 26, 2014. 3:20 AM REPLY
There is a readme.txt file in your package there you will get everything you need
mario.malizia.332 says:
Oct 26, 2014. 2:43 AM REPLY
E' roba italiana? :O Finalmente.
lakshay garg says:
Oct 26, 2014. 3:21 AM REPLY
Sorry I don't understand this language
mario.malizia.332 says: Hello! I have just finished my project, the only thing is ; Where to get Matlba free? Or how to use another 3D Image program? Please, is very important, I will put photos and videos of the final project as soon as I have finished this.
http://www.instructables.com/id/Drawing-Robot/
Oct 25, 2014. 5:51 AM REPLY
lakshay garg says:
Oct 25, 2014. 6:51 AM REPLY
Try utorrent even though I don't recommend it. I have got it from my college admin. You can try open CV or octave which is a linux alternative to matlab but I am not sure if it has arduino support. So you will have to do some work on your own.
mario.malizia.332 says:
Oct 25, 2014. 4:18 PM REPLY
Utorrent is the way ( troll), I'm goint to update you asa it works I'm downloading right now
vpidone says:
Oct 24, 2014. 3:06 PM REPLY
Interesting. A Matlab license costs just above U.S. $2,000.00 Can this be done without Matlab?
lakshay garg says:
Oct 24, 2014. 7:27 PM REPLY Actually I am a college student so got it free from the admin.You can definitely use openCV for image processing and you will have to do some work to find a way to setup a serial communiction b/w your openCV code and your arduino. Trust me this part is not very sweet without matlab. So give it a try and tell me If you get any results.
SparkySolar says:
Oct 24, 2014. 6:51 PM REPLY
Thank you for your nice instructable. Rima
Abhinav Bajaj
says:
Oct 24, 2014. 5:32 AM REPLY
good work lakshay
Royell says:
Oct 24, 2014. 5:21 AM REPLY Wonderful, it's sort of like a game of minesweeper, except it's trying to hit the mines. As one who isn't graced with a natural talent for drawing, but would like pictures with that sketched look, this would be awesome!
madhav _8558 says:
Oct 23, 2014. 12:23 PM REPLY
nice 1 bro
lakshay garg says:
Oct 23, 2014. 12:55 PM REPLY
thanx!!
goldenshuttle says:
Oct 19, 2014. 7:31 AM REPLY
Although the way it works not so clear(maybe its my slow brain); but the project is very creative, I vote for you.
lakshay garg says:
Oct 19, 2014. 7:52 AM REPLY
Thanks and sorry for bad explanation I will try to improve it surely.
kyaylayan says:
Oct 11, 2014. 9:03 AM REPLY
Drawing pantograph you can construct easily.
novelchip says:
Oct 10, 2014. 11:20 PM REPLY
well done !
seamster says: Very cool! Thanks for sharing this!
http://www.instructables.com/id/Drawing-Robot/
Oct 10, 2014. 10:05 AM REPLY
lakshay garg says: glad you liked it.
http://www.instructables.com/id/Drawing-Robot/
Oct 10, 2014. 10:21 AM REPLY