Drawing Machine, with a Brain

Drawing machines are a decent project to build from scratch, but they are not complex robots by today’s standards. They use open loop motors, and the kinematic model is relatively simple and well-understood. Open-source firmware like Marlin  can be used to control the robot like a 3D printer using G and M commands, and is easily added on to in order to perform custom movements.  So what is so special about my design? I’m making this robot for a graduate level robotics class after all, not just for the fun of it.

I’ve developed a series of goals and “stretch goals” to implement in the drawing bot, in order to try something new that improves on the intelligence of the robot. The ultimate goal here is to create a machine that replicates a human’s ability to sketch on paper with a pencil/pen, so a more intelligent machine would be one that more fully accomplishes this task.

1st Goal: Page Detection and Alignment

Most drawing robots are completely open loop, they assume that either the page is completely in their workspace and is aligned with the origins of the robot, or that it is infinite (see polar-style machines). Human intellect is required to align the workpiece to the workspace, which can be difficult when trying to draw near the edges of the space. To automate this part of the process, we would need to perform an operation of detecting the size, location, and orientation of the paper. The robot could then scale and transform the image to be drawn, to this workspace.

How do I plan to implement this?

OpenCV is a computer-vision library that works in python, C++ and other programming languages. It works at the Operating System level, so you can’t implement it on a micro-controller, but it has many built in image detection and processing algorithms, which makes it a very useful tool. I plan to try two different methods here:

  1. Implement a compact camera with a short focal length on the underside of the machine’s drawing gantry, so the image produced has a fixed offset from the stylus. By panning around, the camera can produce an image of the entire workspace, which can then be used to detect the page.
  2. Build an overhead gantry with a camera in a central position. it has a fixed height which determines the #pixels/inch in its images, and can use a fixed reference fiduciary mark to detect the paper.

Both techniques will look for contrasting edges, a subject which I’m currently learning. One technique I’ve been researching for detecting the central location/orientation of the page is Principal Component Analysis, or PCA. This technique looks at the variance in different directions of the object, and uses these to determine the reference frame. OpenCV has functions dedicated to PCA, so that will be one of the first things I try out when I get my cameras operating. I will likely just use geometric rules to figure out the size of the page from there.

Example of PCA being applied to several objects. Provided in svpenkov’s blog post.

Once I have the reference frame, I can use a frame transformation matrix, applied to the data points, to line up the art intended to be drawn to the workpiece. I may also attempt to scale down the drawing if it’s determined that it can’t fit on the page. These can directly modify the G  commands (which dictate movement in the axes of motion for a CNC machine) to perform the physical transformation.

framexform

2nd Goal: automatic pen height/pressure sensitivity.

Almost every drawing machine design that I have come across has simply used an open-loop mechanism to raise and lower the drawing implement between two fixed positions. This works, mostly, but it doesn’t account for changes in the height of the paper, and only allows for a single pressure to be applied. apart from ball-point pens and thin tipped markers, all drawing implements can produce lines with varying weights depending on the pressure applied. In my measurements, a standard #2 graphite pencil can produce lines from light to dark, which range from 20 grams of force up to 300!

I would like to produce a control loop on the Z axis, which controls the height of the pen, to Produce a fixed, but programmable force on the workpiece. I could either:

  1. detect the position that provides the required force at the start of the operation, or
  2. monitor the force throughout and constantly adjust.

The latter would have a few benefits, as it would automatically account for variances in the flatness of the workpiece, deflections in the frame, and the fact that pencils wear down over time.

Implementation

A strain gauge in a Wheatstone bridge amplifier. From AllAboutCircuits

Strain Gauge is a resistive device that can detect very slight changes in force. it is typically made of a set of very small conductors of a material that changes in resistance when flexed. They are typically set up in a Wheatstone bridge configuration to get an increased response, and are actively amplified to get a signal that can be measured by an analog input. by mounting one of these to the printed stylus holder, I can measure the force applied to it.

Some initial testing  with a servo and a tiny BF350 Strain Gauge shows that there is a decent amount of noise in the system, which may make for some messy writing. I won’t know for sure until I build the hardware though (when will that be…). interpreting line weights from a drawing will be much more difficult, but that I am reserving for future development. for now, I just want to be able to detect the forces and adjust automatically.

Unattainable Stretch Goals:

  • Adjust the RP (Roll/Pitch) of the stylus to mimic different sketching styles. Some types of pencils produce different line weights when used at different angles. This would require some pretty complex inverse kinematics, which I think I could accomplish with a bit more time.
  • Convert artwork image to series of paths using computer vision. Again, totally doable, but perfecting this could take a long time.
  • Scanning in an image and replicating it. This would combine several of the previous goals, so I probably shouldn’t even start thinking about this until the others are working.

I think that this is a pretty solid plan, and that I’ll be able to get both of my main goals at least partially functional within the next month. But in order to do that, I need a working drawing machine…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s