Need a HELP on G-Code

13 Jan 2016 02:09 #68279 by SKH
Need a HELP on G-Code was created by SKH
Hi,
Currently I'm working on a 6 Axis robotic arm (I've attached some photos of my design below)& I'm having a little trouble while teaching the G-Code.
right now I'm able to record axis values to a text file,my problem is how to convert those axis values to G-Code.
Ive tried creating the G-code manually by typing those values to a example g code file,
then the robot moves in a awkward manner..
Q1) can i create the G-code from those X,Y,Z,A,B,C motor position values?How?
Q2) also how to move a imported G-code ,to the working space of the robot arm?

Attachments:

13 Jan 2016 07:43 #68288 by SKH
Replied by SKH on topic Need a HELP on G-Code
Guys we need Help....?????

13 Jan 2016 09:03 #68290 by ArcEye
Replied by ArcEye on topic Need a HELP on G-Code
Linuxcnc was only ever conceived of for use with cartesian machines, where axes and joints happen to be essentially the same.

People have used it for robotic arms, but it is not a shining success as the simulations show, if you can get them to work.

Before you get too much time invested in what may well be a cul-de-sac, why not use something that was intended for the job - ROS.

regards
The following user(s) said Thank You: SKH

13 Jan 2016 10:18 #68296 by SKH
Replied by SKH on topic Need a HELP on G-Code
Thank you for the comment Sir,
but we have gone so far to turn back,so is there any way to get the X,Y,Z Cartesian coordinates at a particular instant of the robot?

13 Jan 2016 10:37 #68297 by andypugh
Replied by andypugh on topic Need a HELP on G-Code

SKH wrote: but we have gone so far to turn back,so is there any way to get the X,Y,Z Cartesian coordinates at a particular instant of the robot?

What kinematics are you using?

Or are you using trivkins?

As a first step, switch to using the Joints-Axes branch of LinuxCNC where a lot of recent work has taken place to make running non-cartesian machines work better.

It is probably best to build this from source, though there may be ways to get it from the Buildbot as a binary package (buildbot.linuxcnc.org)
The following user(s) said Thank You: SKH

13 Jan 2016 10:49 #68298 by andypugh
Replied by andypugh on topic Need a HELP on G-Code
Incidentally, I note that you are using what look like BS1363 plugs, Are you in the UK or are your plugs just a remnant of our Empire?

13 Jan 2016 11:18 #68300 by SKH
Replied by SKH on topic Need a HELP on G-Code
Thank you andy..
lol.. Most of the Sri Lankan wall-sockets and plugs are just like that.

We re using genserkins.

which means can't we get the XYZ coordinates directly without building the source??

13 Jan 2016 11:30 #68301 by andypugh
Replied by andypugh on topic Need a HELP on G-Code

SKH wrote: sing genserkins.
which means can't we get the XYZ coordinates directly without building the source??

OK, genserkins is a good start.
Genserkins and Joints_axes is probably a better combination, and is something you should consider, but is not 100% necessary.

Are the XYZABC coordinates on the screen correct? Is the problem that your logging process it capturing joint positions and not cartesian positions?

What is the teach process you are using?
The following user(s) said Thank You: SKH

13 Jan 2016 11:36 #68302 by ArcEye
Replied by ArcEye on topic Need a HELP on G-Code
Cartesian - Joints problems aside, have a look at teach-in.py

It is in src/emc/usr_intf/axis/scripts in the sources, but I don't know where it is or if it is installed in a distro.
```#!/usr/bin/python
"""Usage:
python teach.py nmlfile outputfile
If outputfile is not specified, writes to standard output.

You must ". scripts/rip-environment" before running this script, if you use
run-in-place.
"""
#    Copyright 2007 Jeff Epler <jepler@unpythonic.net>
#
#    This program is free software; you can redistribute it and/or modify
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import linuxcnc
import Tkinter
import sys

linenumber = 1;

if len(sys.argv) > 1:
linuxcnc.nmlfile = sys.argv[1]

if len(sys.argv) > 2:
outfile = sys.argv[2]
sys.stdout = open(outfile, 'w')

s = linuxcnc.stat()

def get_cart():
s.poll()
position = " ".join(["%-8.4f"] * s.axes)
return position % s.position[:s.axes]

def get_joint():
s.poll()
position = " ".join(["%-8.4f"] * s.axes)
return position % s.joint_actual_position[:s.axes]

def log():
global linenumber;
if world.get():
p = get_cart()
else:
p = get_joint()
label1.configure(text='Learned:  %s' % p)
print linenumber, p, s.flood, s.mist, s.lube, s.spindle_enabled;
linenumber += 1;

def show():
s.poll()
if world.get():
p = get_cart()
else:
p = get_joint()
label2.configure(text='Position: %s' % p)
app.after(100, show)

app = Tkinter.Tk(); app.wm_title('LinuxCNC Teach-In')

world = Tkinter.IntVar(app)

button = Tkinter.Button(app, command=log, text='Learn', font=("helvetica", 14))
button.pack(side='left')

label2 = Tkinter.Label(app, width=60, font='fixed', anchor="w")
label2.pack(side='top')

label1 = Tkinter.Label(app, width=60, font='fixed', text="Learned:  (nothing yet)", anchor="w")
label1.pack(side='top')

r1 = Tkinter.Radiobutton(app, text="Joint", variable=world, value=0)
r1.pack(side='left')
r2 = Tkinter.Radiobutton(app, text="World", variable=world, value=1)
r2.pack(side='left')

show()
app.mainloop()```

Should give you a starting point.

I am also not sure what positions you are after, but AFAIK the motion planner works in cartesian planes even if the end result is different from the output that would produce.
The following user(s) said Thank You: SKH

14 Jan 2016 03:43 #68344 by SKH
Replied by SKH on topic Need a HELP on G-Code
We referred the modified version of teach-in.py given in the below link.

we are using the get_cart() function to save Cartesian coordinates.(Q1.Is this function doing that?)
here Ive attached a file ,that i saved from this method.

File Attachment:

File Name: pos_saved.txt
File Size:0 KB

As you can see there are 6 values saved each time.(Q2.why we are getting 6 values when i use get_cart(). it should be X,Y,Z only right?)
(Q3.can't we use joint values to make the g-code?)

also we haven't configure those DH parameters yet.(we taught it is not necessary since we are manually recording the coordinates other than running a direct G-code,) ( Q4.is it a must to configure DH parameters?)

right now we are able to Home the robot arm successfully.