My custom designed GUI

More
22 Jan 2018 04:38 #104828 by persei8
Replied by persei8 on topic My custom designed GUI
Well if you don't think it's worth your time and effort, I will certainly never make it work. It is however, valuable to me as a way to learn some python and it's role in gtk panels. I don't see a specific place to post python questions so I hope I can pose it here.

Here is a snippet from the main python module:
self.lc = self.linuxcnc.command()
--- then a whole bunch of stuff ----
def jog_x_plus_press(self, widget, event):
if self.check_machine_state() == 'STATE_ON':
# self.lc.jog(self.linuxcnc.JOG_CONTINUOUS, 0, 0, float(self.x_jog)) <-- doesn't work
axis_num = 0
self.lc.jog(self.linuxcnc.JOG_CONTINUOUS, 0, axis_num, float('{}{}'.format('+', self.x_jog)))

I consistently get this from the terminal:

<type 'tuple'>
(11, 'JOG_CONT command.com !teleop bad joint_num cmd=47\n')
JOG_CONT command.com !teleop bad joint_num cmd=47

I modified the jog command statement to reflect the way it is done in hazzy, but I must be doing something wrong, but can't figure what. Any ideas?

Please Log in or Create an account to join the conversation.

More
22 Jan 2018 06:20 - 22 Jan 2018 06:21 #104832 by KCJ
Replied by KCJ on topic My custom designed GUI
My very first encounter with python (and programing in general) was when I was trying to get CraftsmanCNC working. I had just learned about LinuxCNC, and, being a Mach fan (sigh), liked the familiar look of the UI. I had no previous experience with linux or coding so it was a steep learning curve, but boy was it worth it. So, by all means, study and hack on CraftsmanCNC, you will learn a lot!

First off, CraftsmamCNC will not work with 2.8~pre without significant modification. Hazzy on the other hand only works with 2.8~pre, so much of the code will not be directly comparable between the two. It looks like you are using 2.8~pre because `teleop` is mentioned in the error log.

Here is a comparison of the jog commands in 2.7 and 2.8:

2.7
cmd.jog(linuxcnc.JOG_CONTINUOUS, axis-num, jog-velocity)

2.8~pre
cmd.jog(linuxcnc.JOG_CONTINUOUS, joint-jog, axis-or-joint-number, jog-velocity)
were `joint-jog` is true for joint jog, or false for axis jog.

The error complains about a `bad joint_num cmd=47`, so what I think is happening it that you are somehow passing the jog-velocity (47) as the joint-number. Check that the format of the jog commands is correct.

Hope that helps,
Kurt
Last edit: 22 Jan 2018 06:21 by KCJ.

Please Log in or Create an account to join the conversation.

More
26 Apr 2018 23:50 #109692 by tripwire
Was there ever a solution to this? I'm running 2.8~pre and am getting the same error with the following:
self.c.jog(self.cnc.JOG_CONTINUOUS,0, 0, 60.0)

Please Log in or Create an account to join the conversation.

More
27 Apr 2018 15:27 #109721 by KCJ
If you are running 2.8~pre that is correct and should not give any errors. Are you certain you are running 2.8? As I mentioned previously, CraftsmamCNC would need a significant amount of modification to make it work with 2.8.

What I like to do to troubleshoot in this type of situation is run the commands in the python interpreter to isolate any problems.
LinuxCNC has to be running, but it does not matter what GUI.

Open a terminal and set up the environment
If you have LCNC 2.8 installed system wide than you can open a terminal anywhere.
If you have 2.8~pre installed as a RIP (Run In Place), then open a terminal in the RIP dir and set up the environment by running
. ./scripts/rip-environment

Run the commands in question
kurt@T510:~/dev/cnc/linuxcnc$ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import linuxcnc
>>> c = linuxcnc.command()
>>> c.jog(linuxcnc.JOG_CONTINUOUS, 0, 0, 60.0)
>>> 

If you watch the gremlin back-plot in axis you will see that the tool moves and there are no error messages.

Cheers,
Kurt

Please Log in or Create an account to join the conversation.

More
27 Apr 2018 20:50 #109731 by tripwire
Thanks Kurt! Another user, dgarrett, provided the following solution:

