Spray Robot
Moderators: TomKerekes, dynomotion
-
- Posts: 60
- Joined: Fri Apr 27, 2018 10:43 pm
Spray Robot
Greetings,
I am building a spray robot and dont want to use ballscrews inside the booth. The nonlinear kinematics package looks very promising. I have read the kinematics wiki page, but dont really understand and would like help walking through the problem. My motion is only on the X/Y axises, and I plan on using a 4 bar linkage hooked up to two stepper motors. I have attached an image.
You can see that combined motion between the two motors can move the tip of the linkage in the X and Y directions. My next step was to make an equation that given X and Y values, I can solve for the two motor angles.
1. What do I do with this equation?
2. How do I feed the equation into the interpreter so that KMotionCNC will move the two motors to make linear moves?
3. Has anyone done something similar?
Thanks!
Scott
I am building a spray robot and dont want to use ballscrews inside the booth. The nonlinear kinematics package looks very promising. I have read the kinematics wiki page, but dont really understand and would like help walking through the problem. My motion is only on the X/Y axises, and I plan on using a 4 bar linkage hooked up to two stepper motors. I have attached an image.
You can see that combined motion between the two motors can move the tip of the linkage in the X and Y directions. My next step was to make an equation that given X and Y values, I can solve for the two motor angles.
1. What do I do with this equation?
2. How do I feed the equation into the interpreter so that KMotionCNC will move the two motors to make linear moves?
3. Has anyone done something similar?
Thanks!
Scott
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Spray Robot
Hi Scott,
That looks interesting.
I think I see one solution:
#1 Given xy position and Motor 2 position point A (see diagram below) can be found by solving the intersection of 2 circles. The Kinematics class has a function to do this CKinematics::IntersectionTwoCircles
#2 Weighted average of point xy and point A can be used to determine point B
#3 Given point B and Motor 1 position point C can be found using the intersection of 2 circles.
#4 Compute Motor 1 angle from C
#5 Compute Motor 2 angle from A
That looks interesting.
I think I see one solution:
#1 Given xy position and Motor 2 position point A (see diagram below) can be found by solving the intersection of 2 circles. The Kinematics class has a function to do this CKinematics::IntersectionTwoCircles
#2 Weighted average of point xy and point A can be used to determine point B
#3 Given point B and Motor 1 position point C can be found using the intersection of 2 circles.
#4 Compute Motor 1 angle from C
#5 Compute Motor 2 angle from A
Create a new Kinematics Class with an appropriate name and change the TransformCADtoActuators function to perform the Transformation.1. What do I do with this equation?
As described above. See also the Kinematics in the wiki.2. How do I feed the equation into the interpreter so that KMotionCNC will move the two motors to make linear moves?
Not that I'm aware of.3. Has anyone done something similar?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 60
- Joined: Fri Apr 27, 2018 10:43 pm
Re: Spray Robot
Thanks Tom!
Well, I figured out all of the math to determine both motor angles based off of X/Y coordinates. I double checked it all with 2D CAD software. I am attaching the spreadsheet with math explained. Next step is to make the "Kinematics2AxisRobot.cpp".
I am struggling to understand the kinematics class examples. Just when I thought I understood how to set up a KFlop, I find that I am a novice again . Would the 3 rod example be the closest one for me to try to modify? I am not seeing how I would modify this to have the math for my robot.
I would really appreciate more nudging in the right direction. As always I am impressed with what the KFlop can do, just seeing that I am the weak link in making this project work.
Scott
Well, I figured out all of the math to determine both motor angles based off of X/Y coordinates. I double checked it all with 2D CAD software. I am attaching the spreadsheet with math explained. Next step is to make the "Kinematics2AxisRobot.cpp".
I am struggling to understand the kinematics class examples. Just when I thought I understood how to set up a KFlop, I find that I am a novice again . Would the 3 rod example be the closest one for me to try to modify? I am not seeing how I would modify this to have the math for my robot.
I would really appreciate more nudging in the right direction. As always I am impressed with what the KFlop can do, just seeing that I am the weak link in making this project work.
Scott
- Attachments
-
- Two Axis Robot.xlsx
- (53.74 KiB) Downloaded 322 times
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Spray Robot
Hi Scott,
The math looks reasonable to me. Although its sort of hard to read Excel formulas without comments. Good work. But I like my method better
Kinematics3Rod.cpp and Kinematics3Rod.h would be the simplest example to start with. Copy the files and first do global replace of "Kinematics3Rod" to "Kinematics2AxisRobot".
The code fragment that you show in your image is the "constructor" of the class. This code is executed once when the class object is created. So any initialization for the object should be performed there such as setting up the Linkage Geometry for your system. In your case L, R1, R2, R3, L, L1, and S any values that are constant or can be pre-calculated. You will need to define these variables in the .h header file as members of the object. Delete the stuff related to the 3Rod approach where the actuator positions were defined.
Next put your formulas into TransformCADtoActuators() to calculate Acts[0] and Acts[1] as a function of x y.
HTH
The math looks reasonable to me. Although its sort of hard to read Excel formulas without comments. Good work. But I like my method better
Kinematics3Rod.cpp and Kinematics3Rod.h would be the simplest example to start with. Copy the files and first do global replace of "Kinematics3Rod" to "Kinematics2AxisRobot".
The code fragment that you show in your image is the "constructor" of the class. This code is executed once when the class object is created. So any initialization for the object should be performed there such as setting up the Linkage Geometry for your system. In your case L, R1, R2, R3, L, L1, and S any values that are constant or can be pre-calculated. You will need to define these variables in the .h header file as members of the object. Delete the stuff related to the 3Rod approach where the actuator positions were defined.
Next put your formulas into TransformCADtoActuators() to calculate Acts[0] and Acts[1] as a function of x y.
HTH
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 60
- Joined: Fri Apr 27, 2018 10:43 pm
Re: Spray Robot
Well, I do have a pile of papers with hand calculations. I would be happy to document it better if you think anyone else would be interested in doing a similar project.
Ok, so working on my two files. Lets start with the Kinematics2AxisRobot.h. Looks like the main thing is to remove the Act3 variables we are not using, and then adding all of my variables to the transform functions. I am new to C++ and am not sure what "double *Acts, bool NoGeo = false);" means, so I left them in there.
Does it look like I got everything right? See attachment.
Ok, so working on my two files. Lets start with the Kinematics2AxisRobot.h. Looks like the main thing is to remove the Act3 variables we are not using, and then adding all of my variables to the transform functions. I am new to C++ and am not sure what "double *Acts, bool NoGeo = false);" means, so I left them in there.
Does it look like I got everything right? See attachment.
- Attachments
-
- Kinematics2AxisRobot.h
- (1.32 KiB) Downloaded 314 times
-
- Posts: 60
- Joined: Fri Apr 27, 2018 10:43 pm
Re: Spray Robot
I think I am starting to understand.. Here is my first attempt at the .cpp file. Seem like I got it right?
Thanks!
Scott
Thanks!
Scott
- Attachments
-
- Kinematics2AxisRobot.cpp
- (2.84 KiB) Downloaded 311 times
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Spray Robot
Hi Scott,
Regarding .h file: No. Leave the function parameters the way they were. Instead delete these member variables:
CPT3D Act0Center;
CPT3D Act1Center;
double Act0Off;
double Act1Off;
and replace them with the linkage geometry variables you need.
Regarding .cpp file: Restore the TransformCADtoActuators parameters back to what they were. Regardless of what the kinematics are we will always be converting the CAD variables (xyzabc) to Motor positions (Acts[] array).
Note that xyzabc are lower case.
Intermediate calculation variables such as H will need to be defined as doubles for the compiler within the TransformCADtoActuators function. The memory for those will be created when the function enters and discarded when the function exits. Unlike member variables defined in the .h file which live for the lifetime of the class object (lifetime of the program in this case)
Regarding .h file: No. Leave the function parameters the way they were. Instead delete these member variables:
CPT3D Act0Center;
CPT3D Act1Center;
double Act0Off;
double Act1Off;
and replace them with the linkage geometry variables you need.
Regarding .cpp file: Restore the TransformCADtoActuators parameters back to what they were. Regardless of what the kinematics are we will always be converting the CAD variables (xyzabc) to Motor positions (Acts[] array).
Note that xyzabc are lower case.
Intermediate calculation variables such as H will need to be defined as doubles for the compiler within the TransformCADtoActuators function. The memory for those will be created when the function enters and discarded when the function exits. Unlike member variables defined in the .h file which live for the lifetime of the class object (lifetime of the program in this case)
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Spray Robot
Also ^ is used for something else (exclusive OR) in C++. Instead use the sqr() function we defined for squaring.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 60
- Joined: Fri Apr 27, 2018 10:43 pm
Re: Spray Robot
Alright, I think we are getting close. If I understood correctly, I made all of the changes you suggested. Do these files look good?
If so, my next steps are to add "Kinematics2AxisRobot" into CordMotion.cpp like this the attached image?
Next, save a text file called "Kinematics.txt" with "Kinematics2AxisRobot" in the "KMotion\data" folder?
Once this is done, do I need to recompile anything? Or will opening KMotionCNC automatically load the correct code if I followed the above steps?
Thanks! Scott
If so, my next steps are to add "Kinematics2AxisRobot" into CordMotion.cpp like this the attached image?
Next, save a text file called "Kinematics.txt" with "Kinematics2AxisRobot" in the "KMotion\data" folder?
Once this is done, do I need to recompile anything? Or will opening KMotionCNC automatically load the correct code if I followed the above steps?
Thanks! Scott
- Attachments
-
- Kinematics2AxisRobot.cpp
- (2.55 KiB) Downloaded 319 times
-
- Kinematics2AxisRobot.h
- (1.02 KiB) Downloaded 317 times
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Spray Robot
Hi Scott,
It looks like you are mixing lower and upper case with x and y variables.
You will also need to include your new header file into CoordMotion.cpp so your new class is defined and can be used. This is described here.
Of course your two new files will need to be added to the GCodeInterpreter project like the rest of the Kinematics classes so your new code will be compiled and linked into the Library.
After you successfully build the libraries with your new code I'd also suggest you build/run KMotionCNC from Visual Studio in debug mode as well. This will allow you to set break points in your code, step through your equations, and view variables to debug any mistakes or issues. See here.
HTH
Almost. But regarding the Linkage variables. They must be defined in the header (.h file) but set to values in the constructor in the .cpp file not the header.Do these files look good?
It looks like you are mixing lower and upper case with x and y variables.
Close, you correctly check for a string match of "Kinematics2AxisRobot" but if there is a match a new CKinematicsGeppetto object is created to be used instead of a CKinematics2AxisRobot object.If so, my next steps are to add "Kinematics2AxisRobot" into CordMotion.cpp like this the attached image?
You will also need to include your new header file into CoordMotion.cpp so your new class is defined and can be used. This is described here.
Of course your two new files will need to be added to the GCodeInterpreter project like the rest of the Kinematics classes so your new code will be compiled and linked into the Library.
Yes you must re-build the KMotion Libraries. The Kinematics is part of the GCodeInterpreter DLL (Dynamically Linked Library). See here.Once this is done, do I need to recompile anything?
After you successfully build the libraries with your new code I'd also suggest you build/run KMotionCNC from Visual Studio in debug mode as well. This will allow you to set break points in your code, step through your equations, and view variables to debug any mistakes or issues. See here.
HTH
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.