joints_axes9: joint jogging and axis gui updates

New for testing: configs/sim/axis/gentrivkins/xz*.ini

Summary:

 1) src/emc/nml_intf/
      names changed to reflect Joint jogging:
           was: sendJogIncr(),... is: sendJogJointIncr(),...
      for emcJogCont(),emcJogIncr(),emcJogStop(),emcJogAbs(),
      add jjogmode parameter to indicate jogging type:
          jjogmode == 1 ==> joint jogging
          jjogmode == 0 ==> axis (teleop) jogging
      (Note emcJogAbs() not updated (not used anywhere?)

 2) src/emc/task/
    src/emc/motion/
    support jjogmode parameter to distinguish joint/axis jogging
    ignore wheel jog for teleop

 3) src/emc/usr_intf/halui.cc
    clarify naming for support of joint jog modes
    rename sendJogInc(),... to sendJogJointIncr(),...
    use jjogmode to deterine joints jogging
    note: currently no pins are created nor support
          incorporated for axis (teleop) jogging

 4) src/emc/usr_intf/emclcd,emcrsh,emcsh,shcom,xemc,keystick
    names changed to reflect Joint jogging:
          was: sendJogIncr(),...  is:sendJogJointIncr()
    support jjogmode parameter to distinguish joint/axis joggint
            (not tested)

 3) axis gui: src/emc/usr_intf/axis/extensions/emcmodule.cc
      new constants linuxcnc.MAX_JOINTS,MAX_AXIS
      jog() new parameter jjogmode to distinguish joint/axis jogging

 4) axis gui: src/emc/usr_intf/axis/scripts/axis.py
      use linuxcnc.MAX_JOINTS and linuxcnc.MAX_AXIS
      derive trajcoodinates from s.axis_mask
      set axis.tcl globals from axis.py (::MAX_JOINTS, etc)
      joints_mode() now independent of kinematics_type
      for KINEMATICS_IDENTITY, force teleop for jogging (get_jog_mode())
      for KINEMATICS_IDENTITY, force teleop for touchoff also
      pass jjogmode parameter to jog()
      new functions: ja_from_rbutton(),all_homed(),go_home()
                     set_teleop(), get_jog_mode()
      new convenience functions get_states(),motion_modename(), etc.
      distinguish axes/joints naming several places
        for instance, current_axis (var for radiobuttons for axis/joint
        selection) is now named ja_rbutton
      use ini [TRAJ]COORDINATES for axis indices
      use parm 'no_joint_display' if KINEMATICS_IDENTITY for dro display
      new option [KINS]AUTO_TELEOP to set teleop after homing (with timelimit)
      change some names to clarify joints/axes
         home_all_axes()      --> home_all_joints()
         home_axis()          --> home_joint()
         home_axis_number()   --> home_joint_number()
         unhome_axis_number() --> unhome_joint_number()
         unhome_axis()        --> unhome_joint()
         unhome_all_axes()    --> unhome_all_joints()
         activate_axis()      --> activate_ja_widget()
         activate_axis_or_set_feedrate() -->
              activate_ja_widget_or_set_feedrate()
      different key binding for activate_ja_widget() for axes xyza
      use AXIS_A not AXIS_3 for a_axis_wrapped etc.
      use AXIS_%s not AXIS_%d for finding SCALE
      use linuxcnc.MAX_JOINTS not 9
      probably a few more ...

 5) axis gui: share/axis/tcl/axis.tcl
      rename varname for joints/axes selection radiobuttons (now ja_rbutton)
      for joints: ja_rbutton values are joint _numbers_
      for axes:   ja_rubtton_values are axis  _letters_
      consolidate radiobuttons and grid for joints & axes with for loops
      use constants set from axis.py (remove hardcoded items: STATE_ON,...)
      expand complex if tests to multiple lines for readability
      initialize ::ja_rbutton in joint_mode_switch{}

 6) lib/python/rs274/glcanon.py
     posstrs() add parm 'no_joint_display' for use with IDENTITY kins
     improve location of homeicon for lathe (based on 'Dia')

 7) new dir: configs/sim/axis/gentrivkins with example configs:
      xz.ini           KINEMATICS_IDENTITY
      xz_both.ini      KINEMATICS_BOTH
      xz_both_auto.ini KINEMATICS_BOTH with AUTO_TELEOP after homing
    (these configs use [DISPLAY]LATHE=1 for testing dro display)

 8) lib/hallib/sim_lib.tcl
      compute axis indices for kins used in sim examples (trivkins,gentrivkins)
      handle [KINS]KINEMATICS= with parameters

Notes:
  a) Not changed:
        Currently, only joint jogging available for:
        wheel jog pins (joint.N.jog*)
        halui jog pins (halui.jog.N*, halui.jog.selected.*,halui.jog-*)

  b) Potential problem/nuisance:
     Some kins may use/require coordinates=value
     (Example: loadrt gentrivkins coordinates=xz)
     The kins parameter:       coordinates=value
     must agree with:    [TRAJ]COORDINATES=value

Signed-off-by: Dewey Garrett <dgarrett@panix.com>
This commit is contained in:
Dewey Garrett 2015-11-10 12:16:40 -07:00 committed by Sebastian Kuzminsky
parent 2a6d43940b
commit fd985dba5f
27 changed files with 933 additions and 658 deletions

View file

@ -0,0 +1,21 @@
gentrivkins examples
xz.ini KINEMATICS_IDENTITY
xz_both.ini KINEMATICS_BOTH
xz_both_auto.ini KINEMATICS_BOTH
(auto switch to teleop after homing)
NOTE:
!!! [TRAJ]COORDINATES MUST AGREE WITH KINS:
!!! [TRAJ]COORDINATES = xz
xz.ini
[KINS]KINEMATICS=gentrivkins coordinates=xz
xz_both.ini
KINEMATICS = gentrivkins coordinates=xz kinstype=BOTH
xz_both_auto.ini
KINEMATICS = gentrivkins coordinates=xz kinstype=BOTH

View file

@ -0,0 +1,12 @@
#INCLUDE xzbase.inc
[EMC]
VERSION = 1.0
MACHINE = gentrivkins XZ KINEMATICS_IDENTITY
DEBUG = 0
[KINS]
# Note: coordinates must agree with [TRAJ]COORDINATES
# gentrivkins with no kinstype defaults to KINEMATICS_IDENTITY
KINEMATICS = gentrivkins coordinates=xz
JOINTS = 2

View file

@ -0,0 +1,2 @@
T1 P1 D0.100000 X-0.333000 Z+0.100000 ;
T2 P2 D0.200000 Z+0.200000 ;

View file

@ -0,0 +1,11 @@
#INCLUDE xzbase.inc
[EMC]
VERSION = 1.0
MACHINE = gentrivkins XZ KINEMATICS_BOTH
DEBUG = 0
[KINS]
# Note: coordinates must agree with [TRAJ]COORDINATES
KINEMATICS = gentrivkins coordinates=xz kinstype=BOTH
JOINTS = 2

View file

@ -0,0 +1,15 @@
#INCLUDE xzbase.inc
[EMC]
VERSION = 1.0
MACHINE = gentrivkins XZ KINEMATICS_BOTH,AUTO TELEOP
DEBUG = 0
[KINS]
# Note: coordinates must agree with [TRAJ]COORDINATES
KINEMATICS = gentrivkins coordinates=xz kinstype=BOTH
JOINTS = 2
# AUTO_TELEOP: switch to teleop after homing
# value is max time (seconds) allowed
# 0 value (or absence) disables
AUTO_TELEOP = 20

View file

@ -0,0 +1,112 @@
[HAL]
HALFILE = LIB:basic_sim.tcl
HALUI = halui
[TRAJ]
COORDINATES = XZ
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_VELOCITY = 1.0
DEFAULT_ACCELERATION = 20.0
MAX_VELOCITY = 4.44444
MAX_ACCELERATION = 22.2222
[DISPLAY]
DISPLAY = axis
LATHE = 1
EDITOR = gedit
TOOL_EDITOR = tooledit diam z
PROGRAM_PREFIX = ../../nc_files/
CYCLE_TIME = 0.100
HELP_FILE = doc/help.txt
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.2
MAX_SPINDLE_OVERRIDE = 1.0
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
[RS274NGC]
PARAMETER_FILE = xz.var
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
COMM_WAIT = 0.010
BASE_PERIOD = 50000
SERVO_PERIOD = 1000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = xz.tbl
TOOL_CHANGE_POSITION = 2 0 1
TOOL_CHANGE_WITH_SPINDLE_ON = 1
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 3.3
MAX_ACCELERATION = 20.3
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -10.0
MAX_LIMIT = 10.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_OFFSET = 1.0
HOME_SEARCH_VEL = 5.0
HOME_LATCH_VEL = 1.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
HOME_SEQUENCE = 0
HOME_IS_SHARED = 0
[JOINT_1]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 3.4
MAX_ACCELERATION = 20.4
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -2.0
MAX_LIMIT = 4.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_OFFSET = 1.0
HOME_SEARCH_VEL = 5.0
HOME_LATCH_VEL = 1.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
HOME_SEQUENCE = 1
HOME_IS_SHARED = 1
[AXIS_X]
HOME = 0.000
MIN_LIMIT = -10.1
MAX_LIMIT = 10.2
MAX_VELOCITY = 3.1
MAX_ACCELERATION = 20.1
[AXIS_Z]
HOME = 0.0
MIN_LIMIT = -2.1
MAX_LIMIT = 4.4
MAX_VELOCITY = 3.2
MAX_ACCELERATION = 20.2

View file

@ -9,8 +9,7 @@
#begin-----------------------------------------------------------------
source [file join $::env(HALLIB_DIR) sim_lib.tcl]
set axes [eval set axes $::TRAJ(COORDINATES)] ;# eval to handle list {}
set axes [string tolower $axes] ;# expect lowercase throughout
set axes [get_traj_coordinates]
set number_of_joints $::KINS(JOINTS)
set base_period 0 ;# 0 means no thread

View file

