Categories
sheffield

Seeking help: Drawing machines

Matt is making a drawing machine. A robot which will live on a wall and plot out paths which are an algorithmic solution to the artistic seeds that Matt feeds it. I’m helping Matt, but we’re stuck with a bit of the maths.

Due to artistic and practical constraints, this is how the robot will work: there will be two motors, top left and top right, from which a ‘pen’ is suspended. Our problem is about how to change the length of the chains from which the pen is suspended to draw a straight line between two points. I’ve done a diagram to make this easier to explain. The crudely drawn black circles are the two motors. There is a small blue circle (a start point), and the two chains in green (with lengths l1 and r1 respectively. The target endpoint is show as a red cross, with the chains shown in purple (with lengths l2 and r2 respectively (obviously there are only ever two chains, one right and one left, not four).

Calculating the length of the chains at the start and the end is fairly trivial. The problem is at what rate to turn the motors to lengthen or draw in the chains to get between the start and the end points drawing a straight line. For artistic reasons it is absolutely essential that the line drawn between two points is straight.

I had a go at solving this. You can have a look at this python code (incidentally, my first ever python script!). The problem is, my solution makes curved lines, like this (points along the path shown as blue dots)

The chains need to be tightened by some amount during travel to stop a curve being described, but I know enough maths to know that I don’t have a hope of solving this one. Can you help?

3 replies on “Seeking help: Drawing machines”

Ok, with a little nudging from @antoniahamilton i’ve realised the first basic error I’ve made. I can solve this in a brute force way by planning a very large number of small steps and then interpolating the motor turns required for the entire trajectory.

Still to account for are

a) accelerating and deceleration of the motors

b) compensating for any sag in the chains (is that they don’t behave as straight lines in reality).

Both of these are probably non-trivial

So, if you’d like to help by getting involved, get in touch!

Update: after posting this there was a great response on twitter (thanks for everyone who had suggestions and links). In particular some critical observations by @antoniahamilton nudged me into realising what I was doing wrong, so now I think I’ve solved it (answer: broke the path down into many small steps and calculated required changes to the line lengths for each step. The answer approximates a straight line. I still don’t know what the correct maths would be)

For a line-drawing algorithm, see:

https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm

For general computer graphics stuff, this book is the “bible” although it’s old:

http://www.amazon.com/dp/0201848406

As for controlling the motors, if they have discrete steps, it should be not too hard. You didn’t say if you were using Arduino, Raspberry Pi, or something else as a controller, but here’s a good source of parts:

https://www.sparkfun.com/

Lee

Leave a Reply

Your email address will not be published. Required fields are marked *