>>
The message (`bad joint_num cmd=47) is poor but it means you have attempted to jog an
axis coordinate but are not in the *required* teleop mode.

In the master branch (2.8~pre) axis coordinates and joint numbers
must be handled properly for the current teleop mode.

In many situations, joint jogging is never required as one
homes the machine and all subsequent axis coordinate jogs
can be done in teleop mode.

The python interface provides:
teleop_enable()
to set/unset teleop mode.
Ref: linuxcnc.org/docs/master/html/config/python-interface.html

Commit to improve message:
github.com/LinuxCNC/linuxcnc/commit/8259...dc46e30136c6979c8e25

Note:
Some guis (notably axis) hide the distinctions of joints and
axis coordinates when using identity kinematics. When using
trivkins (identity kinematics), setting kinstype=Both can help
to clarify joint/axis coodinate usage.

For a demonstration using identity kinematics with multiple
joints assigned to a single axis coordinate (XYZY), run and
experiment with the simulation config:
Sample Configurations/sim/axis/gantry
<<
btw, I'm not the one running the CraftsmanCNC. I had just searched for "bad joint_num=47" and came upon this thread.

Thanks again for your reply! I'm sure I'll make use of your debugging suggestion.
The following user(s) said Thank You: KCJ

Please Log in or Create an account to join the conversation.

More
27 Apr 2018 23:44 #109738 by Grotius
Replied by Grotius on topic My custom designed GUI
Hi,

For 2.8 i have tested config : XXYZ today.
in python this works for double motors on X axis, Y axis is included to see difference in program code.
Joint 1 and 2 are x motors. they are moving together with one button command in the python code, this is tested in real life.
It was very confusing to make this correct, because documentation is very limited for custom gui design.
If you want to move joint 1, x motor 1, the code would be a little different :

x motor 1 : self.c.jog(linuxcnc.JOG_CONTINUOUS, 1, 0, (self.widgets.jog_speed.get_value()/60))

If you want to move joint 2, x motor 2, the code would be a little different :

x motor 2 : self.c.jog(linuxcnc.JOG_CONTINUOUS, 1, 1, (self.widgets.jog_speed.get_value()/60))

(the 1. is moving in joint's) 0, 1, 2 ....
(the 0 is for moving in x or y or z, cartasian way)
# ======================================================================= 
  def on_x_plus_pressed(self, widget, data=None): 
    self.c.mode(self.cnc.MODE_MANUAL)
    self.c.wait_complete()  
    self.c.jog(linuxcnc.JOG_CONTINUOUS, 0, 0, (self.widgets.jog_speed.get_value()/60))
    print " x plus " 
 
  def on_x_plus_released(self, widget, data=None): 
    print " x stop "
    self.c.jog(linuxcnc.JOG_STOP, 0, 0)
    
  def on_x_min_pressed(self, widget, data=None): 
    self.c.mode(self.cnc.MODE_MANUAL)
    self.c.wait_complete()
    self.c.jog(linuxcnc.JOG_CONTINUOUS, 0, 0, -(self.widgets.jog_speed.get_value()/60))
    print " x min " 
 
  def on_x_min_released(self, widget, data=None): 
    self.c.jog(linuxcnc.JOG_STOP, 0, 0)
    print " x stop "
# =======================================================================    
  def on_y_plus_pressed(self, widget, data=None): 
    self.c.mode(self.cnc.MODE_MANUAL)
    self.c.wait_complete() 
    self.c.jog(linuxcnc.JOG_CONTINUOUS, 0, 1, (self.widgets.jog_speed.get_value()/60))
    print " y plus "
       
  def on_y_plus_released(self, widget, data=None): 
    self.c.jog(linuxcnc.JOG_STOP, 0, 1)
    print " y stop "
    
  def on_y_min_pressed(self, widget, data=None): 
    self.c.mode(self.cnc.MODE_MANUAL)
    self.c.wait_complete() 
    self.c.jog(linuxcnc.JOG_CONTINUOUS, 0, 1, -(self.widgets.jog_speed.get_value()/60))
    print " y min "  
    
  def on_y_min_released(self, widget, data=None): 
    self.c.jog(linuxcnc.JOG_STOP, 0, 1)
    print " y stop "
# =======================================================================
The following user(s) said Thank You: KCJ, tripwire

Please Log in or Create an account to join the conversation.

More
28 Apr 2018 00:38 #109740 by tripwire
Replied by tripwire on topic My custom designed GUI
Thanks so much for your work on this, Grotius! I'll check it out and report back...

Please Log in or Create an account to join the conversation.

More
28 Apr 2018 00:58 #109741 by KCJ
Replied by KCJ on topic My custom designed GUI
tripwire: Thanks for posting Dewey's, as always, excellent explanation! It had not even crossed my mind that the error was caused by not being in teleoperating mode. That explains why I was having trouble duplicating it, as the first thing I do when I start LCNC is home and switch to coord or teleop mode. I should have mentioned that in my previous post, but I do it so automatically that I don't even think about it!

Grotius: Thank you for taking the time to prepare and post such a complete code snip, it is very helpful!

Cheers,
Kurt

Please Log in or Create an account to join the conversation.

More
28 Apr 2018 11:51 #109757 by Grotius
Replied by Grotius on topic My custom designed GUI
Hi,

Okey i forgot one thing. In the past i had problem's with multiple homing commands.
Now for homing all axis with one button this works also multiple homing commands good :
self.c.mode(self.cnc.MODE_MANUAL)
       self.c.wait_complete()

       # 1:teleop, 0: joint
       self.c.teleop_enable(0)
       self.c.wait_complete()

       self.c.home(0) 
       self.c.wait_complete()
       self.c.home(2) 
       self.c.wait_complete()
       self.c.home(3) 
       self.c.wait_complete()
       self.c.home(4) 
       self.c.wait_complete()
       print " home all "

Good luck !

A ini file example for double motors on x axis :
[TRAJ]
AXES = 5
COORDINATES = X X Y Z A
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 2.50
MAX_LINEAR_VELOCITY = 25.00

[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl

[KINS]
KINEMATICS = trivkins coordinates=XXYZA 
#kinstype=BOTH
JOINTS = 5

#######################################################
[AXIS_X]
MIN_LIMIT = -10.0
MAX_LIMIT = 6025.0
MAX_VELOCITY = 125.0
MAX_ACCELERATION = 125.0

## Calculation ##
# drive : 10000 steps / rev
# pitch : 37.69    mm    / rev
# calcutation : 10000 / 37.69 = 265.3 
# scale = 265.3

[JOINT_0]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 125
MAX_ACCELERATION = 125
STEPGEN_MAXACCEL = 750
SCALE = 265.3
FERROR = 1
MIN_FERROR = .25
MIN_LIMIT = -10
MAX_LIMIT = 6025
HOME_LATCH_VEL = -1
HOME_SEARCH_VEL = -20
HOME_FINAL_VEL = -1
HOME_IGNORE_LIMITS = YES
HOME_OFFSET = -2
HOME_SEQUENCE = -2

[JOINT_1]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 125
MAX_ACCELERATION = 125
STEPGEN_MAXACCEL = 750
SCALE = 265.3
FERROR = 1
MIN_FERROR = .25
MIN_LIMIT = -10.0
MAX_LIMIT = 6025
HOME_LATCH_VEL = -1
HOME_SEARCH_VEL = -20
HOME_FINAL_VEL = -1
HOME_IGNORE_LIMITS = YES
HOME_OFFSET = -2
HOME_SEQUENCE = -2

#######################################################

A hal file example for double x motors and also the limit switches.
net both-home-x1     <= parport.0.pin-10-in-not
net both-home-x2     <= parport.0.pin-15-in-not

#net spindle-cw      => parport.0.pin-17-out

# X-AXIS #######################################################
setp stepgen.0.position-scale [JOINT_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
setp stepgen.0.dirhold 35000
setp stepgen.0.dirsetup 35000
setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
net x1pos-cmd joint.0.motor-pos-cmd => stepgen.0.position-cmd
net x1pos-fb stepgen.0.position-fb => joint.0.motor-pos-fb
net x1step <= stepgen.0.step
net x1dir <= stepgen.0.dir
net x1enable joint.0.amp-enable-out => stepgen.0.enable
net both-home-x1 => joint.0.home-sw-in
net both-home-x1 => joint.0.neg-lim-sw-in
net both-home-x1 => joint.0.pos-lim-sw-in

setp stepgen.1.position-scale [JOINT_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 35000
setp stepgen.1.dirsetup 35000
setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
net x2pos-cmd joint.1.motor-pos-cmd => stepgen.1.position-cmd
net x2pos-fb stepgen.1.position-fb => joint.1.motor-pos-fb
net x2step <= stepgen.1.step
net x2dir <= stepgen.1.dir
net x2enable joint.1.amp-enable-out => stepgen.1.enable
net both-home-x2 => joint.1.home-sw-in
net both-home-x2 => joint.1.neg-lim-sw-in
net both-home-x2 => joint.1.pos-lim-sw-in
The following user(s) said Thank You: tripwire

Please Log in or Create an account to join the conversation.

More
28 Apr 2018 12:36 #109758 by KCJ
Replied by KCJ on topic My custom designed GUI
Grotius, if the home sequences are specified in the INI then self.c.home(-1) should home all in the home sequence specified. It is not advisable to hard code the home sequence.

Cheers,
Kurt

Please Log in or Create an account to join the conversation.

Time to create page: 0.116 seconds
Powered by Kunena Forum