@ -1,12 +1,77 @@
# sim_lib.tcl: haltcl procs for sim configurations
#----------------------------------------------------------------------
# all globals are in one associative array ::SIM_LIB()
set letters {x y z a b c u v w}
foreach a {x y z a b c u v w} {
set ::SIM_LIB($a,idx) [lsearch $letters $a]
}
# Notes (Joints-Axes):
# 1) establish indices for common kins (trivkins, gentrivkins)
# 2) if ::KINS(KINEMATICS) exists:
# loadrt the kins using any included parameters
# example: for inifile item:
# [KINS]KINEMATICS = gentrivkins coordinates=XZ kinstype=BOTH
# use:
# loadrt gentrivkins coordinates=xz kinstype=BOTH
# else:
# loadrt trivkins
#
# 3) NB: If $::KINS(KINEMATICS) specifies coordinates=, the
# coordinats must agree with ::TRAJ(COORDINATES)
#
#----------------------------------------------------------------------
proc indices_for_trivkins { {axes {x y z a b c u v w} } } {
foreach a [string tolower $axes] {
set ::SIM_LIB(jointidx,$a) [lsearch {x y z a b c u v w} $a]
}
} ;# indices_for_trivkins
proc indices_for_gentrivkins {axes} {
# ref: src/emc/kinematics/gentrivkins.c
set i 0
foreach a [string tolower $axes] {
# assign to consecutive joints:
set ::SIM_LIB(jointidx,$a) $i
incr i
}
} ;# indices_for_gentrivkins
proc get_traj_coordinates {} {
# initraj.cc: coordinates may be with or without spaces X Z or XZ
# convert either form to list like {x z}
set coordinates [lindex $::TRAJ(COORDINATES) 0]
set coordinates [string map {" " "" "\t" ""} $coordinates]
set coordinates [split $coordinates ""]
return [string tolower $coordinates]
} ;# get_traj_coordinates
proc setup_kins {axes} {
if ![info exists ::KINS(KINEMATICS)] {
puts stderr "NO \[KINS\]KINEMATICS, trying trivkins"
indices_for_trivkins
eval loadrt trivkins
return
}
set ::KINS(KINEMATICS) [lindex $::KINS(KINEMATICS) end]
set cmd "loadrt $::KINS(KINEMATICS)" ;# may include parms
set kins [lindex $::KINS(KINEMATICS) 0] ;# just the kins
puts stderr "setup_kins: cmd=$cmd"
if [catch {eval $cmd} msg] {
puts stderr "msg=$msg"
# if fail, try without coordinates parameters
eval $cmd
}
# set up axis indices for known kins
switch $kins {
gentrivkins {indices_for_gentrivkins $axes}
trivkins {indices_for_trivkins $axes}
default {
puts stderr "setup_kins:UNKNOWN \[KINS\]KINEMATICS=<$::KINS(KINEMATICS)>,\
trying incices_for_trivkins"
indices_for_trivkins $axes
}
}
} ;# setup_kins
proc core_sim {axes
number_of_joints
servo_period
@ -15,14 +80,10 @@ proc core_sim {axes
} {
# adapted as haltcl proc from core_sim.hal
# note: with default emcmot==motmot,
# thread will not be added for (default) base_pariod == 9
if [info exists ::KINS(KINEMATICS)] {
loadrt $::KINS(KINEMATICS)
} else {
puts stderr "\n!!!core_sim: KINS(KINEMATICS) must be specified\n"
exit 1
}
# thread will not be added for (default) base_pariod == 0
setup_kins $axes
set lcmd "loadrt $emcmot"
set lcmd "$lcmd base_period_nsec=$base_period"
set lcmd "$lcmd servo_period_nsec=$servo_period"
set lcmd "$lcmd num_joints=$number_of_joints"
@ -73,7 +134,7 @@ proc core_sim {axes
net sample:enable <= motion.motion-enabled
foreach a $axes {
set idx $::SIM_LIB($a,idx)
set idx $::SIM_LIB(jointidx,$a)
net sample:enable => ${a}_mux.sel
net ${a}:enable <= joint.$idx.amp-enable-out
@ -163,7 +224,7 @@ proc simulated_home {axes} {
}
foreach a $axes {
set idx $::SIM_LIB($a,idx)
set idx $::SIM_LIB(jointidx,$a)
# add pin to pre-existing signal:
net ${a}:pos-fb => ${a}_switch.cur-pos
@ -226,3 +287,4 @@ proc sim_spindle {} {
addf near_speed servo-thread
addf sim_spindle servo-thread
} ;# sim_spindle

View file

@ -381,6 +381,7 @@ class GlCanonDraw:
self.select_buffer_size = 100
self.cached_tool = -1
self.initialised = 0
self.no_joint_display = False
def realize(self):
self.hershey = hershey.Hershey()
@ -1160,7 +1161,7 @@ class GlCanonDraw:
glPushMatrix()
glLoadIdentity()
limit, homed, posstrs, droposstrs = self.posstrs()
limit, homed, posstrs, droposstrs = self.posstrs(self.no_joint_display)
charwidth, linespace, base = self.get_font_info()
@ -1191,13 +1192,21 @@ class GlCanonDraw:
glRasterPos2i(5, ypos)
for char in string:
glCallList(base + ord(char))
if i < len(homed) and homed[i]:
glRasterPos2i(pixel_width + 8, ypos)
glBitmap(13, 16, 0, 3, 17, 0, homeicon)
if "Dia" in string:
# use line below
glRasterPos2i(pixel_width + 8, ypos - linespace)
glBitmap(13, 16, 0, 3, 17, 0, homeicon)
else:
glRasterPos2i(pixel_width + 8, ypos)
glBitmap(13, 16, 0, 3, 17, 0, homeicon)
if i < len(homed) and limit[i]:
glBitmap(13, 16, 0, 1, 17, 0, limiticon)
ypos -= linespace
i = i + 1
# FIXME needs work for joints_axes with show_offsets below
if self.get_show_offsets():
i=0
for string in droposstrs:
@ -1206,6 +1215,7 @@ class GlCanonDraw:
for char in string:
glCallList(base + ord(char))
if i < len(homed) and homed[i]:
print "((((W i=%d homed[i]=%d len(homed)=%d ls=%d s=%s"%(i,homed[i],len(homed),linespace,string)
glRasterPos2i(charwidth *3, ypos)
glBitmap(13, 16, 0, 3, 17, 0, homeicon)
ypos -= linespace
@ -1245,16 +1255,20 @@ class GlCanonDraw:
gluDeleteQuadric(q)
glEndList()
def posstrs(self):
def posstrs(self,no_joint_display=False):
s = self.stat
self.no_joint_display = no_joint_display
limit = list(s.limit[:])
homed = list(s.homed[:])
if self.is_lathe() and not s.axis_mask & 2:
if self.is_lathe() and (s.joints >= 3):
# hack to hide homeicon for dummy joint_1
# better to use gentrivkins with KINEMATICS_BOTH
# even gentrivkins with KINEMATICS_IDENTITY is better
homed[1] = 0
limit[1] = 0
if not self.get_joints_mode():
if not self.get_joints_mode() or self.no_joint_display:
if self.get_show_commanded():
positions = s.position
else:

View file

@ -809,280 +809,56 @@ setup_widget_accel $_tabs_manual.axis [_ Axis:]
frame $_tabs_manual.axes
radiobutton $_tabs_manual.axes.axisx \
# Axis select radiobuttons
# These set the variable ja_rbutton to alphabetic value
foreach {letter} {x y z a b c u v w} {
radiobutton $_tabs_manual.axes.axis$letter \
-anchor w \
-padx 0 \
-value x \
-variable current_axis \
-value $letter \
-variable ja_rbutton \
-width 2 \
-text X \
-text [string toupper $letter] \
-command axis_activated
}
radiobutton $_tabs_manual.axes.axisy \
-anchor w \
-padx 0 \
-value y \
-variable current_axis \
-width 2 \
-text Y \
-command axis_activated
radiobutton $_tabs_manual.axes.axisz \
-anchor w \
-padx 0 \
-value z \
-variable current_axis \
-width 2 \
-text Z \
-command axis_activated
radiobutton $_tabs_manual.axes.axisa \
-anchor w \
-padx 0 \
-value a \
-variable current_axis \
-width 2 \
-text A \
-command axis_activated
radiobutton $_tabs_manual.axes.axisb \
-anchor w \
-padx 0 \
-value b \
-variable current_axis \
-width 2 \
-text B \
-command axis_activated
radiobutton $_tabs_manual.axes.axisc \
-anchor w \
-padx 0 \
-value c \
-variable current_axis \
-width 2 \
-text C \
-command axis_activated
radiobutton $_tabs_manual.axes.axisu \
-anchor w \
-padx 0 \
-value u \
-variable current_axis \
-width 2 \
-text U \
-command axis_activated
radiobutton $_tabs_manual.axes.axisv \
-anchor w \
-padx 0 \
-value v \
-variable current_axis \
-width 2 \
-text V \
-command axis_activated
radiobutton $_tabs_manual.axes.axisw \
-anchor w \
-padx 0 \
-value w \
-variable current_axis \
-width 2 \
-text W \
-command axis_activated
# Grid widget $_tabs_manual.axes.axisa
grid $_tabs_manual.axes.axisu \
-column 0 \
-row 2 \
-padx 4
# Grid widget $_tabs_manual.axes.axisb
grid $_tabs_manual.axes.axisv \
-column 1 \
-row 2 \
-padx 4
# Grid widget $_tabs_manual.axes.axisc
grid $_tabs_manual.axes.axisw \
-column 2 \
-row 2 \
-padx 4
# Grid widget $_tabs_manual.axes.axisa
grid $_tabs_manual.axes.axisa \
-column 0 \
-row 1 \
-padx 4
# Grid widget $_tabs_manual.axes.axisb
grid $_tabs_manual.axes.axisb \
-column 1 \
-row 1 \
-padx 4
# Grid widget $_tabs_manual.axes.axisc
grid $_tabs_manual.axes.axisc \
-column 2 \
-row 1 \
-padx 4
# Grid widget $_tabs_manual.axes.axisx
grid $_tabs_manual.axes.axisx \
-column 0 \
-row 0 \
-padx 4
# Grid widget $_tabs_manual.axes.axisy
grid $_tabs_manual.axes.axisy \
-column 1 \
-row 0 \
-padx 4
# Grid widget $_tabs_manual.axes.axisz
grid $_tabs_manual.axes.axisz \
-column 2 \
-row 0 \
-padx 4
# grid for Axis select radiobuttons
set ano 0; set aletters {x y z a b c u v w}
for {set row 0} {$row < 3} {incr row} {
for {set col 0} {$col < 3} {incr col} {
grid $_tabs_manual.axes.axis[lindex $aletters $ano] \
-column $col -row $row -padx 4
incr ano
}
}
frame $_tabs_manual.joints
radiobutton $_tabs_manual.joints.joint0 \
# Joints select radiobuttons
# These set the variable ja_rbutton to numeric values [0,MAX_JOINTS)
for {set num 0} {$num < $::MAX_JOINTS} {incr num} {
radiobutton $_tabs_manual.joints.joint$num \
-anchor w \
-padx 0 \
-value x \
-variable current_axis \
-value $num \
-variable ja_rbutton \
-width 2 \
-text 0 \
-text $num \
-command axis_activated
}
radiobutton $_tabs_manual.joints.joint1 \
-anchor w \
-padx 0 \
-value y \
-variable current_axis \
-width 2 \
-text 1 \
-command axis_activated
radiobutton $_tabs_manual.joints.joint2 \
-anchor w \
-padx 0 \
-value z \
-variable current_axis \
-width 2 \
-text 2 \
-command axis_activated
radiobutton $_tabs_manual.joints.joint3 \
-anchor w \
-padx 0 \
-value a \
-variable current_axis \
-width 2 \
-text 3 \
-command axis_activated
radiobutton $_tabs_manual.joints.joint4 \
-anchor w \
-padx 0 \
-value b \
-variable current_axis \
-width 2 \
-text 4 \
-command axis_activated
radiobutton $_tabs_manual.joints.joint5 \
-anchor w \
-padx 0 \
-value c \
-variable current_axis \
-width 2 \
-text 5 \
-command axis_activated
radiobutton $_tabs_manual.joints.joint6 \
-anchor w \
-padx 0 \
-value u \
-variable current_axis \
-width 2 \
-text 6 \
-command axis_activated
radiobutton $_tabs_manual.joints.joint7 \
-anchor w \
-padx 0 \
-value v \
-variable current_axis \
-width 2 \
-text 7 \
-command axis_activated
radiobutton $_tabs_manual.joints.joint8 \
-anchor w \
-padx 0 \
-value w \
-variable current_axis \
-width 2 \
-text 8 \
-command axis_activated
# Grid widget $_tabs_manual.joints.joint0
grid $_tabs_manual.joints.joint0 \
-column 0 \
-row 0 \
-padx 4
# Grid widget $_tabs_manual.joints.joint1
grid $_tabs_manual.joints.joint1 \
-column 1 \
-row 0 \
-padx 4
# Grid widget $_tabs_manual.joints.joint2
grid $_tabs_manual.joints.joint2 \
-column 2 \
-row 0 \
-padx 4
# Grid widget $_tabs_manual.joints.joint3
grid $_tabs_manual.joints.joint3 \
-column 0 \
-row 1 \
-padx 4
# Grid widget $_tabs_manual.joints.joint4
grid $_tabs_manual.joints.joint4 \
-column 1 \
-row 1 \
-padx 4
# Grid widget $_tabs_manual.joints.joint5
grid $_tabs_manual.joints.joint5 \
-column 2 \
-row 1 \
-padx 4
# Grid widget $_tabs_manual.joints.joint6
grid $_tabs_manual.joints.joint6 \
-column 0 \
-row 2 \
-padx 4
# Grid widget $_tabs_manual.joints.joint7
grid $_tabs_manual.joints.joint7 \
-column 1 \
-row 2 \
-padx 4
# Grid widget $_tabs_manual.joints.joint8
grid $_tabs_manual.joints.joint8 \
-column 2 \
-row 2 \
-padx 4
# grid for Joint select radiobuttons
set jno 0
set rows [expr $::MAX_JOINTS / 3]
for {set row 0} {$row < 3} {incr row} {
for {set col 0} {$col < 3} {incr col} {
grid $_tabs_manual.joints.joint$jno \
-column $col -row $row -padx 4
incr jno
if {$jno >= $::MAX_JOINTS} break
}
if {$jno >= $::MAX_JOINTS} break
}
frame $_tabs_manual.jogf
frame $_tabs_manual.jogf.jog
@ -1123,7 +899,7 @@ $_tabs_manual.jogf.jog.jogincr list insert end [_ Continuous] 0.1000 0.0100 0.00
frame $_tabs_manual.jogf.zerohome
button $_tabs_manual.jogf.zerohome.home \
-command home_axis \
-command home_joint \
-padx 2m \
-pady 0
setup_widget_accel $_tabs_manual.jogf.zerohome.home [_ "Home Axis"]
@ -1929,23 +1705,6 @@ grid rowconfigure . 1 -weight 1
# vim:ts=8:sts=8:noet:sw=8
set TASK_MODE_MANUAL 1
set TASK_MODE_AUTO 2
set TASK_MODE_MDI 3
set STATE_ESTOP 1
set STATE_ESTOP_RESET 2
set STATE_OFF 3
set STATE_ON 4
set INTERP_IDLE 1
set INTERP_READING 2
set INTERP_PAUSED 3
set INTERP_WAITING 4
set TRAJ_MODE_FREE 1
set KINEMATICS_IDENTITY 1
set manualgroup [concat [winfo children $_tabs_manual.axes] \
$_tabs_manual.jogf.zerohome.home \
$_tabs_manual.jogf.jog.jogminus \
@ -2061,7 +1820,9 @@ proc update_state {args} {
$::_tabs_manual.spindlef.spindleminus \
$::_tabs_manual.spindlef.spindleplus
if {$::motion_mode == $::TRAJ_MODE_FREE && $::kinematics_type != $::KINEMATICS_IDENTITY} {
if { $::motion_mode == $::TRAJ_MODE_FREE
&& $::kinematics_type != $::KINEMATICS_IDENTITY
} {
set ::position [concat [_ "Position:"] Joint]
} else {
set coord_str [lindex [list [_ Machine] [_ Relative]] $::coord_type]
@ -2085,17 +1846,21 @@ proc update_state {args} {
disable_group $::mdigroup
}
if {$::task_state == $::STATE_ON && $::interp_state == $::INTERP_IDLE &&
($::motion_mode != $::TRAJ_MODE_FREE
|| $::kinematics_type == $::KINEMATICS_IDENTITY)} {
if { $::task_state == $::STATE_ON
&& $::interp_state == $::INTERP_IDLE
&& ( $::motion_mode != $::TRAJ_MODE_FREE
|| $::kinematics_type == $::KINEMATICS_IDENTITY
)} {
$::_tabs_manual.jogf.zerohome.zero configure -state normal
} else {
$::_tabs_manual.jogf.zerohome.zero configure -state disabled
}
if { $::task_state == $::STATE_ON
if { $::task_state == $::STATE_ON
&& $::interp_state == $::INTERP_IDLE
&& ($::motion_mode != $::TRAJ_MODE_FREE || $::kinematics_type == $::KINEMATICS_IDENTITY)
&& ( $::motion_mode != $::TRAJ_MODE_FREE
|| $::kinematics_type == $::KINEMATICS_IDENTITY
)
&& ("$::tool" != "" && "$::tool" != [_ "No tool"])
} {
$::_tabs_manual.jogf.zerohome.tooltouch configure -state normal
@ -2123,15 +1888,38 @@ proc set_mode_from_tab {} {
}
# trace var: motion_mode
proc joint_mode_switch {args} {
if {$::motion_mode == $::TRAJ_MODE_FREE && $::kinematics_type != $::KINEMATICS_IDENTITY} {
# note: test for existence of ::trajcoordinates because it is not avail first timeo
# todo: save and restore last value of ::ja_rbutton for joints,axes
if { $::motion_mode == $::TRAJ_MODE_FREE
&& $::kinematics_type != $::KINEMATICS_IDENTITY
} {
grid forget $::_tabs_manual.axes
grid $::_tabs_manual.joints -column 1 -row 0 -padx 0 -pady 0 -sticky w
setup_widget_accel $::_tabs_manual.axis [_ Joint:]
# Joints: need number for ja_rbutton
if {[info exists ::trajcoordinates]} {
# make first (leftmost) radiobutton active
for {set i 0} {$i < $::MAX_AXIS} {incr i} {lappend anums $i}
# typ anums is {0 ... 8}
if { [lsearch $anums $::ja_rbutton] < 0 } {
set ::ja_rbutton 0
}
}
} else {
grid forget $::_tabs_manual.joints
grid $::_tabs_manual.axes -column 1 -row 0 -padx 0 -pady 0 -sticky w
setup_widget_accel $::_tabs_manual.axis [_ Axis:]
# Axes: need letter for ja_rbutton
if {[info exists ::trajcoordinates]} {
# make first (leftmost) radiobutton active
for {set i 0} {$i < $::MAX_JOINTS} {incr i} {lappend jnums $i}
# typ jnums is {0 ... 8}
if { [lsearch $jnums $::ja_rbutton] >= 0 } {
set ::ja_rbutton [string range $::trajcoordinates 0 0]
}
}
}
}

View file

@ -227,8 +227,6 @@ STATIC int inRange(EmcPose pos, int id, char *move_type)
emcmot_joint_t *joint;
int in_range = 1;
/* First, make sure our endpoint is inside the world volume */
if(check_axis_constraint(pos.tran.x, id, move_type, 0, 'X') == 0)
in_range = 0;
if(check_axis_constraint(pos.tran.y, id, move_type, 1, 'Y') == 0)
@ -400,6 +398,10 @@ void emcmotCommandHandler(void *arg, long period)
double tmp1;
emcmot_comp_entry_t *comp_entry;
char issue_atspeed = 0;
int abort = 0;
check_stuff ( "before command_handler()" );
/* check for split read */
if (emcmotCommand->head != emcmotCommand->tail) {
emcmotDebug->split++;
@ -419,33 +421,54 @@ void emcmotCommandHandler(void *arg, long period)
/* ...and process command */
/* Many commands uses "command->joint" to indicate which joint they
wish to operate on. This code eliminates the need to copy
command->joint to "joint_num", limit check it, and then set "joint"
to point to the joint data. All the individual commands need to do
is verify that "joint" is non-zero. */
joint_num = emcmotCommand->joint;
if (joint_num >= 0 && joint_num < emcmotConfig->numJoints) {
/* valid joint, point to it's data */
joint = &joints[joint_num];
} else {
/* bad joint number */
joint = 0;
}
joint = 0;
axis = 0;
joint_num = emcmotCommand->joint;
axis_num = emcmotCommand->axis;
/* same for axes */
axis_num = emcmotCommand->axis;
if (axis_num >= 0 && axis_num < EMCMOT_MAX_AXIS) {
/* valid joint, point to it's data */
axis = &axes[axis_num];
} else {
/* bad axis number */
axis = 0;
}
//-----------------------------------------------------------------------------
// joints_axes test for unexpected conditions
// remove after branch stabilization:
if ( emcmotCommand->command == EMCMOT_JOG_CONT
|| emcmotCommand->command == EMCMOT_JOG_INCR
|| emcmotCommand->command == EMCMOT_JOG_ABS
|| emcmotCommand->command == EMCMOT_JOINT_ABORT
) {
if (GET_MOTION_TELEOP_FLAG() && axis_num < 0) {
rtapi_print_msg(RTAPI_MSG_ERR,
"command.com teleop bad axis_num cmd=%d\n",
emcmotCommand->command);
abort = 1;
}
if (!GET_MOTION_TELEOP_FLAG() && joint_num < 0) {
rtapi_print_msg(RTAPI_MSG_ERR,
"command.com !teleop bad joint_num cmd=%d\n",
emcmotCommand->command);
abort = 1;
}
}
if (abort) {
switch (emcmotCommand->command) {
case EMCMOT_JOG_CONT: rtapi_print_msg(RTAPI_MSG_ERR,"JOG_CONT\n");
break;
case EMCMOT_JOG_INCR: rtapi_print_msg(RTAPI_MSG_ERR,"JOG_INCR\n");
break;
case EMCMOT_JOG_ABS: rtapi_print_msg(RTAPI_MSG_ERR,"JOG_ABS\n");
break;
case EMCMOT_JOINT_ABORT: rtapi_print_msg(RTAPI_MSG_ERR,"JOG_ABORT\n");
break;
default: break;
}
return;
}
//-----------------------------------------------------------------------------
/* printing of commands for troubleshooting */
rtapi_print_msg(RTAPI_MSG_DBG, "%d: CMD %d, code %3d ", emcmotStatus->heartbeat,
emcmotCommand->commandNum, emcmotCommand->command);
if (joint_num >= 0 && joint_num < emcmotConfig->numJoints) {
joint = &joints[joint_num];
}
if (axis_num >= 0 && axis_num < EMCMOT_MAX_AXIS) {
axis = &axes[axis_num];
}
switch (emcmotCommand->command) {
case EMCMOT_ABORT:
@ -496,13 +519,9 @@ void emcmotCommandHandler(void *arg, long period)
case EMCMOT_JOINT_ABORT:
/* abort one joint */
/* can happen at any time */
/* this command stops a single joint. It is only usefull
in free mode, so in coord or teleop mode it does
nothing. */
rtapi_print_msg(RTAPI_MSG_DBG, "JOINT_ABORT");
rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num);
if (GET_MOTION_TELEOP_FLAG()) {
axis = &axes[joint_num];
/* tell teleop planner to stop */
axis->teleop_tp.enable = 0;
/* do nothing in teleop mode */
@ -710,9 +729,6 @@ void emcmotCommandHandler(void *arg, long period)
stop the jog. */
rtapi_print_msg(RTAPI_MSG_DBG, "JOG_CONT");
rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num);
if (joint == 0) {
break;
}
/* must be in free mode and enabled */
if (GET_MOTION_COORD_FLAG()) {
reportError(_("Can't jog joint in coordinated mode."));
@ -771,11 +787,7 @@ void emcmotCommandHandler(void *arg, long period)
since homing, otherwise just do this one */
clearHomes(joint_num);
} else {
axis_num = emcmotCommand->joint;
if (axis_num >= 0 && axis_num < EMCMOT_MAX_AXIS) {
/* valid axis, point to it's data */
axis = &axes[axis_num];
}
// TELEOP JOG_CONT
if (emcmotCommand->vel > 0.0) {
axis->teleop_tp.pos_cmd = axis->max_pos_limit;
} else {
@ -794,9 +806,6 @@ void emcmotCommandHandler(void *arg, long period)
/* do an incremental jog */
rtapi_print_msg(RTAPI_MSG_DBG, "JOG_INCR");
rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num);
if (joint == 0) {
break;
}
/* must be in free mode and enabled */
if (GET_MOTION_COORD_FLAG()) {
reportError(_("Can't jog joint in coordinated mode."));
@ -863,11 +872,7 @@ void emcmotCommandHandler(void *arg, long period)
since homing, otherwise just do this one */
clearHomes(joint_num);
} else {
axis_num = emcmotCommand->joint;
if (axis_num >= 0 && axis_num < EMCMOT_MAX_AXIS) {
/* valid axis, point to it's data */
axis = &axes[axis_num];
}
// TELEOP JOG_INCR
if (emcmotCommand->vel > 0.0) {
tmp1 = axis->teleop_tp.pos_cmd + emcmotCommand->offset;
} else {
@ -891,7 +896,8 @@ void emcmotCommandHandler(void *arg, long period)
}
break;
case EMCMOT_JOG_ABS:
case EMCMOT_JOG_ABS: //FIXME not updated for free/teleop
//(see JOG_CONT,JOG_INCR above for reqd changes)
/* do an absolute jog */
rtapi_print_msg(RTAPI_MSG_DBG, "JOG_ABS");
rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num);
@ -1569,7 +1575,7 @@ void emcmotCommandHandler(void *arg, long period)
/* emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND; */
/* tpAbort(&emcmotDebug->tp); */
/* SET_MOTION_ERROR_FLAG(1); */
/* } else { */
/* } else {...} */
emcmotStatus->spindle.speed = emcmotCommand->vel;
emcmotStatus->spindle.css_factor = emcmotCommand->ini_maxvel;
emcmotStatus->spindle.xoffset = emcmotCommand->acc;

View file

@ -12,7 +12,6 @@
*
* Copyright (c) 2004 All rights reserved.
********************************************************************/
#include "posemath.h"
#include "rtapi.h"
#include "hal.h"
@ -899,6 +898,9 @@ static void handle_jogwheels(void)
/* no, nothing to do */
continue;
}
if (GET_MOTION_TELEOP_FLAG()) {
return; //only joint jogging (no axis.N.jog* pins)
}
/* must be in free mode and enabled */
if (GET_MOTION_COORD_FLAG()) {
continue;
@ -979,7 +981,6 @@ static void handle_jogwheels(void)
// done with initialization, do the whole thing from now on
first_pass = 0;
}
static void get_pos_cmds(long period)
{
int joint_num, axis_num, result;

View file

@ -1270,7 +1270,7 @@ void EMC_JOINT_CMD_MSG::update(CMS * cms)
void EMC_AXIS_CMD_MSG::update(CMS * cms)
{
cms->update(axis);
cms->update(joint_or_axis);
}

View file

@ -417,10 +417,10 @@ extern int emcJointActivate(int joint);
extern int emcJointDeactivate(int joint);
extern int emcJointOverrideLimits(int joint);
extern int emcJointLoadComp(int joint, const char *file, int type);
extern int emcJogStop(int nr);
extern int emcJogCont(int nr, double vel);
extern int emcJogIncr(int nr, double incr, double vel);
extern int emcJogAbs(int nr, double pos, double vel);
extern int emcJogStop(int nr, int jjogmode);
extern int emcJogCont(int nr, double vel, int jjogmode);
extern int emcJogIncr(int nr, double incr, double vel, int jjogmode);
extern int emcJogAbs(int nr, double pos, double vel, int jjogmode);
extern int emcJointUpdate(EMC_JOINT_STAT stat[], int numJoints);

View file

@ -142,7 +142,7 @@ class EMC_AXIS_CMD_MSG:public RCS_CMD_MSG {
void update(CMS * cms);
// 0 = X, 1 = Y, 2 = Z, etc.
int axis;
int joint_or_axis;
};
// AIXS status base class
@ -408,6 +408,7 @@ class EMC_JOG_CONT:public EMC_AXIS_CMD_MSG {
void update(CMS * cms);
double vel;
int jjogmode;
};
class EMC_JOG_INCR:public EMC_AXIS_CMD_MSG {
@ -421,6 +422,7 @@ class EMC_JOG_INCR:public EMC_AXIS_CMD_MSG {
double incr;
double vel;
int jjogmode;
};
class EMC_JOG_ABS:public EMC_AXIS_CMD_MSG {
@ -434,6 +436,7 @@ class EMC_JOG_ABS:public EMC_AXIS_CMD_MSG {
double pos;
double vel;
int jjogmode;
};
class EMC_JOG_STOP:public EMC_AXIS_CMD_MSG {
@ -444,6 +447,8 @@ class EMC_JOG_STOP:public EMC_AXIS_CMD_MSG {
// For internal NML/CMS use only.
void update(CMS * cms);
int jjogmode;
};
class EMC_JOINT_ACTIVATE:public EMC_JOINT_CMD_MSG {

View file

@ -1648,24 +1648,31 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
case EMC_JOG_CONT_TYPE:
jog_cont_msg = (EMC_JOG_CONT *) cmd;
retval = emcJogCont(jog_cont_msg->axis, jog_cont_msg->vel);
retval = emcJogCont(jog_cont_msg->joint_or_axis,
jog_cont_msg->vel,
jog_cont_msg->jjogmode);
break;
case EMC_JOG_STOP_TYPE:
jog_stop_msg = (EMC_JOG_STOP *) cmd;
retval = emcJogStop(jog_stop_msg->axis);
retval = emcJogStop(jog_stop_msg->joint_or_axis,
jog_stop_msg->jjogmode);
break;
case EMC_JOG_INCR_TYPE:
jog_incr_msg = (EMC_JOG_INCR *) cmd;
retval = emcJogIncr(jog_incr_msg->axis,
jog_incr_msg->incr, jog_incr_msg->vel);
retval = emcJogIncr(jog_incr_msg->joint_or_axis,
jog_incr_msg->incr,
jog_incr_msg->vel,
jog_incr_msg->jjogmode);
break;
case EMC_JOG_ABS_TYPE:
jog_abs_msg = (EMC_JOG_ABS *) cmd;
retval = emcJogAbs(jog_abs_msg->axis,
jog_abs_msg->pos, jog_abs_msg->vel);
retval = emcJogAbs(jog_abs_msg->joint_or_axis,
jog_abs_msg->pos,
jog_abs_msg->vel,
jog_abs_msg->jjogmode);
break;
case EMC_JOINT_SET_BACKLASH_TYPE:

View file

@ -708,73 +708,101 @@ int emcJointUnhome(int joint)
return usrmotWriteEmcmotCommand(&emcmotCommand);
}
int emcJogCont(int nr, double vel)
int emcJogCont(int nr, double vel, int jjogmode)
{
if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) {
return 0;
if (jjogmode) {
if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) { return 0; }
if (vel > JointConfig[nr].MaxVel) {
vel = JointConfig[nr].MaxVel;
} else if (vel < -JointConfig[nr].MaxVel) {
vel = -JointConfig[nr].MaxVel;
}
emcmotCommand.joint = nr;
emcmotCommand.axis = -1; //NA
} else {
if (nr < 0 || nr >= EMCMOT_MAX_AXIS) { return 0; }
if (vel > AxisConfig[nr].MaxVel) {
vel = AxisConfig[nr].MaxVel;
} else if (vel < -AxisConfig[nr].MaxVel) {
vel = -AxisConfig[nr].MaxVel;
}
emcmotCommand.joint = -1; //NA
emcmotCommand.axis = nr;
}
if (vel > JointConfig[nr].MaxVel) {
vel = JointConfig[nr].MaxVel;
} else if (vel < -JointConfig[nr].MaxVel) {
vel = -JointConfig[nr].MaxVel;
}
emcmotCommand.command = EMCMOT_JOG_CONT;
emcmotCommand.joint = nr;
emcmotCommand.vel = vel;
return usrmotWriteEmcmotCommand(&emcmotCommand);
}
int emcJogIncr(int nr, double incr, double vel)
int emcJogIncr(int nr, double incr, double vel, int jjogmode)
{
if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) {
return 0;
if (jjogmode) {
if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) { return 0; }
if (vel > JointConfig[nr].MaxVel) {
vel = JointConfig[nr].MaxVel;
} else if (vel < -JointConfig[nr].MaxVel) {
vel = -JointConfig[nr].MaxVel;
}
emcmotCommand.joint = nr;
emcmotCommand.axis = -1; //NA
} else {
if (nr < 0 || nr >= EMCMOT_MAX_AXIS) { return 0; }
if (vel > AxisConfig[nr].MaxVel) {
vel = AxisConfig[nr].MaxVel;
} else if (vel < -AxisConfig[nr].MaxVel) {
vel = -AxisConfig[nr].MaxVel;
}
emcmotCommand.joint = -1; //NA
emcmotCommand.axis = nr;
}
if (vel > JointConfig[nr].MaxVel) {
vel = JointConfig[nr].MaxVel;
} else if (vel < -JointConfig[nr].MaxVel) {
vel = -JointConfig[nr].MaxVel;
}
emcmotCommand.command = EMCMOT_JOG_INCR;
emcmotCommand.joint = nr;
emcmotCommand.vel = vel;
emcmotCommand.offset = incr;
return usrmotWriteEmcmotCommand(&emcmotCommand);
}
int emcJogAbs(int nr, double pos, double vel)
int emcJogAbs(int nr, double pos, double vel, int jjogmode)
{
if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) {
return 0;
if (jjogmode) {
if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) { return 0; }
if (vel > JointConfig[nr].MaxVel) {
vel = JointConfig[nr].MaxVel;
} else if (vel < -JointConfig[nr].MaxVel) {
vel = -JointConfig[nr].MaxVel;
}
emcmotCommand.joint = nr;
emcmotCommand.axis = -1; //NA
} else {
if (nr < 0 || nr >= EMCMOT_MAX_AXIS) { return 0; }
if (vel > AxisConfig[nr].MaxVel) {
vel = AxisConfig[nr].MaxVel;
} else if (vel < -AxisConfig[nr].MaxVel) {
vel = -AxisConfig[nr].MaxVel;
}
emcmotCommand.joint = -1; //NA
emcmotCommand.axis = nr;
}
if (vel > JointConfig[nr].MaxVel) {
vel = JointConfig[nr].MaxVel;
} else if (vel < -JointConfig[nr].MaxVel) {
vel = -JointConfig[nr].MaxVel;
}
emcmotCommand.command = EMCMOT_JOG_ABS;
emcmotCommand.joint = nr;
emcmotCommand.vel = vel;
emcmotCommand.offset = pos;
return usrmotWriteEmcmotCommand(&emcmotCommand);
}
int emcJogStop(int nr)
int emcJogStop(int nr, int jjogmode)
{
if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) {
return 0;
if (jjogmode) {
if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) { return 0; }
emcmotCommand.joint = nr;
emcmotCommand.axis = -1; //NA
} else {
if (nr < 0 || nr >= EMCMOT_MAX_AXIS) { return 0; }
emcmotCommand.joint = -1; //NA
emcmotCommand.axis = nr;
}
emcmotCommand.command = EMCMOT_JOINT_ABORT;
emcmotCommand.joint = nr;
return usrmotWriteEmcmotCommand(&emcmotCommand);
}

View file

@ -1027,49 +1027,54 @@ static PyObject *unhome(pyCommandChannel *s, PyObject *o) {
return Py_None;
}
// jog(JOG_STOP, axis)
// jog(JOG_CONTINUOUS, axis, speed)
// jog(JOG_INCREMENT, axis, speed, increment)
// jog(JOG_STOP, jjogmode, ja_value)
// jog(JOG_CONTINUOUS, jjogmode, ja_value, speed)
// jog(JOG_INCREMENT, jjogmode, ja_value, speed, increment)
static PyObject *jog(pyCommandChannel *s, PyObject *o) {
int fn;
int axis;
int ja_value,jjogmode;
double vel, inc;
if(!PyArg_ParseTuple(o, "iii|dd", &fn, &jjogmode, &ja_value, &vel, &inc)) {
return NULL;
}
if(!PyArg_ParseTuple(o, "ii|dd", &fn, &axis, &vel, &inc)) return NULL;
if(fn == LOCAL_JOG_STOP) {
if(PyTuple_Size(o) != 2) {
if(PyTuple_Size(o) != 3) {
PyErr_Format( PyExc_TypeError,
"jog(JOG_STOP, ...) takes 2 arguments (%lu given)",
"jog(JOG_STOP, ...) takes 3 arguments (%lu given)",
(unsigned long)PyTuple_Size(o));
return NULL;
}
EMC_JOG_STOP abort;
abort.axis = axis;
abort.joint_or_axis = ja_value;
abort.jjogmode = jjogmode;
emcSendCommand(s, abort);
} else if(fn == LOCAL_JOG_CONTINUOUS) {
if(PyTuple_Size(o) != 3) {
if(PyTuple_Size(o) != 4) {
PyErr_Format( PyExc_TypeError,
"jog(JOG_CONTINUOUS, ...) takes 3 arguments (%lu given)",
"jog(JOG_CONTINUOUS, ...) takes 4 arguments (%lu given)",
(unsigned long)PyTuple_Size(o));
return NULL;
}
EMC_JOG_CONT cont;
cont.axis = axis;
cont.joint_or_axis = ja_value;
cont.vel = vel;
cont.jjogmode = jjogmode;
emcSendCommand(s, cont);
} else if(fn == LOCAL_JOG_INCREMENT) {
if(PyTuple_Size(o) != 4) {
if(PyTuple_Size(o) != 5) {
PyErr_Format( PyExc_TypeError,
"jog(JOG_INCREMENT, ...) takes 4 arguments (%lu given)",
"jog(JOG_INCREMENT, ...) takes 5 arguments (%lu given)",
(unsigned long)PyTuple_Size(o));
return NULL;
}
EMC_JOG_INCR incr;
incr.axis = axis;
incr.joint_or_axis = ja_value;
incr.vel = vel;
incr.incr = inc;
incr.jjogmode = jjogmode;
emcSendCommand(s, incr);
} else {
PyErr_Format( PyExc_TypeError, "jog() first argument must be JOG_xxx");
@ -2218,6 +2223,10 @@ initlinuxcnc(void) {
ENUMX(9, EMC_TASK_EXEC_WAITING_FOR_SYSTEM_CMD);
ENUMX(9, EMC_TASK_EXEC_WAITING_FOR_SPINDLE_ORIENTED);
ENUMX(7, EMCMOT_MAX_JOINTS);
ENUMX(7, EMCMOT_MAX_AXIS);
ENUM(RCS_DONE);
ENUM(RCS_EXEC);
ENUM(RCS_ERROR);

View file

@ -126,12 +126,23 @@ rs274.options.install(root_window)
root_window.tk.call("set", "version", linuxcnc.version)
try:
root_window.tk.call("set","::MAX_JOINTS" ,linuxcnc.MAX_JOINTS)
root_window.tk.call("set","::MAX_AXIS" ,linuxcnc.MAX_AXIS)
root_window.tk.call("set","::STATE_ESTOP" ,linuxcnc.STATE_ESTOP)
root_window.tk.call("set","::STATE_ESTOP_RESET" ,linuxcnc.STATE_ESTOP_RESET)
root_window.tk.call("set","::STATE_OFF" ,linuxcnc.STATE_OFF)
root_window.tk.call("set","::STATE_ON" ,linuxcnc.STATE_ON)
root_window.tk.call("set","::INTERP_IDLE" ,linuxcnc.INTERP_IDLE)
root_window.tk.call("set","::INTERP_READING" ,linuxcnc.INTERP_READING)
root_window.tk.call("set","::INTERP_PAUSED" ,linuxcnc.INTERP_PAUSED)
root_window.tk.call("set","::INTERP_WAITING" ,linuxcnc.INTERP_WAITING)
root_window.tk.call("set","::TRAJ_MODE_FREE" ,linuxcnc.TRAJ_MODE_FREE)
root_window.tk.call("set","::KINEMATICS_IDENTITY",linuxcnc.KINEMATICS_IDENTITY)
nf.source_lib_tcl(root_window,"axis.tcl")
except TclError:
print root_window.tk.call("set", "errorInfo")
raise
def General_Halt():
text = "Do you really want to close linuxcnc?"
if not root_window.tk.call("nf_dialog", ".error", "Confirm Close", text, "warning", 1, "Yes", "No"):
@ -245,7 +256,7 @@ def install_help(app):
Label(keys, text=" ").grid(row=0, column=2)
def joints_mode():
return s.motion_mode == linuxcnc.TRAJ_MODE_FREE and s.kinematics_type != linuxcnc.KINEMATICS_IDENTITY
return s.motion_mode == linuxcnc.TRAJ_MODE_FREE
def parse_color(c):
if c == "": return (1,0,0)
@ -551,7 +562,7 @@ class MyOpengl(GlCanonDraw, Opengl):
def redraw_dro(self):
self.stat.poll()
limit, homed, posstrs, droposstrs = self.posstrs()
limit, homed, posstrs, droposstrs = self.posstrs(no_joint_display)
text = widgets.numbers_text
@ -1253,16 +1264,24 @@ widgets = nf.Widgets(root_window,
("unhomemenu", Menu, ".menu.machine.unhome")
)
def activate_axis(i, force=0):
def activate_ja_widget(i, force=0):
if not force and not manual_ok(): return
if joints_mode():
if get_jog_mode():
# free jogging (joints) (only accept integers here)
if type(i) != type(0): return
if i >= num_joints: return
axis = getattr(widgets, "joint_%d" % i)
widget = getattr(widgets, "joint_%d" % i)
else:
if not s.axis_mask & (1<<i): return
axis = getattr(widgets, "axis_%s" % "xyzabcuvw"[i])
axis.focus()
axis.invoke()
# teleop jogging (axes) (letters are special case for key bindings)
if type(i) == type(""): letter = i
else: letter = "xyzabcuvw"[i]
if letter in trajcoordinates:
widget = getattr(widgets, "axis_%s" % letter)
else:
# key bindings for letters not in trajcoordinates end up here
return
widget.focus()
widget.invoke()
def set_first_line(lineno):
global program_start_line
@ -1561,11 +1580,11 @@ class _prompt_touchoff(_prompt_float):
systems = all_systems[:]
if not tool_only:
del systems[-1]
linear_axis = vars.current_axis.get() in "xyzuvw"
linear_axis = vars.ja_rbutton.get() in "xyzuvw"
if linear_axis:
if vars.metric.get(): unit_str = " " + _("mm")
else: unit_str = " " + _("in")
if lathe and vars.current_axis.get() == "x":
if lathe and vars.ja_rbutton.get() == "x":
if 80 in s.gcodes:
unit_str += _(" radius")
else:
@ -1699,6 +1718,102 @@ def reload_file(refilter=True):
if line:
o.set_highlight_line(line)
def ja_from_rbutton():
# radiobuttons for joints set ja_rbutton to numeric value [0,MAX_JOINTS)
# radiobuttons for axes set ja_rbutton to one of: xyzabcuvw
ja = vars.ja_rbutton.get()
if ja in "012345678":
a = int(ja)
else :
a = "xyzabcuvw".index(ja)
return a
def all_homed():
isHomed=True
for i,h in enumerate(s.homed):
if i >= num_joints: break
isHomed = isHomed and h
return isHomed
def go_home(num):
vars.teleop_mode.set(0)
commands.set_teleop_mode()
c.home(num)
c.wait_complete()
auto_teleop = inifile.find("KINS", "AUTO_TELEOP") or 0
auto_teleop = int(float(auto_teleop)) # use as int
# Optional: set teleop after homing
# [KINS]AUTO_SET_TELEOP is max seconds to wait
# zero value or absence disables
# test on != KINEMATICS_IDENTITY is not mandatory
if ( (auto_teleop > 0)
and (num == -1)
and (s.kinematics_type != linuxcnc.KINEMATICS_IDENTITY)
):
delta_secs = 1 # seconds
max_wait_secs = auto_teleop # seconds
print("AUTO_TELEOP: wait for homing completion (%s seconds max)"
% max_wait_secs)
switch_to_teleop(0,delta_secs,max_wait_secs)
def switch_to_teleop(ct,delta_secs,max_wait_secs):
import threading
s.poll()
#print ct,get_states()
if s.task_state != linuxcnc.STATE_ON:
print("AUTO_TELEOP: ABANDON (task_state=%s)"
% task_statename(s.task_state))
return
ct = ct + 1
elapsed = ct * delta_secs
if all_homed():
vars.teleop_mode.set(1)
commands.set_teleop_mode()
print "AUTO_TELEOP: homing finished in %s seconds" % elapsed
return
if (elapsed < max_wait_secs):
#print "ct=%s max=%s elapsed=%s" % (ct,max_wait_secs,elapsed)
threading.Timer(delta_secs,
switch_to_teleop,
args=(ct,delta_secs,max_wait_secs)).start()
else:
print "AUTO_TELEOP: GIVEUP after %s seconds" % max_wait_secs
pass
#-----------------------------------------------------------
# convenience functions
def motion_modename(x):
if x == linuxcnc.TRAJ_MODE_FREE: return "FREE"
if x == linuxcnc.TRAJ_MODE_COORD: return "COORD"
if x == linuxcnc.TRAJ_MODE_TELEOP: return "TELEOP"
def task_modename(x):
if x == linuxcnc.TASK_MODE_MDI: return "MDI"
if x == linuxcnc.TASK_MODE_MANUAL: return "MANUAL"
if x == linuxcnc.TASK_MODE_AUTO: return "AUTO"
def task_statename(x):
if x == linuxcnc.STATE_ESTOP: return "STATE_ESTOP"
if x == linuxcnc.STATE_ESTOP_RESET: return "STATE_ESTOP_RESET"
if x == linuxcnc.STATE_OFF: return "STATE_OFF"
if x == linuxcnc.STATE_ON: return "STATE_ON"
def interp_statename(x):
if x == linuxcnc.INTERP_IDLE: return "IDLE"
if x == linuxcnc.INTERP_READING: return "READING"
if x == linuxcnc.INTERP_PAUSED: return "PAUSED"
if x == linuxcnc.INTERP_WAITING: return "WAITING"
def get_states():
s.poll()
return (task_modename(s.task_mode)
,task_statename(s.task_state)
,motion_modename(s.motion_mode)
,interp_statename(s.interp_state)
)
#-----------------------------------------------------------
class TclCommands(nf.TclCommands):
def next_tab(event=None):
current = widgets.right.raise_page()
@ -1808,6 +1923,10 @@ class TclCommands(nf.TclCommands):
spindlerate_blackout = time.time() + 1
def set_feedrate(newval):
if (joints_mode()
and (s.kinematics_type != linuxcnc.KINEMATICS_IDENTITY)):
return
# teleop or identity allows (De Morgan):
global feedrate_blackout
try:
value = int(newval)
@ -2314,57 +2433,53 @@ class TclCommands(nf.TclCommands):
# The next three don't have 'manual_ok' because that's done in jog_on /
# jog_off
def jog_plus(incr=False):
a = vars.current_axis.get()
if isinstance(a, (str, unicode)):
a = "xyzabcuvw".index(a)
a = ja_from_rbutton()
speed = get_jog_speed(a)
jog_on(a, speed)
def jog_minus(incr=False):
a = vars.current_axis.get()
if isinstance(a, (str, unicode)):
a = "xyzabcuvw".index(a)
a = ja_from_rbutton()
speed = get_jog_speed(a)
jog_on(a, -speed)
def jog_stop(event=None):
jog_off(vars.current_axis.get())
def home_all_axes(event=None):
def jog_stop(event=None):
a = ja_from_rbutton()
jog_off(a)
def home_all_joints(event=None):
if not manual_ok(): return
ensure_mode(linuxcnc.MODE_MANUAL)
isHomed=True
for i,h in enumerate(s.homed):
if s.axis_mask & (1<<i):
isHomed=isHomed and h
isHomed = all_homed()
doHoming=True
if isHomed:
doHoming=prompt_areyousure(_("Warning"),_("Axis is already homed, are you sure you want to re-home?"))
doHoming=prompt_areyousure(_("Warning"),_("Joint is already homed, are you sure you want to re-home?"))
if doHoming:
c.home(-1)
go_home(-1)
def unhome_all_axes(event=None):
def unhome_all_joints(event=None):
if not manual_ok(): return
ensure_mode(linuxcnc.MODE_MANUAL)
c.unhome(-1)
def home_axis(event=None):
def home_joint(event=None):
if not manual_ok(): return
doHoming=True
if s.homed["xyzabcuvw".index(vars.current_axis.get())]:
doHoming=prompt_areyousure(_("Warning"),_("This axis is already homed, are you sure you want to re-home?"))
if s.homed[trajcoordinates.index(vars.ja_rbutton.get())]:
doHoming=prompt_areyousure(_("Warning"),_("This joint is already homed, are you sure you want to re-home?"))
if doHoming:
ensure_mode(linuxcnc.MODE_MANUAL)
c.home("xyzabcuvw".index(vars.current_axis.get()))
go_home(trajcoordinates.index(vars.ja_rbutton.get()))
def unhome_axis(event=None):
def unhome_joint(event=None):
if not manual_ok(): return
ensure_mode(linuxcnc.MODE_MANUAL)
c.unhome("xyzabcuvw".index(vars.current_axis.get()))
c.unhome(trajcoordinates.index(vars.ja_rbutton.get()))
def home_axis_number(num):
def home_joint_number(num):
ensure_mode(linuxcnc.MODE_MANUAL)
c.home(num)
go_home(num)
def unhome_axis_number(num):
def unhome_joint_number(num):
ensure_mode(linuxcnc.MODE_MANUAL)
c.unhome(num)
@ -2387,12 +2502,19 @@ class TclCommands(nf.TclCommands):
def touch_off_system(event=None, new_axis_value = None):
global system
if not manual_ok(): return
if s.kinematics_type == linuxcnc.KINEMATICS_IDENTITY:
c.teleop_enable(1)
c.wait_complete()
#print "touch_off_system() IDENTITY force TELEOP"
s.poll()
if joints_mode(): return
offset_axis = "xyzabcuvw".index(vars.current_axis.get())
offset_axis = trajcoordinates.index(vars.ja_rbutton.get())
if new_axis_value is None:
new_axis_value, system = prompt_touchoff(
title=_("Touch Off (system)"),
text=_("Enter %s coordinate relative to %%s:") % vars.current_axis.get().upper(),
text=_("Enter %s coordinate relative to %%s:") % vars.ja_rbutton.get().upper(),
default=0.0,
tool_only=False,
system=vars.touch_off_system.get()
@ -2404,14 +2526,14 @@ class TclCommands(nf.TclCommands):
ensure_mode(linuxcnc.MODE_MDI)
s.poll()
linear_axis = vars.current_axis.get() in "xyzuvw"
linear_axis = vars.ja_rbutton.get() in "xyzuvw"
if linear_axis and vars.metric.get(): scale = 1/25.4
else: scale = 1
if linear_axis and 210 in s.gcodes:
scale *= 25.4
offset_command = "G10 L20 %s %c[%s*%.12f]" % (system.split()[0], vars.current_axis.get(), new_axis_value, scale)
offset_command = "G10 L20 %s %c[%s*%.12f]" % (system.split()[0], vars.ja_rbutton.get(), new_axis_value, scale)
c.mdi(offset_command)
c.wait_complete()
@ -2423,6 +2545,13 @@ class TclCommands(nf.TclCommands):
def touch_off_tool(event=None, new_axis_value = None):
global system
if not manual_ok(): return
if s.kinematics_type == linuxcnc.KINEMATICS_IDENTITY:
c.teleop_enable(1)
c.wait_complete()
#print "touch_off_tool() IDENTITY force TELEOP"
s.poll()
if joints_mode(): return
s.poll()
# in case we get here via the keyboard shortcut, when the widget is disabled:
@ -2430,7 +2559,7 @@ class TclCommands(nf.TclCommands):
if new_axis_value is None:
new_axis_value, system = prompt_touchoff(
title=_("Tool Touch Off (Tool No:%s)"%s.tool_in_spindle),
text=_("Enter %s coordinate relative to %%s:") % vars.current_axis.get().upper(),
text=_("Enter %s coordinate relative to %%s:") % vars.ja_rbutton.get().upper(),
default=0.0,
tool_only=True,
system=vars.touch_off_system.get()
@ -2442,7 +2571,7 @@ class TclCommands(nf.TclCommands):
ensure_mode(linuxcnc.MODE_MDI)
s.poll()
linear_axis = vars.current_axis.get() in "xyzuvw"
linear_axis = vars.ja_rbutton.get() in "xyzuvw"
if linear_axis and vars.metric.get(): scale = 1/25.4
else: scale = 1
@ -2450,7 +2579,7 @@ class TclCommands(nf.TclCommands):
scale *= 25.4
lnum = 10 + vars.tto_g11.get()
offset_command = "G10 L%d P%d %c[%s*%.12f]" % (lnum, s.tool_in_spindle, vars.current_axis.get(), new_axis_value, scale)
offset_command = "G10 L%d P%d %c[%s*%.12f]" % (lnum, s.tool_in_spindle, vars.ja_rbutton.get(), new_axis_value, scale)
c.mdi(offset_command)
c.wait_complete()
c.mdi("G43")
@ -2553,16 +2682,17 @@ class TclCommands(nf.TclCommands):
commands.set_view_z()
def axis_activated(*args):
if not hal_present: return # this only makes sense if HAL is present on this machine
comp['jog.x'] = vars.current_axis.get() == "x"
comp['jog.y'] = vars.current_axis.get() == "y"
comp['jog.z'] = vars.current_axis.get() == "z"
comp['jog.a'] = vars.current_axis.get() == "a"
comp['jog.b'] = vars.current_axis.get() == "b"
comp['jog.c'] = vars.current_axis.get() == "c"
comp['jog.u'] = vars.current_axis.get() == "u"
comp['jog.v'] = vars.current_axis.get() == "v"
comp['jog.w'] = vars.current_axis.get() == "w"
# this only makes sense if HAL is present on this machine
if not hal_present: return
comp['jog.x'] = vars.ja_rbutton.get() == "x"
comp['jog.y'] = vars.ja_rbutton.get() == "y"
comp['jog.z'] = vars.ja_rbutton.get() == "z"
comp['jog.a'] = vars.ja_rbutton.get() == "a"
comp['jog.b'] = vars.ja_rbutton.get() == "b"
comp['jog.c'] = vars.ja_rbutton.get() == "c"
comp['jog.u'] = vars.ja_rbutton.get() == "u"
comp['jog.v'] = vars.ja_rbutton.get() == "v"
comp['jog.w'] = vars.ja_rbutton.get() == "w"
def set_teleop_mode(*args):
teleop_mode = vars.teleop_mode.get()
@ -2624,7 +2754,7 @@ vars = nf.Variables(root_window,
("task_mode", IntVar),
("has_ladder", IntVar),
("has_editor", IntVar),
("current_axis", StringVar),
("ja_rbutton", StringVar),
("tto_g11", BooleanVar),
("mist", BooleanVar),
("flood", BooleanVar),
@ -2671,6 +2801,7 @@ vars = nf.Variables(root_window,
("on_any_limit", BooleanVar),
("queued_mdi_commands", IntVar),
("max_queued_mdi_commands", IntVar),
("trajcoordinates", StringVar),
)
vars.linuxcnctop_command.set(os.path.join(os.path.dirname(sys.argv[0]), "linuxcnctop"))
vars.highlight_line.set(-1)
@ -2705,10 +2836,13 @@ def set_feedrate(n):
def set_rapidrate(n):
widgets.rapidoverride.set(n)
def activate_axis_or_set_feedrate(n):
# XXX: axis_mask does not apply if in joint mode
if manual_ok() and s.axis_mask & (1<<n):
activate_axis(n)
def activate_ja_widget_or_set_feedrate(n):
if (joints_mode()
and (s.kinematics_type != linuxcnc.KINEMATICS_IDENTITY)):
return
# teleop or identity allows (De Morgan):
if manual_ok() and (str(n) in trajcoordinates):
activate_ja_widget(n)
else:
set_feedrate(10*n)
@ -2743,19 +2877,25 @@ root_window.bind("<Key-F12>", commands.spindle_increase)
root_window.bind("B", commands.brake_on)
root_window.bind("b", commands.brake_off)
root_window.bind("<Control-k>", commands.clear_live_plot)
root_window.bind("x", lambda event: activate_axis(0))
root_window.bind("y", lambda event: activate_axis(1))
root_window.bind("z", lambda event: activate_axis(2))
root_window.bind("a", lambda event: activate_axis(3))
root_window.bind("`", lambda event: activate_axis_or_set_feedrate(0))
root_window.bind("1", lambda event: activate_axis_or_set_feedrate(1))
root_window.bind("2", lambda event: activate_axis_or_set_feedrate(2))
root_window.bind("3", lambda event: activate_axis_or_set_feedrate(3))
root_window.bind("4", lambda event: activate_axis_or_set_feedrate(4))
root_window.bind("5", lambda event: activate_axis_or_set_feedrate(5))
root_window.bind("6", lambda event: activate_axis_or_set_feedrate(6))
root_window.bind("7", lambda event: activate_axis_or_set_feedrate(7))
root_window.bind("8", lambda event: activate_axis_or_set_feedrate(8))
#----------------------------------------------------
# letters for teleop only
root_window.bind("x", lambda event: activate_ja_widget("x"))
root_window.bind("y", lambda event: activate_ja_widget("y"))
root_window.bind("z", lambda event: activate_ja_widget("z"))
root_window.bind("a", lambda event: activate_ja_widget("a"))
#----------------------------------------------------
root_window.bind("`", lambda event: activate_ja_widget_or_set_feedrate(0))
root_window.bind("1", lambda event: activate_ja_widget_or_set_feedrate(1))
root_window.bind("2", lambda event: activate_ja_widget_or_set_feedrate(2))
root_window.bind("3", lambda event: activate_ja_widget_or_set_feedrate(3))
root_window.bind("4", lambda event: activate_ja_widget_or_set_feedrate(4))
root_window.bind("5", lambda event: activate_ja_widget_or_set_feedrate(5))
root_window.bind("6", lambda event: activate_ja_widget_or_set_feedrate(6))
root_window.bind("7", lambda event: activate_ja_widget_or_set_feedrate(7))
root_window.bind("8", lambda event: activate_ja_widget_or_set_feedrate(8))
root_window.bind("9", lambda event: set_feedrate(90))
root_window.bind("0", lambda event: set_feedrate(100))
root_window.bind("c", lambda event: jogspeed_continuous())
@ -2767,13 +2907,13 @@ root_window.bind("@", commands.toggle_display_type)
root_window.bind("#", commands.toggle_coord_type)
root_window.bind("$", commands.toggle_teleop_mode)
root_window.bind("<Home>", commands.home_axis)
root_window.bind("<KP_Home>", kp_wrap(commands.home_axis, "KeyPress"))
root_window.bind("<Control-Home>", commands.home_all_axes)
root_window.bind("<Home>", commands.home_joint)
root_window.bind("<KP_Home>", kp_wrap(commands.home_joint, "KeyPress"))
root_window.bind("<Control-Home>", commands.home_all_joints)
root_window.bind("<Shift-Home>", commands.set_axis_offset)
root_window.bind("<End>", commands.touch_off_system)
root_window.bind("<Control-End>", commands.touch_off_tool)
root_window.bind("<Control-KP_Home>", kp_wrap(commands.home_all_axes, "KeyPress"))
root_window.bind("<Control-KP_Home>", kp_wrap(commands.home_all_joints, "KeyPress"))
root_window.bind("<Shift-KP_Home>", kp_wrap(commands.set_axis_offset, "KeyPress"))
root_window.bind("<KP_End>", kp_wrap(commands.touch_off_system, "KeyPress"))
widgets.mdi_history.bind("<Configure>", "%W see end" )
@ -2817,23 +2957,37 @@ try:
except IOError:
pass
def jog(*args):
if not manual_ok(): return
if not manual_tab_visible(): return
ensure_mode(linuxcnc.MODE_MANUAL)
c.jog(*args)
# XXX correct for machines with more than six axes
jog_after = [None] * 9
jog_cont = [False] * 9
jogging = [0] * 9
def get_jog_mode():
if s.kinematics_type == linuxcnc.KINEMATICS_IDENTITY:
vars.teleop_mode.set(1)
commands.set_teleop_mode()
ans = False
#print "get_jog_mode() IDENTITY force TELEOP"
else:
s.poll()
# check motion_mode since other guis (halui) could alter it
if s.motion_mode == linuxcnc.TRAJ_MODE_FREE:
vupdate(vars.teleop_mode,0)
ans = True
else:
vupdate(vars.teleop_mode,1)
ans = False
# ans==True ==> jjogmode, False ==> jog_axes (teleop)
return ans
# Note: require linuxcnc.MAX_JOINTS >= linuxcnc.MAX_AXIS
jog_after = [None] * linuxcnc.MAX_JOINTS
jog_cont = [False] * linuxcnc.MAX_JOINTS
jogging = [0] * linuxcnc.MAX_JOINTS
def jog_on(a, b):
if not manual_ok(): return
if not manual_tab_visible(): return
if isinstance(a, (str, unicode)):
a = "xyzabcuvw".index(a)
if a < 3 or a > 5:
if vars.metric.get(): b = b / 25.4
b = from_internal_linear_unit(b)
@ -2842,30 +2996,30 @@ def jog_on(a, b):
jog_after[a] = None
return
jogincr = widgets.jogincr.get()
jjogmode = get_jog_mode()
if jogincr != _("Continuous"):
s.poll()
if s.state != 1: return
distance = parse_increment(jogincr)
jog(linuxcnc.JOG_INCREMENT, a, b, distance)
jog(linuxcnc.JOG_INCREMENT, jjogmode, a, b, distance)
jog_cont[a] = False
else:
jog(linuxcnc.JOG_CONTINUOUS, a, b)
jog(linuxcnc.JOG_CONTINUOUS, jjogmode, a, b)
jog_cont[a] = True
jogging[a] = b
def jog_off(a):
if isinstance(a, (str, unicode)):
a = "xyzabcuvw".index(a)
if jog_after[a]: return
jog_after[a] = root_window.after_idle(lambda: jog_off_actual(a))
def jog_off_actual(a):
if not manual_ok(): return
activate_axis(a)
activate_ja_widget(a)
jog_after[a] = None
jogging[a] = 0
jjogmode = get_jog_mode()
if jog_cont[a]:
jog(linuxcnc.JOG_STOP, a)
jog(linuxcnc.JOG_STOP, jjogmode, a)
def jog_off_all():
for i in range(6):
@ -2934,7 +3088,7 @@ mav = (
or inifile.find("TRAJ","MAX_VELOCITY")
or mlv)
vars.max_aspeed.set(float(mav))
mv = inifile.find("DISPLAY","MAX_LINEAR_VELOCITY") or inifile.find("TRAJ","MAX_LINEAR_VELOCITY") or inifile.find("TRAJ","MAX_VELOCITY") or inifile.find("AXIS_0","MAX_VELOCITY") or 1.0
mv = inifile.find("DISPLAY","MAX_LINEAR_VELOCITY") or inifile.find("TRAJ","MAX_LINEAR_VELOCITY") or inifile.find("TRAJ","MAX_VELOCITY") or inifile.find("AXIS_X","MAX_VELOCITY") or 1.0
vars.maxvel_speed.set(float(mv)*60)
vars.max_maxvel.set(float(mv))
root_window.tk.eval("${pane_top}.jogspeed.s set [setval $jog_speed $max_speed]")
@ -2956,9 +3110,9 @@ vars.has_editor.set(editor is not None)
tooleditor = inifile.find("DISPLAY", "TOOL_EDITOR") or "tooledit"
tooltable = inifile.find("EMCIO", "TOOL_TABLE")
lu = units(inifile.find("TRAJ", "LINEAR_UNITS"))
a_axis_wrapped = inifile.find("AXIS_3", "WRAPPED_ROTARY")
b_axis_wrapped = inifile.find("AXIS_4", "WRAPPED_ROTARY")
c_axis_wrapped = inifile.find("AXIS_5", "WRAPPED_ROTARY")
a_axis_wrapped = inifile.find("AXIS_A", "WRAPPED_ROTARY")
b_axis_wrapped = inifile.find("AXIS_B", "WRAPPED_ROTARY")
c_axis_wrapped = inifile.find("AXIS_C", "WRAPPED_ROTARY")
if coordinate_display:
if coordinate_display.lower() in ("mm", "metric"): vars.metric.set(1)
else: vars.metric.set(0)
@ -2975,10 +3129,10 @@ root_window.tk.eval(u"${pane_top}.ajogspeed.l1 configure -text deg/min")
homing_order_defined = inifile.find("JOINT_0", "HOME_SEQUENCE") is not None
if homing_order_defined:
widgets.homebutton.configure(text=_("Home All"), command="home_all_axes")
widgets.homebutton.configure(text=_("Home All"), command="home_all_joints")
root_window.tk.call("DynamicHelp::add", widgets.homebutton,
"-text", _("Home all axes [Ctrl-Home]"))
widgets.homemenu.add_command(command=commands.home_all_axes)
widgets.homemenu.add_command(command=commands.home_all_joints)
root_window.tk.call("setup_menu_accel", widgets.homemenu, "end",
_("Home All Axes"))
@ -2986,11 +3140,22 @@ update_ms = int(1000 * float(inifile.find("DISPLAY","CYCLE_TIME") or 0.020))
interpname = inifile.find("TASK", "INTERPRETER") or ""
widgets.unhomemenu.add_command(command=commands.unhome_all_axes)
widgets.unhomemenu.add_command(command=commands.unhome_all_joints)
root_window.tk.call("setup_menu_accel", widgets.unhomemenu, "end", _("Unhome All Axes"))
s = linuxcnc.stat();
s.poll()
# derive trajcoordinates from axis_mask (initraj.cc [TRAJ]COORDINATES)
trajcoordinates = ""
for i in range(9):
if s.axis_mask & (1<<i): trajcoordinates = trajcoordinates + "xyzabcuvw"[i]
vars.trajcoordinates.set(trajcoordinates)
no_joint_display = False
if (s.kinematics_type == linuxcnc.KINEMATICS_IDENTITY):
no_joint_display = True
statfail=0
statwait=.01
while s.joints == 0:
@ -3006,18 +3171,19 @@ while s.joints == 0:
num_joints = s.joints
for i in range(num_joints):
if not (s.axis_mask & (1<<i)): continue
widgets.homemenu.add_command(command=lambda i=i: commands.home_axis_number(i))
widgets.unhomemenu.add_command(command=lambda i=i: commands.unhome_axis_number(i))
#if not (s.axis_mask & (1<<i)): continue # ja:not needed for consecutive joints
widgets.homemenu.add_command(command=lambda i=i: commands.home_joint_number(i))
widgets.unhomemenu.add_command(command=lambda i=i: commands.unhome_joint_number(i))
root_window.tk.call("setup_menu_accel", widgets.homemenu, "end",
_("Home Joint _%s") % i)
root_window.tk.call("setup_menu_accel", widgets.unhomemenu, "end",
_("Unhome Joint _%s") % i)
astep_size = step_size = 1
for a in range(9):
if s.axis_mask & (1<<a) == 0: continue
section = "AXIS_%d" % a
for a in range(linuxcnc.MAX_AXIS):
a = "XYZABCUVW"[a]
if s.axis_mask & (1<<i) == 0: continue
section = "AXIS_%s" % a
unit = inifile.find(section, "UNITS") or lu
unit = units(unit) * 25.4
f = inifile.find(section, "SCALE") or inifile.find(section, "INPUT_SCALE") or "8000"
@ -3031,8 +3197,8 @@ for a in range(9):
if a < 3: step_size = astep_size = step_size_tmp
else: astep_size = step_size_tmp
joint_type = [None] * 9
for j in range(9):
joint_type = [None] * linuxcnc.MAX_JOINTS
for j in range(linuxcnc.MAX_JOINTS):
if s.axis_mask & (1<<j) == 0: continue
section = "AXIS_%d" % j
joint_type[j] = inifile.find(section, "TYPE")
@ -3096,18 +3262,21 @@ root_window.bind("<KeyPress-equal>", nomodifier(commands.jog_plus))
root_window.bind("<KeyRelease-minus>", commands.jog_stop)
root_window.bind("<KeyRelease-equal>", commands.jog_stop)
opts, args = getopt.getopt(sys.argv[1:], 'd:')
for i in range(9):
# forget axis radiobuttons not in axis_mask
for i in range(linuxcnc.MAX_AXIS):
if s.axis_mask & (1<<i): continue
c = getattr(widgets, "axis_%s" % ("xyzabcuvw"[i]))
letter = "xyzabcuvw"[i]
c = getattr(widgets, "axis_%s" % letter)
c.grid_forget()
for i in range(num_joints, 9):
# forget joint radiobuttons for joints > num_joints
for i in range(num_joints, linuxcnc.MAX_JOINTS):
c = getattr(widgets, "joint_%d" % i)
c.grid_forget()
if s.axis_mask & 56 == 0:
if s.axis_mask & 56 == 0: # 56==0x38== 000111000 (abc)
widgets.ajogspeed.grid_forget()
c = linuxcnc.command()
e = linuxcnc.error_channel()
@ -3277,7 +3446,7 @@ def remove_tempdir(t):
tempdir = tempfile.mkdtemp()
atexit.register(remove_tempdir, tempdir)
activate_axis(0, True)
activate_ja_widget(0, True)
set_hal_jogincrement()
code = []
@ -3464,7 +3633,7 @@ forget(widgets.spinoverridef,
"motion.spindle-speed-out", "motion.spindle-speed-out-abs", "motion.spindle-speed-out-rps", "motion.spindle-speed-out-rps-abs")
has_limit_switch = 0
for j in range(9):
for j in range(linuxcnc.MAX_JOINTS):
try:
if hal.pin_has_writer("joint.%d.neg-lim-sw-in" % j):
has_limit_switch=1

View file

@ -1131,43 +1131,43 @@ static void parseConnect()
// sockSendStr(sockfd, "info\n");
}
static int jog(int axis, float speed)
static int jog(int jnum, float speed)
{
float stepSize;
if (emcStatus->task.mode != EMC_TASK_MODE_MANUAL) return 0;
if (units == unmm) stepSize = 10.0;
else stepSize = 1.0;
if ((axis < 0) || (axis > 5)) return -1;
if ((jnum < 0) || (jnum > 5)) return -1;
// if (runStatus == rsIdle) {
// sendManual();
switch (jogMode) {
case jtCont:
if (jogging == 1) { // toggle if driver does not support key down / key up
jogging = 0;
return sendJogStop(axis);
return sendJogJointStop(jnum);
}
else {
jogging = 1;
return sendJogCont(axis, speed);
return sendJogJointCont(jnum, speed);
}
case jtStep1: return sendJogIncr(axis, speed, stepSize/conversion); break;
case jtStep01: return sendJogIncr(axis, speed, (stepSize/10.0)/conversion); break;
case jtStep001: return sendJogIncr(axis, speed, (stepSize/100.0)/conversion); break;
case jtStep0001: return sendJogIncr(axis, speed, (stepSize/1000.0)/conversion); break;
case jtStep1: return sendJogJointIncr(jnum, speed, stepSize/conversion); break;
case jtStep01: return sendJogJointIncr(jnum, speed, (stepSize/10.0)/conversion); break;
case jtStep001: return sendJogJointIncr(jnum, speed, (stepSize/100.0)/conversion); break;
case jtStep0001: return sendJogJointIncr(jnum, speed, (stepSize/1000.0)/conversion); break;
default: return -1;
}
// }
// else return 0;
}
static int jogStop(int axis)
static int jogStop(int jnum)
{
if (emcStatus->task.mode != EMC_TASK_MODE_MANUAL) return 0;
if ((axis < 0) || (axis > 5)) return -1;
if ((jnum < 0) || (jnum > 5)) return -1;
jogging = 0;
if (jogMode != jtCont) return 0;
return sendJogStop(axis);
return sendJogJointStop(jnum);
}
static int leftKey()

View file

@ -1013,29 +1013,29 @@ static cmdResponseType setHome(char *s, connectionRecType *context)
static cmdResponseType setJogStop(char *s, connectionRecType *context)
{
int axis;
int jnum;
if (s == NULL) return rtStandardError;
if (sscanf(s, "%d", &axis) <= 0) return rtStandardError;
if ((axis < 0) || (axis > 5)) return rtStandardError;
if (sendJogStop(axis) != 0) return rtStandardError;
if (sscanf(s, "%d", &jnum) <= 0) return rtStandardError;
if ((jnum < 0) || (jnum > 5)) return rtStandardError;
if (sendJogJointStop(jnum) != 0) return rtStandardError;
return rtNoError;
}
static cmdResponseType setJog(char *s, connectionRecType *context)
{
int axis;
int jnum;
float speed;
char *pch;
pch = strtok(NULL, delims);
if (pch == NULL) return rtStandardError;
if (sscanf(pch, "%d", &axis) <= 0) return rtStandardError;
if ((axis < 0) || (axis > 5)) return rtStandardError;
if (sscanf(pch, "%d", &jnum) <= 0) return rtStandardError;
if ((jnum < 0) || (jnum > 5)) return rtStandardError;
pch = strtok(NULL, delims);
if (pch == NULL) return rtStandardError;
if (sscanf(pch, "%f", &speed) <= 0) return rtStandardError;
if (sendJogCont(axis, speed) != 0) return rtStandardError;
if (sendJogJointCont(jnum, speed) != 0) return rtStandardError;
return rtNoError;
}
@ -1051,21 +1051,21 @@ static cmdResponseType setFeedOverride(char *s, connectionRecType *context)
static cmdResponseType setJogIncr(char *s, connectionRecType *context)
{
int axis;
int jnum;
float speed, incr;
char *pch;
pch = strtok(NULL, delims);
if (pch == NULL) return rtStandardError;
if (sscanf(pch, "%d", &axis) <= 0) return rtStandardError;
if ((axis < 0) || (axis > 5)) return rtStandardError;
if (sscanf(pch, "%d", &jnum) <= 0) return rtStandardError;
if ((jnum < 0) || (jnum > 5)) return rtStandardError;
pch = strtok(NULL, delims);
if (pch == NULL) return rtStandardError;
if (sscanf(pch, "%f", &speed) <= 0) return rtStandardError;
pch = strtok(NULL, delims);
if (pch == NULL) return rtStandardError;
if (sscanf(pch, "%f", &incr) <= 0) return rtStandardError;
if (sendJogIncr(axis, speed, incr) != 0) return rtStandardError;
if (sendJogJointIncr(jnum, speed, incr) != 0) return rtStandardError;
return rtNoError;
}

View file

@ -1778,7 +1778,7 @@ static int emc_jog_stop(ClientData clientdata,
return TCL_ERROR;
}
if (0 != sendJogStop(joint)) {
if (0 != sendJogJointStop(joint)) {
setresult(interp,"emc_jog_stop: can't send jog stop msg");
return TCL_OK;
}
@ -1807,7 +1807,7 @@ static int emc_jog(ClientData clientdata,
return TCL_ERROR;
}
if (0 != sendJogCont(joint, speed)) {
if (0 != sendJogJointCont(joint, speed)) {
setresult(interp,"emc_jog: can't jog");
return TCL_OK;
}
@ -1842,7 +1842,7 @@ static int emc_jog_incr(ClientData clientdata,
return TCL_ERROR;
}
if (0 != sendJogIncr(joint, speed, incr)) {
if (0 != sendJogJointIncr(joint, speed, incr)) {
setresult(interp,"emc_jog_incr: can't jog");
return TCL_OK;
}

View file

@ -1364,51 +1364,49 @@ static int sendAbort()
return emcCommandSend(task_abort_msg);
}
static int axisJogging[EMCMOT_MAX_JOINTS] = {0,};
int sendJogStop(int axis)
int sendJogJointStop(int ja)
{
EMC_JOG_STOP emc_jog_stop_msg;
emc_jog_stop_msg.axis = axis;
axisJogging[axis] = 0;
if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE_TELEOP) { return -1; }
emc_jog_stop_msg.jjogmode = 1;
emc_jog_stop_msg.joint_or_axis = ja;
return emcCommandSend(emc_jog_stop_msg);
}
int sendJogCont(int axis, double speed)
int sendJogJointCont(int ja, double speed)
{
EMC_JOG_CONT emc_jog_cont_msg;
sendManual();
if (emcStatus->task.state != EMC_TASK_STATE_ON) { return -1; }
if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE_TELEOP) { return -1; }
if (ja < 0 || ja >= EMCMOT_MAX_JOINTS) { return -1; }
emc_jog_cont_msg.axis = axis;
emc_jog_cont_msg.jjogmode = 1;
emc_jog_cont_msg.joint_or_axis = ja;
emc_jog_cont_msg.vel = speed / 60.0;
axisJogging[axis] = 1;
sendManual();
return emcCommandSend(emc_jog_cont_msg);
}
int sendJogInc(int axis, double speed, double incr)
int sendJogJointIncr(int ja, double speed, double incr)
{
EMC_JOG_INCR emc_jog_incr_msg;
if (emcStatus->task.state != EMC_TASK_STATE_ON) {
return -1;
}
if (emcStatus->task.state != EMC_TASK_STATE_ON) { return -1; }
if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE_TELEOP) { return -1; }
if (ja < 0 || ja >= EMCMOT_MAX_JOINTS) { return -1; }
if (axis < 0 || axis >= EMCMOT_MAX_AXIS) {
return -1;
}
sendManual();
if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE_TELEOP)
return -1;
emc_jog_incr_msg.axis = axis;
emc_jog_incr_msg.jjogmode = 1;
emc_jog_incr_msg.joint_or_axis = ja;
emc_jog_incr_msg.vel = speed / 60.0;
emc_jog_incr_msg.incr = incr;
axisJogging[axis] = 1;
sendManual();
return emcCommandSend(emc_jog_incr_msg);
}
@ -1884,18 +1882,18 @@ static void check_hal_changes()
bit = new_halui_data.jog_minus[joint];
if ((bit != old_halui_data.jog_minus[joint]) || (bit && jog_speed_changed)) {
if (bit != 0)
sendJogCont(joint,-new_halui_data.jog_speed);
sendJogJointCont(joint,-new_halui_data.jog_speed);
else
sendJogStop(joint);
sendJogJointStop(joint);
old_halui_data.jog_minus[joint] = bit;
}
bit = new_halui_data.jog_plus[joint];
if ((bit != old_halui_data.jog_plus[joint]) || (bit && jog_speed_changed)) {
if (bit != 0)
sendJogCont(joint,new_halui_data.jog_speed);
sendJogJointCont(joint,new_halui_data.jog_speed);
else
sendJogStop(joint);
sendJogJointStop(joint);
old_halui_data.jog_plus[joint] = bit;
}
@ -1903,23 +1901,23 @@ static void check_hal_changes()
bit = (fabs(floatt) > new_halui_data.jog_deadband);
if ((floatt != old_halui_data.jog_analog[joint]) || (bit && jog_speed_changed)) {
if (bit)
sendJogCont(joint,(new_halui_data.jog_speed) * (new_halui_data.jog_analog[joint]));
sendJogJointCont(joint,(new_halui_data.jog_speed) * (new_halui_data.jog_analog[joint]));
else
sendJogStop(joint);
sendJogJointStop(joint);
old_halui_data.jog_analog[joint] = floatt;
}
bit = new_halui_data.jog_increment_plus[joint];
if (bit != old_halui_data.jog_increment_plus[joint]) {
if (bit)
sendJogInc(joint, new_halui_data.jog_speed, new_halui_data.jog_increment[joint]);
sendJogJointIncr(joint, new_halui_data.jog_speed, new_halui_data.jog_increment[joint]);
old_halui_data.jog_increment_plus[joint] = bit;
}
bit = new_halui_data.jog_increment_minus[joint];
if (bit != old_halui_data.jog_increment_minus[joint]) {
if (bit)
sendJogInc(joint, new_halui_data.jog_speed, -(new_halui_data.jog_increment[joint]));
sendJogJointIncr(joint, new_halui_data.jog_speed, -(new_halui_data.jog_increment[joint]));
old_halui_data.jog_increment_minus[joint] = bit;
}
@ -1962,9 +1960,9 @@ static void check_hal_changes()
js = new_halui_data.joint_selected;
if ((bit != old_halui_data.jog_minus[num_joints]) || (bit && jog_speed_changed)) {
if (bit != 0)
sendJogCont(js, -new_halui_data.jog_speed);
sendJogJointCont(js, -new_halui_data.jog_speed);
else
sendJogStop(js);
sendJogJointStop(js);
old_halui_data.jog_minus[num_joints] = bit;
}
@ -1972,9 +1970,9 @@ static void check_hal_changes()
js = new_halui_data.joint_selected;
if ((bit != old_halui_data.jog_plus[num_joints]) || (bit && jog_speed_changed)) {
if (bit != 0)
sendJogCont(js,new_halui_data.jog_speed);
sendJogJointCont(js,new_halui_data.jog_speed);
else
sendJogStop(js);
sendJogJointStop(js);
old_halui_data.jog_plus[num_joints] = bit;
}
@ -1982,7 +1980,7 @@ static void check_hal_changes()
js = new_halui_data.joint_selected;
if (bit != old_halui_data.jog_increment_plus[num_joints]) {
if (bit)
sendJogInc(js, new_halui_data.jog_speed, new_halui_data.jog_increment[num_joints]);
sendJogJointIncr(js, new_halui_data.jog_speed, new_halui_data.jog_increment[num_joints]);
old_halui_data.jog_increment_plus[num_joints] = bit;
}
@ -1990,7 +1988,7 @@ static void check_hal_changes()
js = new_halui_data.joint_selected;
if (bit != old_halui_data.jog_increment_minus[num_joints]) {
if (bit)
sendJogInc(js, new_halui_data.jog_speed, -(new_halui_data.jog_increment[num_joints]));
sendJogJointIncr(js, new_halui_data.jog_speed, -(new_halui_data.jog_increment[num_joints]));
old_halui_data.jog_increment_minus[num_joints] = bit;
}

View file

@ -1279,7 +1279,8 @@ static void idleHandler()
// key up for jogs
if (axisJogging != AXIS_NONE && keyup_count == 0)
{
emc_jog_stop_msg.axis = axisIndex(axisJogging);
emc_jog_stop_msg.joint_or_axis = axisIndex(axisJogging);
emc_jog_stop_msg.jjogmode = 1;
emcCommandSend(emc_jog_stop_msg);
axisJogging = AXIS_NONE;
}
@ -2126,7 +2127,8 @@ int main(int argc, char *argv[])
{
if (jogMode == JOG_INCREMENTAL)
{
emc_jog_incr_msg.axis = axisIndex(AXIS_X);
emc_jog_incr_msg.joint_or_axis = axisIndex(AXIS_X);
emc_jog_incr_msg.jjogmode = 1;
if (xJogPol)
emc_jog_incr_msg.vel = jogSpeed / 60.0;
else
@ -2138,7 +2140,8 @@ int main(int argc, char *argv[])
else
{
jogMode = JOG_CONTINUOUS;
emc_jog_cont_msg.axis = axisIndex(AXIS_X);
emc_jog_cont_msg.joint_or_axis = axisIndex(AXIS_X);
emc_jog_cont_msg.jjogmode = 1;
if (xJogPol)
emc_jog_cont_msg.vel = jogSpeed / 60.0;
else
@ -2156,7 +2159,8 @@ int main(int argc, char *argv[])
{
if (jogMode == JOG_INCREMENTAL)
{
emc_jog_incr_msg.axis = axisIndex(AXIS_X);
emc_jog_incr_msg.joint_or_axis = axisIndex(AXIS_X);
emc_jog_incr_msg.jjogmode = 1;
if (xJogPol)
emc_jog_incr_msg.vel = - jogSpeed / 60.0;
else
@ -2168,7 +2172,8 @@ int main(int argc, char *argv[])
else
{
jogMode = JOG_CONTINUOUS;
emc_jog_cont_msg.axis = axisIndex(AXIS_X);
emc_jog_cont_msg.joint_or_axis = axisIndex(AXIS_X);
emc_jog_cont_msg.jjogmode = 1;
if (xJogPol)
emc_jog_cont_msg.vel = - jogSpeed / 60.0;
else
@ -2186,7 +2191,8 @@ int main(int argc, char *argv[])
{
if (jogMode == JOG_INCREMENTAL)
{
emc_jog_incr_msg.axis = axisIndex(AXIS_Y);
emc_jog_incr_msg.joint_or_axis = axisIndex(AXIS_Y);
emc_jog_incr_msg.jjogmode = 1;
if (yJogPol)
emc_jog_incr_msg.vel = jogSpeed / 60.0;
else
@ -2198,7 +2204,8 @@ int main(int argc, char *argv[])
else
{
jogMode = JOG_CONTINUOUS;
emc_jog_cont_msg.axis = axisIndex(AXIS_Y);
emc_jog_cont_msg.joint_or_axis = axisIndex(AXIS_Y);
emc_jog_cont_msg.jjogmode = 1;
if (yJogPol)
emc_jog_cont_msg.vel = jogSpeed / 60.0;
else
@ -2216,7 +2223,8 @@ int main(int argc, char *argv[])
{
if (jogMode == JOG_INCREMENTAL)
{
emc_jog_incr_msg.axis = axisIndex(AXIS_Y);
emc_jog_incr_msg.joint_or_axis = axisIndex(AXIS_Y);
emc_jog_incr_msg.jjogmode = 1;
if (yJogPol)
emc_jog_incr_msg.vel = - jogSpeed / 60.0;
else
@ -2228,7 +2236,8 @@ int main(int argc, char *argv[])
else
{
jogMode = JOG_CONTINUOUS;
emc_jog_cont_msg.axis = axisIndex(AXIS_Y);
emc_jog_cont_msg.joint_or_axis = axisIndex(AXIS_Y);
emc_jog_cont_msg.jjogmode = 1;
if (yJogPol)
emc_jog_cont_msg.vel = - jogSpeed / 60.0;
else
@ -2246,7 +2255,8 @@ int main(int argc, char *argv[])
{
if (jogMode == JOG_INCREMENTAL)
{
emc_jog_incr_msg.axis = axisIndex(AXIS_Z);
emc_jog_incr_msg.joint_or_axis = axisIndex(AXIS_Z);
emc_jog_incr_msg.jjogmode = 1;
if (zJogPol)
emc_jog_incr_msg.vel = jogSpeed / 60.0;
else
@ -2258,7 +2268,8 @@ int main(int argc, char *argv[])
else
{
jogMode = JOG_CONTINUOUS;
emc_jog_cont_msg.axis = axisIndex(AXIS_Z);
emc_jog_cont_msg.joint_or_axis = axisIndex(AXIS_Z);
emc_jog_cont_msg.jjogmode = 1;
if (zJogPol)
emc_jog_cont_msg.vel = jogSpeed / 60.0;
else
@ -2276,7 +2287,8 @@ int main(int argc, char *argv[])
{
if (jogMode == JOG_INCREMENTAL)
{
emc_jog_incr_msg.axis = axisIndex(AXIS_Z);
emc_jog_incr_msg.joint_or_axis = axisIndex(AXIS_Z);
emc_jog_incr_msg.jjogmode = 1;
if (zJogPol)
emc_jog_incr_msg.vel = - jogSpeed / 60.0;
else
@ -2288,7 +2300,9 @@ int main(int argc, char *argv[])
else
{
jogMode = JOG_CONTINUOUS;
emc_jog_cont_msg.axis = axisIndex(AXIS_Z);
emc_jog_cont_msg.joint_or_axis = axisIndex(AXIS_Z);
emc_jog_cont_msg.jjogmode = 1;
if (zJogPol)
if (zJogPol)
emc_jog_cont_msg.vel = - jogSpeed / 60.0;
else

View file

@ -551,32 +551,31 @@ int sendOverrideLimits(int axis)
return 0;
}
static int axisJogging[EMCMOT_MAX_AXIS] = {0,};
int sendJogStop(int axis)
int sendJogJointStop(int jnum)
{
EMC_JOG_STOP emc_jog_stop_msg;
emc_jog_stop_msg.axis = axis;
emc_jog_stop_msg.jjogmode = 1;
emc_jog_stop_msg.joint_or_axis = jnum;
emcCommandSend(emc_jog_stop_msg);
axisJogging[axis] = 0;
return 0;
}
int sendJogCont(int axis, double speed)
int sendJogJointCont(int jnum, double speed)
{
EMC_JOG_CONT emc_jog_cont_msg;
if (0 == jogPol[axis]) {
if (0 == jogPol[jnum]) {
speed = -speed;
}
emc_jog_cont_msg.axis = axis;
emc_jog_cont_msg.jjogmode = 1;
emc_jog_cont_msg.joint_or_axis = jnum;
emc_jog_cont_msg.vel = speed / 60.0;
emcCommandSend(emc_jog_cont_msg);
axisJogging[axis] = 1;
if (emcWaitType == EMC_WAIT_RECEIVED) {
return emcCommandWaitReceived();
} else if (emcWaitType == EMC_WAIT_DONE) {
@ -586,15 +585,16 @@ int sendJogCont(int axis, double speed)
return 0;
}
int sendJogIncr(int axis, double speed, double incr)
int sendJogJointIncr(int jnum, double speed, double incr)
{
EMC_JOG_INCR emc_jog_incr_msg;
if (0 == jogPol[axis]) {
if (0 == jogPol[jnum]) {
speed = -speed;
}
emc_jog_incr_msg.axis = axis;
emc_jog_incr_msg.jjogmode = 1;
emc_jog_incr_msg.joint_or_axis = jnum;
emc_jog_incr_msg.vel = speed / 60.0;
emc_jog_incr_msg.incr = incr;
emcCommandSend(emc_jog_incr_msg);
@ -604,7 +604,6 @@ int sendJogIncr(int axis, double speed, double incr)
} else if (emcWaitType == EMC_WAIT_DONE) {
return emcCommandWaitDone();
}
axisJogging[axis] = 1;
return 0;
}

View file

@ -101,9 +101,9 @@ extern int sendManual();
extern int sendAuto();
extern int sendMdi();
extern int sendOverrideLimits(int axis);
extern int sendJogStop(int axis);
extern int sendJogCont(int axis, double speed);
extern int sendJogIncr(int axis, double speed, double incr);
extern int sendJogJointStop(int jnum);
extern int sendJogJointCont(int jnum, double speed);
extern int sendJogJointIncr(int jnum, double speed, double incr);
extern int sendMistOn();
extern int sendMistOff();
extern int sendFloodOn();

View file

@ -926,7 +926,7 @@ static int sendOverrideLimits()
return 0;
}
static int sendJogStop(int axis)
static int sendJogJointStop(int axis)
{
EMC_JOG_STOP emc_jog_stop_msg;
@ -939,7 +939,8 @@ static int sendJogStop(int axis)
return 0;
}
emc_jog_stop_msg.axis = axisJogging;
emc_jog_stop_msg.joint_or_axis = axisJogging;
emc_jog_stop_msg.jjogmode = 1;
emcCommandSend(emc_jog_stop_msg);
axisJogging = -1;
@ -947,7 +948,7 @@ static int sendJogStop(int axis)
return 0;
}
static int sendJogCont(int axis, double speed)
static int sendJogJointCont(int axis, double speed)
{
EMC_JOG_CONT emc_jog_cont_msg;
@ -964,7 +965,8 @@ static int sendJogCont(int axis, double speed)
speed = -speed;
}
emc_jog_cont_msg.axis = axis;
emc_jog_cont_msg.joint_or_axis = axis;
emc_jog_cont_msg.jjogmode = 1;
emc_jog_cont_msg.vel = speed / 60.0;
emcCommandSend(emc_jog_cont_msg);
@ -973,7 +975,7 @@ static int sendJogCont(int axis, double speed)
return 0;
}
static int sendJogIncr(int axis, double speed, double incr)
static int sendJogJointIncr(int axis, double speed, double incr)
{
EMC_JOG_INCR emc_jog_incr_msg;
@ -990,7 +992,8 @@ static int sendJogIncr(int axis, double speed, double incr)
speed = -speed;
}
emc_jog_incr_msg.axis = axis;
emc_jog_incr_msg.joint_or_axis = axis;
emc_jog_incr_msg.jjogmode = 1;
emc_jog_incr_msg.vel = speed / 60.0;
emc_jog_incr_msg.incr = jogIncrement;
emcCommandSend(emc_jog_incr_msg);
@ -2363,18 +2366,18 @@ static void downAction(Widget w,
}
else if (w == jogMinusLabel) {
if (jogIncrement > 0.0) {
sendJogIncr(activeAxis, -jogSpeed, jogIncrement);
sendJogJointIncr(activeAxis, -jogSpeed, jogIncrement);
}
else {
sendJogCont(activeAxis, -jogSpeed);
sendJogJointCont(activeAxis, -jogSpeed);
}
}
else if (w == jogPlusLabel) {
if (jogIncrement > 0.0) {
sendJogIncr(activeAxis, jogSpeed, jogIncrement);
sendJogJointIncr(activeAxis, jogSpeed, jogIncrement);
}
else {
sendJogCont(activeAxis, jogSpeed);
sendJogJointCont(activeAxis, jogSpeed);
}
}
else if (w == posLabel[0]) {
@ -2475,13 +2478,13 @@ static void upAction(Widget w,
else if (w == jogMinusLabel) {
// only stop it if it's continuous jogging
if (jogIncrement <= 0.0) {
sendJogStop(axisJogging);
sendJogJointStop(axisJogging);
}
}
else if (w == jogPlusLabel) {
// only stop it if it's continuous jogging
if (jogIncrement <= 0.0) {
sendJogStop(axisJogging);
sendJogJointStop(axisJogging);
}
}
else if (w == posLabel[0]) {
@ -2700,60 +2703,60 @@ static void keyPressAction(unsigned int state, unsigned int keycode)
case KEY_PGUP:
activeAxis = 2;
if (jogIncrement > 0.0) {
sendJogIncr(activeAxis, jogSpeed, jogIncrement);
sendJogJointIncr(activeAxis, jogSpeed, jogIncrement);
}
else {
sendJogCont(activeAxis, jogSpeed);
sendJogJointCont(activeAxis, jogSpeed);
}
break;
case KEY_PGDN:
activeAxis = 2;
if (jogIncrement > 0.0) {
sendJogIncr(activeAxis, -jogSpeed, jogIncrement);
sendJogJointIncr(activeAxis, -jogSpeed, jogIncrement);
}
else {
sendJogCont(activeAxis, -jogSpeed);
sendJogJointCont(activeAxis, -jogSpeed);
}
break;
case KEY_RIGHT:
activeAxis = 0;
if (jogIncrement > 0.0) {
sendJogIncr(activeAxis, jogSpeed, jogIncrement);
sendJogJointIncr(activeAxis, jogSpeed, jogIncrement);
}
else {
sendJogCont(activeAxis, jogSpeed);
sendJogJointCont(activeAxis, jogSpeed);
}
break;
case KEY_LEFT:
activeAxis = 0;
if (jogIncrement > 0.0) {
sendJogIncr(activeAxis, -jogSpeed, jogIncrement);
sendJogJointIncr(activeAxis, -jogSpeed, jogIncrement);
}
else {
sendJogCont(activeAxis, -jogSpeed);
sendJoJointgCont(activeAxis, -jogSpeed);
}
break;
case KEY_UP:
activeAxis = 1;
if (jogIncrement > 0.0) {
sendJogIncr(activeAxis, jogSpeed, jogIncrement);
sendJogJointIncr(activeAxis, jogSpeed, jogIncrement);
}
else {
sendJogCont(activeAxis, jogSpeed);
sendJogJointCont(activeAxis, jogSpeed);
}
break;
case KEY_DOWN:
activeAxis = 1;
if (jogIncrement > 0.0) {
sendJogIncr(activeAxis, -jogSpeed, jogIncrement);
sendJogJointIncr(activeAxis, -jogSpeed, jogIncrement);
}
else {
sendJogCont(activeAxis, -jogSpeed);
sendJogJointCont(activeAxis, -jogSpeed);
}
break;
@ -3016,7 +3019,7 @@ static void keyReleaseAction(unsigned int state, unsigned int keycode)
case KEY_RIGHT:
if (jogIncrement <= 0.0) {
// only stop it if it's continuous jogging
sendJogStop(axisJogging);
sendJogJointStop(axisJogging);
}
break;
@ -3024,7 +3027,7 @@ static void keyReleaseAction(unsigned int state, unsigned int keycode)
case KEY_DOWN:
if (jogIncrement <= 0.0) {
// only stop it if it's continuous jogging
sendJogStop(axisJogging);
sendJogJointStop(axisJogging);
}
break;
@ -3032,7 +3035,7 @@ static void keyReleaseAction(unsigned int state, unsigned int keycode)
case KEY_PGDN:
if (jogIncrement <= 0.0) {
// only stop it if it's continuous jogging
sendJogStop(axisJogging);
sendJogJointStop(axisJogging);
}
break;