Struggling with custom kinematics...
- dave.franchino@gmail.com
- Offline
- New Member
- Posts: 14
- Thank you received: 5
LinuxCNC newby here - please be gentle... I'm clearly over my head here...
I am trying to learn to use LinuxCNC to run a 2-axis cable robot - each joint features a "drum" of known diameter. The cables from two drums truncate at a single point.
Eventually I hope to turn this into a low-cost hot-wire foam cutter that would allow you to use G-code to cut out shapes from large sheets of foam. Here is my crude prototype (not working in cartesian coordinates yet).
photos.app.goo.gl/z3gUimXLRd3yP33W6
I have my mechanism up and running using "trivial" kinematics and if I simply hang a weight from the left drum (mapped to the X axis in trivial kinematics) and instruct it to move 10mm, the drum will indeed wrap up enough cable to move the weight up 10mm - so I believe I have correctly computed the parameters to account for the various gear reductions, drum diameter, etc.
So my understanding is that I need to use a custom kinematics file to provide the kinematics / math needed to translate from the desired cartesian coordinates to the resulting joint rotations. The math is a bit complicated because the cables wrap around the drum and I need to account for both the length of the tangent line as well as the part of the cable wrapped around the drum.
Never the less - I believe I have correctly ascertained the math necessary to compute the left and right drum rotation (from home position of 0,0) to achieve a desired X,Y location for the truncation of the two cables. I believe these are inverse kinematics, correct?
Beyond this, I understand LinuxCNC is looking for the "Forward" kinematics - (given a left and right cable length, what is the resulting X,Y location. This math is a bit more complicated and required numerical methods (Newton Raphison - basically "guess and check").
I believe I have "solve" both forward and inverse kinematics conceptually - I have verified that my math is basically working - I wrote a simple program using Processing and I can feed in a desired X,Y location and my Processing program will correctly spit back the change in cable length from home of 0,0. Likewise, I have confirmed that my Forward kinematics seem to be working - I can input the change in cable lengths (from home) and my processing program will output the resulting X,Y.
My custom kinematics (attached) will compile but It's not working yet but I have some conceptual blocks that I could use some assistance on that might help me debug.
the man file states: 3) If required, add hal pins following examples in
the template code
I honestly don't really understand what a hal pin is and whether these are required. I'm running my code on a Raspberry pi if it matters.
I don't really understand why LinuxCNC requires Forward kinematics (even though I think I've solved them). I will be feeding this program G-Code with desired cartesian coordinates and relying on LinuxCNC and my kinematics to resolve these to the desired drum rotations (Inverse kinematics, right?). I don't have any feedback in my device so what does LinuxCNC do with the Forward kinematics?
My inverse kinematics routine computes the drum rotations FROM HOME to a desired X,Y. Is this correct?
I'm not sure how all of this works with "homing" With a conventional CNC I understand you would use limit switches to "home" each of the axis but I don't really have that option since there is no physical "home" for either drum (both of which turn multiple turns). My general approach was going to be to manually "drive" the two drums to the known 0,0 and then manually "home" . Is this viable? Any advice?
My CableKins.comp file is attached. I'm basically breaking out of the forward kinematics since that was erroring out but I'm not getting expected results. If you see any glaring issues I'd appreciate any guidance.
Thanks for any nudges in the right direction!
Please Log in or Create an account to join the conversation.
correctNever the less - I believe I have correctly ascertained the math necessary to compute the left and right drum rotation (from home position of 0,0) to achieve a desired X,Y location for the truncation of the two cables. I believe these are inverse kinematics, correct?
hal pins are used to connect signals in the hal layer. If your kinematic does do not need real time information from hal (eg tool length) then you do not need to add any pins.I honestly don't really understand what a hal pin is and whether these are required. I'm running my code on a Raspberry pi if it matters.
I believe in your case the forward kinematic is only used until the machine is homed. (ie to calculate the initial XY position) But I might be wrong about that.I don't have any feedback in my device so what does LinuxCNC do with the Forward kinematics?
Note: Looks like it is possible to also run either inverse / forward kinematics only (but I have never used that or seen it used):
linuxcnc.org/docs/devel/html/motion/kine...rward-transformation
KINEMATICS_IDENTITY (each joint number corresponds to an axis letter)
KINEMATICS_BOTH (forward and inverse kinematics functions are provided)
KINEMATICS_FORWARD_ONLY
KINEMATICS_INVERSE_ONLY
That is correct, for HOME = (0,0) and provided you have not built any offsets into your model (eg a tool-offset)My inverse kinematics routine computes the drum rotations FROM HOME to a desired X,Y. Is this correct?
So what is the error you are getting?My CableKins.comp file is attached. I'm basically breaking out of the forward kinematics since that was erroring out but I'm not getting expected results. If you see any glaring issues I'd appreciate any guidance.
Please Log in or Create an account to join the conversation.
- dave.franchino@gmail.com
- Offline
- New Member
- Posts: 14
- Thank you received: 5
I am running in simulation mode - no hardware is connected or moving
When I launch LinuxCNC, the GUI only lists Joint0 and Joint[1] - not X and Y (1st image)
When I "home" the machine, X and Y appear on the GUI however the position of the unit jumps to x1.106, y1.895 (image 2)
At the same time, the forward kinematics are executing and coverging, but not exactly where I expected them (very close though)
Am then getting a "Joint Following Error" and the inverse kinematics are executing but returning zeros for every calculation.
My cablekins.comp file is attached.
Any ideas?
Please Log in or Create an account to join the conversation.
Note how the Joint1 position has run away after homing:
I'm not really familiar with using Jacobian matrices but I would have expected the forward kinematics to use the jacobian matrix and then invert that to derive the inverse kinematics. You seem to use the jacobian for the forward kinematics only.
Attachments:
Please Log in or Create an account to join the conversation.
- dave.franchino@gmail.com
- Offline
- New Member
- Posts: 14
- Thank you received: 5
Is it a correct assumption that the forward transformation is only called when homing the machine - and beyond that is not referenced? In my case, with the cable robot it is not possible to add "home" switches to each of the joints so my current strategy is to manually drive the unit to 0,0 and then home manually.
I'm still confused on how LinuxCNC uses the forward and inverse. I will look for an explaination on why the forward transformation and inverse are yielding different values.
Thanks for your input!!
Please Log in or Create an account to join the conversation.
That is what I _think_ is happening but I'm not positive. If you home your machine manually I wonder if you could simply set the cartesian position to zero in your forward kinematics:Is it a correct assumption that the forward transformation is only called when homing the machine - and beyond that is not referenced?
pos->tran.x = 0;
pos->tran.y = 0;
As long as you have no OFFSET or HOME_OFFSET values set in the [JOINT_n] section of your ini file then that should give you a cartesian coordinate of X0/Y0 for joint0.pos_fb = 0/ oint_1.pos_fb = 0. But again I'm really not sure as to what actually happens behind the scenes which I think is here:
github.com/LinuxCNC/linuxcnc/blob/master...emc/motion/control.c
Please Log in or Create an account to join the conversation.
1. before homing the controller is in 'joint' mode and axes (eg X,Y,Z,...) do not exist
2. a successful homing procedure ends with the joints being in a known position (ie each joint position is either zero or offset by the OFFSET or HOME_OFFSET values set in the [JOINT_n] section of your ini file or has a known position from an absolute encoder)
3. these joint position values are then passed to the Forward kinematic model which calculates the initial values for the axes position.
4. Axes are created as setup in the ini file (eg X, Y, Z) and are initialized with the values calculated in step 3
5. The trajectory planner calculates the axis positions and passes them on to the Inverse kinematic model which calculates the joint position values to be passed on to the motor drives (eg by way of step generators, ethercat command, analog voltage, etc).
Please Log in or Create an account to join the conversation.
- dave.franchino@gmail.com
- Offline
- New Member
- Posts: 14
- Thank you received: 5
For example, in the following cablekins.comp file I have defined:
const double LEFT_DRUM_X = -100.0;
const double LEFT_DRUM_Y = 250.0;
These are being used in the forward transformation and working properly. However in the inverse transformation i put in print statements:
debugPrint("Debug: LEFT_DRUM_X = %f, LEFT_DRUM_Y = %f\n", LEFT_DRUM_X , LEFT_DRUM_Y);
and the output is:
Debug: LEFT_DRUM_X = 0.000000, LEFT_DRUM_Y = 0.000000
Sorry my C sucks.. any idea why this is going on?
thanks!
Please Log in or Create an account to join the conversation.
- dave.franchino@gmail.com
- Offline
- New Member
- Posts: 14
- Thank you received: 5
Attachments:
Please Log in or Create an account to join the conversation.
rtapi_print(
instead of
debugPrint(
[edit]
with the above I get this output:
In kinematics inverse
Debug: x_target = 0.000598, y_target = 0.000315
Debug: LEFT_DRUM_X = -100.000000, LEFT_DRUM_Y = 250.000000
Debug: distance_left_drum_center_to_target = 269.258170, distance_right_drum_center_to_target = 471.698383
Debug: left_tangent_length_to_target = 263.433105, right_tangent_length_to_target = 468.397698
Debug: theta1_left = 0.380509, theta2_left = 0.208385, theta_left = 0.588894
Debug: theta1_right = -1.012197, theta2_right = 0.118369, theta_right = -0.893828
Debug: left_arc_length = 32.803895, right_arc_length = -49.789988
Debug: left_cable_length_to_target = 296.237000, right_cable_length_to_target = 418.607709
Debug: left_cable_length_change = 0.000000, right_cable_length_change = 112.767291
Debug: kinematicsInverse joints: j[0] = 0.000000, j[1] = 112.767291
Please Log in or Create an account to join the conversation.