Hacker News new | ask | show | jobs
by imp0cat 547 days ago
I am currently doing something similar for an off-the-shelf drawing robot with two arms, each with a shoulder and an elbow joint - load svg, convert layers to numpy arrays, then get the angle configuration for each point and save them to a format the robot can read and draw. However, I am finding that the time required to compute the points is quite long.

The fastest way I have right now is a large look-up table (ie. precompute angles for each point of a canvas with a sufficient precision, then use the table to do fast searches for the nearest point).

1 comments

That's odd, have you profiled it?
I took a look at the code that I started with and... it is kinda horrible.

https://github.com/AnykeyNL/Quincy/blob/master/coordcalc.py#...

There is a loop in a loop that goes through all the possible values of x and y to find the correct ones. No wonder it's so slow!

The scipy solver - inspired by the original article, I used https://docs.scipy.org/doc/scipy/reference/generated/scipy.o... - isn't much faster though (from reading the docs, it's just a smarter random search).

I guess it's time to learn some linear algebra (again!) and create a custom algorithm.

Did you try using the previous configuration as an initial guess to the numerical optimizer? If the next position is close to the previous one, the solver should be very quick.

Also, you can probably get much faster results if you obtain the gradient of the forward kinematics.

Thanks, much appreciated! I will try that.

I am trying multiple optimizations right now, mostly centered around reducing the amount of lookups required.