## Spray Robot

Moderators: TomKerekes, dynomotion

TomKerekes
Posts: 985
Joined: Mon Dec 04, 2017 1:49 am

### Re: Spray Robot

Hi Scott,

I think your Homing routine has the motors swapped. Motor1 (Axis 0) should be at 0 degrees. Motor2 (Axis 1) should be 90 degrees. So try changing the Home Program to result in that. Having the opposite probably results in an impossible pose.
Normally +X is to the right and +Y up. Your convention for X is backwards.

Also defining the XY origin to be at Motor 1 is not very logical. For the algorithm to solve for the XY position it needs some reasonable starting guess. It uses 0,0 as an initial guess. In your convention this would be at an impossible orientation. So I added an adjustment to have the XY origin be at the payload home position with:

Code: Select all

``````	// adjust xy to be zero at neutral home position
x = -x + L1 - S;
y += R3;
``````
I also added code to define Actuators 2-5 so the variables wouldn't be undefined

Code: Select all

``````	Acts[2] = z*m_MotionParams.CountsPerInchZ;
Acts[3] = a*m_MotionParams.CountsPerInchA;
Acts[4] = b*m_MotionParams.CountsPerInchB;
Acts[5] = c*m_MotionParams.CountsPerInchC;
``````
Regards,

Tom Kerekes
Dynomotion, Inc.

TomKerekes
Posts: 985
Joined: Mon Dec 04, 2017 1:49 am

### Re: Spray Robot

Here is the modified Kinematics file.
Attachments
Kinematics2AxisRobot.cpp
Regards,

Tom Kerekes
Dynomotion, Inc.

TomKerekes
Posts: 985
Joined: Mon Dec 04, 2017 1:49 am

### Re: Spray Robot

Oops: should have been L not L1

x = -x + L - S;
Attachments
Kinematics2AxisRobot.cpp
Regards,

Tom Kerekes
Dynomotion, Inc.

TomKerekes
Posts: 985
Joined: Mon Dec 04, 2017 1:49 am

### Re: Spray Robot

Regards,

Tom Kerekes
Dynomotion, Inc.

CNC_Machines
Posts: 58
Joined: Fri Apr 27, 2018 10:43 pm

### Re: Spray Robot

Tom,

This looks great, I am getting very close. I am trying to understand your code a bit better.

// adjust xy to be zero at neutral home position
x = -x + L - S;
y += R3;

I can see why we would need this the first time through, but doesnt forcing the X/Y variables every cycle mess up the actual position?

// find angles for each motor
GeoCorrect(x,y,z,&x,&y,&z);

This line is right underneath. What is this line of code doing?

Thanks,

Scott

CNC_Machines
Posts: 58
Joined: Fri Apr 27, 2018 10:43 pm

### Re: Spray Robot

Tom,

Spray booth is built, looking at making several more of these robots. As far as installing this software on multiple computers, I do the normal install with drivers, and then just replace folder with my library instead of the one that installs with KMotionCNC?

Thanks,

Scott

TomKerekes
Posts: 985
Joined: Mon Dec 04, 2017 1:49 am

### Re: Spray Robot

Oops sorry I though I alread replied to this...
I am trying to understand your code a bit better.

// adjust xy to be zero at neutral home position
x = -x + L - S;
y += R3;

I can see why we would need this the first time through, but doesnt forcing the X/Y variables every cycle mess up the actual position?
I'm not sure I understand the question, but when parameters are passed into a function, they are a copy of the caller's values, so they can be changed and not have any effect on the values outside the function. In C if you want to change a variable outside of a function then the address of that variable must be passed to the function. Then the function can modify the variable indirectly.

// find angles for each motor
GeoCorrect(x,y,z,&x,&y,&z);

This line is right underneath. What is this line of code doing?
This would perform any Geometric Correction as described here. You might find that useful. If the motor positions, link arm lengths, joint angles, etc etc are not mechanically perfect there may be some distortion/imperfection in the XY positions. A calibration using a table of measured positions could be used to correct this. Unfortunately this would need to be implemented in the reverse kinematics also which is somewhat complicated and not currently handled by your code. The normal method of doing the reverse kinematics numerically handles this automatically. I'm guessing the required accuracy of a paint sprayer is not extremely high so probably wont be needed. If a Geometric Correction table file is not specified the function does nothing.

As far as installing this software on multiple computers, I do the normal install with drivers, and then just replace folder with my library instead of the one that installs with KMotionCNC?
You should only need to copy the \KMotion\Release\GCodeInterpreter.dll file to the other computer as it contains the kinematics changes. You might also copy the \KMotion\Data directory to get all the same settings and the Kinematics.txt file that turns on your Kinematics

Waiting for Video
Regards,

Tom Kerekes
Dynomotion, Inc.

CNC_Machines
Posts: 58
Joined: Fri Apr 27, 2018 10:43 pm

### Re: Spray Robot

Machine is up and running! I modified the Kinematics program to keep the spray head parallel no as the robot moves in X/Y space. G Code is used to adjust spray angles.

Tom, I am trying attach an MP4 video and am not having any success.

TomKerekes
Posts: 985
Joined: Mon Dec 04, 2017 1:49 am

### Re: Spray Robot

Hi Scott,

We don't allow mp4 videos directly. How big is it? If you add/change the extension to .txt it should be possible to attach the file.