Softlimits and scara kinematics

Moderators: TomKerekes, dynomotion

User avatar
TomKerekes
Posts: 2889
Joined: Mon Dec 04, 2017 1:49 am

Re: Softlimits and scara kinematics

Post by TomKerekes » Sun Dec 07, 2025 6:03 pm

Hi Dana,
After reading your reply I first moved the arms inline and along something close to an x axis. Then I set the postion of the end (47,0)
I'm not sure what you mean by "set". If you mean the 'Set' buttons in KMotionCNC that wouldn't be correct. Those set GCode offsets. The Kinematics operate on the absolute Machine coordinates of the system. Instead after setting the arms inline go to KMotion.exe Console Screen and issue ZeroN commands for both your axes where N is replaced by your axis numbers. 7 and 6? (Not sure why you aren't using 0 and 1, that would be more logical).

You should then be able to verify on the KMotion Axis Screen that the Destination on those axes are 0.

KMotion should then show a position or 47,0 if the Kinematics is working correctly.

I do worry that with both arms straight out that it is at a something like a singularity where there is near zero/infinite relation ship between the X position and arm angles. So it might be better to do something like rotate the 2nd arm CCW 90 degrees in KMotion using a Move6=XXX. KMotionCNC should then show 23.63,23.63. Be sure to remove any GCode offset you may have set (clear out everything in the Edit Fixtures Screen) or display Machine Coordinates.

One thing I realized is my shoulder joint is turning the reverse from what I think should be the positive direction, for coordinates as drawn. So for example, a moveRel7=5000 from the console moves in what would be the clockwise direction, looking down on the robot, or towards the x axis. I think I just need to flip the direction in the channel setup? I'm guessing it is straight forward, but I'm missing it.
Change the sign of the OutputGain for the Axis.

I did try setting the count/deg in the trajectory planner to negative but I don't think that was right. And, oddly, now that I changed x and y ( I mistakenly changed y) I can't seem to set them back? I tried removing the minus, but they seem to persist after choosing "OK" and also after a restart.
That's a silly bug we've been struggling to get rid of. Once the values are set negative they can't be changed from the GUI. If you exit KMotionCNC and manually edit the file \KMotion\Data\GCodeConfigCNC.txt CountsPerInch parameters to a positive number then the GUI should allow you to change them.

On top of all this, I did not do anything with the "jerk" in the step response screen, I left the default. Not sure important this for what is, if I' sayin git right, effectively an open loop system, form Kmotion's perspective?
Regarding KMotion Vel, Accel, and Jerk you should test in the KMotion | Step Response Screen by performing Moves. The Jerk of 4e6 should be fine which is essentially infinity (pure acceleration limited). The Acceleration seems a bit slow. With a value equal to Velocity means that it will take 1 second to accelerate to full velocity. So you will need to test a move like 3 seconds long to see full velocity. Plot Velocity to observe what velocity you are actually testing.

I was going to clarify that I was mostly blindly using the scara kinematics files included (KMotion5.4.1\GCodeInterpreter\KinematicsScara.cpp) with kmotion, with the one change of making the arm lengths match my machine. I opened it to take a closer look, and now I think I am maybe treating 0,0 wrong. I think this line offsets the machine base to right (x pos) of 0,0 by the length of the arms.
Do the test described above (arms at 0 and 90 degrees) to verify the Kinematics are working correctly. as well as some other angles.

Also Set 'Rapids as Feeds' in the KMotionCNC | Trajectory Planner Screen as with non-linear systems like this rapids need to be treated the same as curved paths from a trajectory planning perspective.

HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

danabradbury
Posts: 8
Joined: Sat Nov 29, 2025 8:50 pm

Re: Softlimits and scara kinematics

Post by danabradbury » Sun Dec 07, 2025 8:46 pm

I'm making these changes now, thanks,
TomKerekes wrote:
Sun Dec 07, 2025 6:03 pm
That's a silly bug we've been struggling to get rid of. Once the values are set negative they can't be changed from the GUI. If you exit KMotionCNC and manually edit the file \KMotion\Data\GCodeConfigCNC.txt CountsPerInch parameters to a positive number then the GUI should allow you to change them.
Should I also change the value counts per values in the similar file GCodeConfig.txt?
Capture.JPG
Dana

User avatar
TomKerekes
Posts: 2889
Joined: Mon Dec 04, 2017 1:49 am

Re: Softlimits and scara kinematics

Post by TomKerekes » Sun Dec 07, 2025 10:05 pm

Its not necessary. That file is used by the GCode Screen in KMotion.exe which is obsolete and replaced by the KMotionCNC Program.
Regards,

Tom Kerekes
Dynomotion, Inc.

danabradbury
Posts: 8
Joined: Sat Nov 29, 2025 8:50 pm

Re: Softlimits and scara kinematics

Post by danabradbury » Sun Dec 07, 2025 11:44 pm

Tom,

I have made the changes you gave and run the test, moving the elbow to 90's (MoveRel6=252000 => 90deg). It mostly worked! Kmotion showed the position after deg 90 move as (7.874, 7.874). These are not my lengths, they are coming from the default scara file. But I think I'm very close. I think I have machine oriented correctly and can set the correct home, or zero spot.

I Went back through how I set my kinematics file and found I had a bug/typo in theCoordMotion.cpp file

else if (wcsstr(s, L"Geppetto") != NULL)
Kinematics = new CKinematicsGeppetto;
else if (wcsstr(s, L"Scara") != NULL)
Kinematics = new CKinematicsScara;
else if (wcsstr(s, L"DanasScara") != NULL)
Kinematics = new CKinematicsScara; // This should have been CKinematicsDanasScara
else if (wcsstr(s, L"Kinematics2AxisRobot") != NULL)
Kinematics = new CKinematics2AxisRobot;
else
Kinematics = new CKinematics3Rod;

Problem is when I I update the file I'm getting a type error. I'm clearly missing something from when copied and refactored the CKinematicsScara files, but I'm missing what?

Any quick solution?

Thanks,

Dana
Untitled.png

danabradbury
Posts: 8
Joined: Sat Nov 29, 2025 8:50 pm

Re: Softlimits and scara kinematics

Post by danabradbury » Sun Dec 07, 2025 11:59 pm

I added my header as in include in CoorMotion.cpp to resolve the error. I think this is probably not the right way? But I was clean able to clean and build all libs.

Problem now is KmotionCNC is still seeing the old file. So I guess one problem, I probably not building correctly? I did clean and build and think it built for release for win32.

I will go back through the docs on building.

Dana

// CoordMotion.cpp: implementation of the CCoordMotion class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CoordMotion.h"
#include "HiResTimer.h"
#include "KinematicsDanasScara.h" // <-- add this include

Capture.JPG

User avatar
TomKerekes
Posts: 2889
Joined: Mon Dec 04, 2017 1:49 am

Re: Softlimits and scara kinematics

Post by TomKerekes » Mon Dec 08, 2025 12:15 am

Including your .h file is the correct way to define the class.

The problem is that DanasScara contains the term Scara and it checks for Scara first and finds it. Reverse the order of the checks to check for the more specific case DanasScara first and it should select yours. We should probably do an exact match check instead of any match.
Regards,

Tom Kerekes
Dynomotion, Inc.

danabradbury
Posts: 8
Joined: Sat Nov 29, 2025 8:50 pm

Re: Softlimits and scara kinematics

Post by danabradbury » Mon Dec 08, 2025 3:37 pm

I moved my file up the list as you said, it's working! I can move from fully extended arm to 90deg at the elbow and KmotionCNC shows the correct 23.6, 23.6 position.

I then tried a simple gcode program that draws a 2" circle at 24,24 and then a cross through the circle. There is still something off, but I am so much closer than I was. The circle is an ellipse, and the cross id screwed, but the motion is very smooth and repeatable. I'll try some more basic moves to see what is off.



Lot left to do, but I feel like I'm over a big hurdle, thanks for all the help!

Dana

User avatar
TomKerekes
Posts: 2889
Joined: Mon Dec 04, 2017 1:49 am

Re: Softlimits and scara kinematics

Post by TomKerekes » Mon Dec 08, 2025 4:18 pm

Cool. From your 23.6,23.6 position you might move 1 inch to the right 24.7,23.6 and check the motor angles on the KMotion Axis Screen as well as measuring the physical movement to try to determine what’s wrong. Then do similar in Y.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply