In this video we will go over the setup and the capabilities of the Dorna 2 robot for drawing an image. Dorna 2 robot can replicate SVG file to draw an image on a given surface. In this experiment we use Python programming language for converting the SVG file into robot commands.
You can find the original document here on our website: https://dorna.ai/blog/dorna-drawing/
We will need to attach the pen holder toolhead. We have the links to the materials below. You can use a 3D printer for two of the parts and you will need to order a few of the materials.
|Two 3D printed parts
|9 x M3 10mm length and 1 x M3 bolt
|2 x 35mm springs
|1 x pen(preferably Bic pen)
|2 x 50mm Standoff Column Spacers with 5mm outer diameter
Put the smaller 3D printed piece around the shafts and the springs attached as well. If the shaft doesn’t slide along the small 3D printed piece it is recommended to sand paper the holes down. Make sure to have the small 3D printed piece oriented to hug the wall farthest from the mount holes on the larger 3D printed piece as shown below. Screw four M3 screws into the ends of the shafts to lock them in. Now attach the part to the Dorna 2 robot by using four M3 screws. Lastly put the pen through the large hole and screw on an M3 bolt and nut. If the pen is too small for the hole, an easy solution can be to wrap it in tape to create a bigger outer diameter for the pen.
Find an image in SVG format or convert a file to SVG format (use InKscape for that purpose). You can read into how the SVG format works thanks to MDN.
Actions Needed to Run
Here we use Python for programming the robot, You need to download Python and Dorna 2 Python API if you haven’t already done so. The line below allows you to connect to your Dorna 2. Replace the
"robot_ip_address" based on your robot ip address, for more information on the API.
The line below takes the path to the SVG file and generates the commands associated to that SVG file.
When the program is run. It will ask you to turn off the motors. Be sure to hold the robot when turning off the motors because it will fall. Then a command will ask you to direct your robot to the left bottom corner of your paper. Make sure to have the toolhead attachment perpendicular to the surface. Not doing so will have the tool attachment going deeper into the surface than desired when drawing the image. For each point, set the pen so it is barely touching the surface. The command will then ask you to direct the robot to the top right of the paper. Lastly you will then direct the robot to a point along the line clockwise of the left bottom coordinate as shown below. A command asking to turn on the motors will come up. After doing so, the Dorna 2 robot will draw the image.
This part of the code allows you to change the parameters for a faster drawing or a more precise drawing. Recommendations are given, but the numbers can be changed. The numbers will change the upper limits of the motion parameters.
Explanation of Code
We can take a look at the main function. This section is at the bottom of the code. The main function starts by connecting to the robot.
Next the starting points are initialized by calling the
.startingpoints() function. With the guidance of the user we can set the 3 points of the paper to understand the size of the paper and to understand the equation of the plane. This is used so if the surface isn’t completely flat the program will modify the path to a new plane.
Next we call a function that allows us to find a 3rd corner of the paper. This helps us define the papers width and length and allows the program to have a upper limit for the surfaces width and length in 3D space.
Now, we want to convert all points on an xy plane of the input SVG file to a xyz plane of the robot. This can be done by a linear formula of
[[x],[y],[z]]= T * [[x0],[y0]] + B
The T stands for transformation and can be solved using the 3 corners of the plane. T is a 3×2 matrix. B is a 3×1 matrix. B is the starting position’s coordinates. Next we want to find the perpendicular vector from the plane. This will help to move the robot away from the paper when lifting the pen on a drawing.
Next is a function that creates the path. This is the bulk of the code. This function creates a xy path from the SVG path provided. The function will then transform the 2D path into a 3D path. The 3D path will then be translated into robot commands.
The last few lines of the code takes the list of commands created from the the function above and sends it to the robot to perform. The robot will close the WebSocket connection and stop moving when the image is done. For more information on robot commands.