Numerical simulation of halfway imaginary machines to generate instructions for real machines
Today I made a cut on my PocketNC 5-axis milling machine with gcode generated with the help of this inverse kinematics solver. I'd post a video of the cut if it wasn't boring. Literally boring. It was gcode to do finish passes on 1/8" diameter hole, with a ball nose endmill angled 5 degrees so that it was only cutting on the radius of the cutter, not the shank.
I'll have to do a more interesting cut.
I created a modelica model that looks at the distance between the tool target and the actual position. Whenever the error is within a configurable tolerance the model records the current position of the machine joints and calls some external python code that reads new tool target positions from a file.
I created tool targets using pythonocc. I created a sphere. I accessed the position and normal vector of the sphere's surface at a few points and wrote those to a csv file in x,y,z,i,j,k format where x,y, and z are the position of the tool tip and i,j, k makes up a unit vector pointing from the tool tip back along the cutting tool axis. This is what the target points look like:
Here are the some plots of the modelica model running with the above tool targets:
The next part of the project will be to format the inverse kinematics solution into g-code so that I can run it on my milling machine and then to work on some routines for generating tool paths for milling.
Today I put together a modelica model in using the multibody physics library from the standard modelica library to see if this idea about solving inverse kinematics with modelica will work.
The joints in the model match my pocketnc 5 axis milling machine. There's a damper on each joint and mass on each part of the machine. Springs connect the imaginary tool target position to the actual tool position. When the model is run, the tool moves toward the target position and eventually settles there.
Success! I've solved the inverse kinematics problem!... But only for one tool position.
The next step will be to make some custom modelica blocks to feed the model with a series of end effector target positions and to extract the joint positions.